timescale/promscale_extension

Cannot create metric view when there's a tag with key `series`

alejandrodnm opened this issue · 1 comments

When creating the view for a metric the following function is called with the label_key as argument:

CREATE OR REPLACE FUNCTION _prom_catalog.get_label_key_column_name_for_view(label_key text, id BOOLEAN)

The label_key is checked against some reserved keys, if there's a match then the key is prepended with label_:

SELECT label_key = ANY(ARRAY['time', 'value', 'series_id', 'labels'])
INTO STRICT is_reserved;
IF is_reserved THEN
label_key := 'label_' || label_key;
END IF;

If the key is series it won't match series_id and pass the check. The problem is that if the key is an id (second parameter of the function) we call:

RETURN (_prom_catalog.get_or_create_label_key(label_key)).id_column_name;

Which returns series_id and creates the conflict:

_prom_catalog.pg_name_unique(new_key || '_id', format('%s_id', new_id))

This was reported by one of our users timescale/promscale#1685