How to combine 2 queries in promql

Viewed 19

I have two queries in promql that I need join by instance so I can display the node name

first query : (1 - avg(irate(node_cpu_seconds_total{mode="idle"}[5m])) by (instance))

first query result :

{instance="10.103.20.68:9796"} 0.10527083333193621

second query : node_uname_info

second query result : `

node_uname_info{container="node-exporter", domainname="(none)", endpoint="metrics", instance="10.103.20.68:9796", job="node-exporter", machine="x86_64", namespace="cattle-monitoring-system", nodename="iagindvd01-indv-dev-02-mastercentos3", pod="rancher-monitoring-prometheus-node-exporter-pns4c", release="3.10.0-1160.59.1.el7.x86_64", service="rancher-monitoring-prometheus-node-exporter", sysname="Linux", version="#1 SMP Wed Feb 23 16:47:03 UTC 2022"}

`

1 Answers

You need to match both series based on their label sets using on and also group_left to make the nodename label from the right side available in the final result:

(1 - avg by (instance) (irate(node_cpu_seconds_total{mode="idle"}[5m])))
* on (instance) group_left (nodename) node_uname_info
Related