I'm trying to monitor my network switches and I can get data from it. But the query doesn't return ifName in the results, so when I graph per interface status I can't label the results with the interface name.
Prometheus query irate(ifHCOutOctets{job="snmp"}[5m])
Results
{ifIndex="cpu",instance="192.168.7.130",job="snmp"}
{ifIndex="g1",instance="192.168.7.130",job="snmp"}
{ifIndex="cpu",instance="192.168.7.130",job="snmp"}
This feels like I need a join to add ifName to the result set but I just can figure out how to do that.
Normally, you should have metrics describing your interface (metrics ifAlias
, ifDescr
and ifName
which can be the same):
ifDescr{ifAlias="",ifDescr="ether1",ifIndex="cpu",ifName="ether1"} 1
ifDescr{ifAlias="",ifDescr="ether2",ifIndex="g1",ifName="ether2"} 1
Then you can apply a multiplication operation to match the metrics with a GROUP instruction to pull the labels:
irate(ifHCOutOctets{job="snmp"}[5m]) BY(ifIndex) * ON(ifIndex) GROUP_RIGHT ifDescr{job="snmp"}
I am also trying to create a query similar to this. Basically I want to see Interface Description and their utilization. I followed the above suggestion and made below query but this is not working. Data Source is Victoria Metrics. Can you please suggest what is incorrect?
(irate(ifHCOutOctets{instance="Server1"}5m]) / 125000) / ifHighSpeed{instance="Server1"} by (ifIndex) * on (ifIndex) group_right ifDescr{instance="Server1"}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.