Plot some rows of timeseries depending on condition

  • What Grafana version and what operating system are you using?

Will update later to add this info, using Prometheus datasource

  • What are you trying to achieve?

I have a metric “my_metric”, with a name and value. It can be 0 or 1. I want to plot max(my_metric) by (name), but only for "name"s which have had a 1 for at least one hour continuously at some point in the dashboard range.

  • How are you trying to achieve it?

I tried multiple things, but the closest I got was with query max(my_metric) by (name) on (name) (min_over_time(my_metric[1h]))

  • What happened?

However this graphs the result of min_over_time(my_metric[1h]), not the result of max(my_metric) by (name)…

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

No errors

Create dashboard variable, which will have only names with that condition and then use that variable in the panel to filter only timeseries with those names.