# How to get interface bandwidth utilization using grafana 9.5

**URL:** <https://community.grafana.com/t/how-to-get-interface-bandwidth-utilization-using-grafana-9-5/89828>\
**Category:** InfluxDB\
**Tags:** influxdb\
**Created:** [June 18, 2023, 9:30pm UTC](https://community.grafana.com/t/how-to-get-interface-bandwidth-utilization-using-grafana-9-5/89828 "2023-06-18T21:30:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![barr8181](https://avatars.discourse-cdn.com/v4/letter/b/c57346/32.png) [@barr8181](https://community.grafana.com/u/barr8181)\
**Post date:** [June 18, 2023, 9:30pm UTC](https://community.grafana.com/t/how-to-get-interface-bandwidth-utilization-using-grafana-9-5/89828/1 "2023-06-18T21:30:27Z")

</div>

Hi, i’m using grafana 9.5 with influxdb2 and telegraf. I’m using snmp in order to get badwidth utilization on a switch. I made the query, but the results are a graph with the Y Axes displaying i think the accumulated data not current data.

I’m using grafana with influxdb2 influx. Does anybody know how to do it?

---

<div class="post-metadata">

**Author:** ![yosiasz](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yosiasz/32/45847_2.png) [@yosiasz](https://community.grafana.com/u/yosiasz)\
**Post date:** [June 18, 2023, 10:29pm UTC](https://community.grafana.com/t/how-to-get-interface-bandwidth-utilization-using-grafana-9-5/89828/2 "2023-06-18T22:29:40Z")

</div>

Welcome

Since we do not have access to what you have please post sampling of data and query you used

---

<div class="post-metadata">

**Author:** ![barr8181](https://avatars.discourse-cdn.com/v4/letter/b/c57346/32.png) [@barr8181](https://community.grafana.com/u/barr8181)\
**Post date:** [June 20, 2023, 12:22am UTC](https://community.grafana.com/t/how-to-get-interface-bandwidth-utilization-using-grafana-9-5/89828/3 "2023-06-20T00:22:32Z")

</div>

I wanna collect a switch bandwidth utilization, using ifInOctets and ifOutOctet. The examples that I saw was using a different version of Grafana.

See the image below, that basically what I need.

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/c/7/c71af3cb871a2beef1ab61650c773d212db67316.png)

---

<div class="post-metadata">

**Author:** ![barr8181](https://avatars.discourse-cdn.com/v4/letter/b/c57346/32.png) [@barr8181](https://community.grafana.com/u/barr8181)\
**Post date:** [June 21, 2023, 11:57pm UTC](https://community.grafana.com/t/how-to-get-interface-bandwidth-utilization-using-grafana-9-5/89828/4 "2023-06-21T23:57:12Z")

</div>

I still don’t know how to create a query for this. Anybody to help?

---

<div class="post-metadata">

**Author:** ![barr8181](https://avatars.discourse-cdn.com/v4/letter/b/c57346/32.png) [@barr8181](https://community.grafana.com/u/barr8181)\
**Post date:** [June 22, 2023, 1:54pm UTC](https://community.grafana.com/t/how-to-get-interface-bandwidth-utilization-using-grafana-9-5/89828/5 "2023-06-22T13:54:17Z")

</div>

That’s the query that i have.

from(bucket: “telegraf”)  
|\> range(start: v.timeRangeStart, stop: v.timeRangeStop)  
|\> filter(fn: (r) =\> r[“hostname”] == “Netgear\_sw”)  
|\> filter(fn: (r) =\> r[“\_measurement”] == “ifXTable”)  
|\> filter(fn: (r) =\> r[“\_field”] == “ifHCOutOctets” or r[“\_field”] == “ifHCInOctets”)  
|\> filter(fn: (r) =\> r[“ifDescr”] == “g5”)  
|\> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)  
|\> yield(name: “mean”)

How can i convert this to the one on the picture above?

- using mean, non\_negative\_derivative, math(\*8), alias()

---

<div class="post-metadata">

**Author:** ![barr8181](https://avatars.discourse-cdn.com/v4/letter/b/c57346/32.png) [@barr8181](https://community.grafana.com/u/barr8181)\
**Post date:** [June 23, 2023, 3:36am UTC](https://community.grafana.com/t/how-to-get-interface-bandwidth-utilization-using-grafana-9-5/89828/6 "2023-06-23T03:36:49Z")

</div>

i came up with the query below. It’s working as expected. I just don’t know if is the best way to do it. Another thing is how to change the label, i end up configuring grafana with regex in order to change the label manually,since i don’t have much devices it’s ok to do it manually. I used the map function in order to make it work. I hope this help somebody.

from(bucket: “telegraf”)  
|\> range(start: 2023-06-22T21:25:10.653Z, stop: 2023-06-23T03:25:10.653Z)  
|\> filter(fn: (r) =\> r[“hostname”] == “Netgear\_sw”)  
|\> filter(fn: (r) =\> r[“\_measurement”] == “ifXTable”)  
|\> filter(fn: (r) =\> r[“\_field”] == “ifHCOutOctets” or r[“\_field”] == “ifHCInOctets”)  
|\> filter(fn: (r) =\> r[“ifDescr”] == “Slot: 0 Port: 5 Gigabit - Level”)  
**|\> map(fn: (r) =\> ({r with \_value: r.\_value \* 8 / 300}))**  
**|\> derivative(unit: 1s, nonNegative: true, columns: [“\_value”], timeColumn: “\_time”)**  
|\> aggregateWindow(every: 5m, fn: mean, createEmpty: false)  
|\> yield(name: “mean”)
