grok_exporter icon indicating copy to clipboard operation
grok_exporter copied to clipboard

allow same metric name

Open frenkye opened this issue 4 years ago • 2 comments
trafficstars

Hi,

tried to find out if this was somewhere discused or I'am doing something wrong. Is there any reason why can we reuse metric name?

Getting error: Invalid metric configuration: metric '<metricName>' defined twice

This should not be a problem, if labels differ like event or message, becase you can't have 2 metric with same labels in output, that would be a problem.

In our use case we have multiple patterns on few log files and now we have to have for each pattern diffrent metric which mean we have to have diffrent alert for each pattern a list go on. While if we could reuse metric name, but differ by labels we could have few alerts and adding new pattern to grok, will be much easier.

frenkye avatar Jul 29 '21 11:07 frenkye

One thing you can try is to create a single pattern that matches all cases. For example, if you have

- type: counter
  name: my_metric
  match: pattern1
  ...

and

- type: counter
  name: my_metric
  match: pattern2
  ...

you could convert this to

- type: counter
  name: my_metric
  match: pattern1|pattern2
  ...

fstab avatar Aug 09 '21 19:08 fstab

I know that is possible, but this doesn't allow for custom message per match.

frenkye avatar Sep 25 '21 10:09 frenkye