Using range with label_join

I have a set of metrics that are being sent only when there is an issue. I want to create an expression that will capture the number of issues in the last 15 minutes. For efficiency I would like to use a regex with the metrics names (let’s asume that there will be no performance problems) . After I have the count I would like to know if I had more than 9 issues in the 15 minutes interval

  • I am starting from this expression, label_join({name=~“node_load\d+”,instance=“172.31.2.79:9100”},“metricname”,“”,“name”) which adds the metric name as a label to each metric. I will use it later in a by (metricname)
  • My goal now is to count the number of samples for each metric in the last 15 minutes (the number of samples represents the number of issues). I can’t find where the put the range [15m] without getting a syntax error.

Any help will be appreciated.

This sounds like events rather than metrics. For a metric system you should have the metric always existing, often as a counter which increases when an issue is detected.

What you are describing are instead events, which are not something Prometheus handles. You can instead insert them into another system (e.g. a database such as Elasticsearch or MySQL) and then convert them into metrics.

Thank for the reply @stuart. I completely agree with you but my hands are pretty much tied here, since this is a third party that sends the metrics this way. Any ideas about how to do count_over_time on these set of metric series, label_join({name =~“node_load\d+”,instance=“172.31.2.79:9100”},“metricname”,“”,“name ”)?