Bug in labelling where regex is used?

Hi! I am using timelion with this code .es(index = measurements, metric = max:value, split = id:4, q = “bar”).label(regex = ‘.FOO-(.)’, label = ‘$1 Consumption’).

The thing is, I have a column with structure “FOO-BAR (some number)”. So, I am using regex in order to match entities in that column and put them as first argument in label. I am expecting something like this in my labels BAR1 Consumption, BAR2 Consumption and etc. But instead, I get following:

BAR1 > max(value) Consumption, BAR2 > max(value) Consumption
Is it the way it supposed to work? If I label graphs already why I have also my aggregation there?

Hi Emil,
the regex is actually execute against the legend as is at this point. Meaning you shouldn’t make your regex match against the field value, but get rid of the legend function, look how the legend looks, and make your regex match this legend and extract what it needs.
Cheers

Tim

Hi Tim,
this is my original query without applying the regex part. .es(index = measurements, metric = max:value, split = meter_id:4, q = “1-0:1.8.0*255”).derivative(). This is what I get in my labels:

q:1-0:1.8.0*255 > meter_id:CUC-DEMO6 > max(value)
and this is my query with regex. .es(index = measurements, metric = max:value, split = meter_id:4, q = "1\-0\:1\.8\.0\*255").derivative().label(regex = '.*CUC-(.*)', label = '$1 Consumption'). This is what I get in response in my label:
DEMO6 > max(value) Consumption
My question would be, is this the normal behavior? If yes, how I can "make" > max(value) part disappear?

Try not to match the > sign in your capture group: .CUC-([^>]).*, because currently your capture group matches the whole rest of the string (including the aggregation part).

Thank you Tim,
it did solve my problem. Seems, I haven’t quite understood the core idea behind labeling.

So, it is used to match the label itself, not some columns

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.