I'm trying to graph the temperature of my servers with Prometheus's hwmon
and Grafana.
Relevant for this are 2 time series that prometheus-node-exporter
offers:
node_hwmon_temp_celsius
which has the actual temperatures; it has labels like:{chip="platform_coretemp_0",sensor="temp1"}
node_hwmon_sensor_label
which is a helper time series for temperature sensors that have a name (the Prometheus label calledlabel
):{chip="platform_coretemp_0",sensor="temp1",label="core_0"}
On https://github.com/prometheus/node_exporter/issues/631 it is explained that:
labels are not available for all sensors. If all you sensors have a label, you can do something like this to join them:
node_hwmon_temp_celsius{...} * ignoring(label) group_left(label) node_hwmon_sensor_label
But some of my sensors don't have a label. The above PromQL query does not help in that case; group_left(label)
returns no results in that case.
Instead, I would like to write a query for the temperatures that has the label
label present, always, and defaults it to unknown-sensor-name
if the label
label is missing.
How can I do this with PromQL?