Search code examples
kubernetesprometheusgrafanamonitoring

Group query in Grafana GQL to use a field from another query as legend


I'm trying to monitor the bandwidth usage of each node of my Kubernetes cluster but I cannot find a way to use the node name as legend.

To get the bandwidth input, I use the query:

sum by(instance) (irate(node_network_receive_bytes_total[$interval:$resolution]))

Note: interval and resolution are time based value (e.g, 4h:30s)

But this returns me the instance by their IP address and node_network_receive_bytes_total has no nodename field.

So I want to use the query

node_uname_info

To get the node name and then combine these field to use the node_name as legend for corresponding instance.

I tried to use transform join by labels and multiple techniques to find a solutions but I couldn't find one.

Is it actually possible with Grafana? If so, how can I do that because I always ends up with IP address as legend and couldn't find a way to merge these fields with a GQL query.


Solution

  • Use the following query to group by nodename but based on instance label.

    sum by (instance)(irate(node_network_receive_bytes_total[4h:30s])) * on(instance) group_left(nodename) (node_uname_info)
    

    Hope this helps.