regex – Reusing a regexp match across 2 metrics/labels

For an alert I have the following expression:

node_hwmon_tempcelsius{sensor="nvme_nvme0"} >= node_hwmon_temp_crit_celsius{sensor="nvme_nvme0"}

repeated for nvme 0-5. I don’t want to enumerate all the nvmes by hand and instead use a regexp sort of like:

node_hwmon_tempcelsius{sensor=~"^nvme_nvme.*$"} >= node_hwmon_temp_crit_celsius{sensor=~"nvme_nvme.*$"}

But whatever matches the first regexp has to be reused for the second regexp.

Anyone know the syntax for that?

Read more here: Source link