'How to Make a graph of consecutive values in Prometheus
In a Debian Os target, I want to calculate BandWidth utilization "%" on a 1-minute interval and generate a graph of these BW values over 1Hr time window using Prometheus.
"60 minutes = 60 different values of BW"
I configured snmp_exporter to scrape snmp_agent metrics such as ifHCInOctets from the target server and here's the equation:
Interface In Utilization % =
((( [Total Sent packets in Bytes "ifHCInOctets_time2" - Total Sent packets in Bytes "ifHCInOctets _time1"] * 8 "Bytes into Bits") / ▲time "60s") / Maximum-Bandwidth "in bits/sec") * 100 "%"
How can I apply this equation in ▲time=60s intervals and apply it for a 1H time-window and depict these 60 values of BW consecutively in a Prometheus graph

Solution 1:[1]
PromQL expression should looks like this:
(rate(ifHCOutOctets[1m]) * 8) / (ifHighSpeed * 1000000) * 100
If you want to restrict to particular interface, add filter like
(rate(ifHCOutOctets{ifIndex="0"}[1m]) * 8) / (ifHighSpeed{ifIndex="0"} * 1000000) * 100
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | rkosegi |
