Network total bandwidth usage

Hi all
My goal is monitoring the cumulative bandwidth used on my network and track the total usage in GB/TB per month from each network port, e. g. [1].

I’m tying with Grafana / InfluxDB / Cacti + Plugin [2] and or Collectd.

From both cacti and collectd, I can’t generate the expected value. I have tried the queries with:

SELECT sum(“value”)
SELECT 8derivative(sum(“value”),1s)
SELECT 8
derivative(mean(“value”),1s)

But every query show different value from the Cacti Total In/Out graphs

Any help would be greatly appreciated

[1] https://statoshi.info/dashboard/db/bandwidth-usage?panelId=2&fullscreen
[2] https://www.urban-software.com/products/nmid-plugins/cereustransporter/

Can you provide more details, please.

  • In what way are the values from InfluxDB wrong? Or are they wrong in Cacti? It is hard to know which one have the problem with?
  • Is the problem with the query in Grafana or the raw data in InfluxDB or the raw data from Cacti or the raw data from Collectd?
  • Can you show a screenshot of your InfluxDB query in Grafana.
  • Why are you multiplying the derivative by 8?
  • Why are you combining derivative with sum and mean?

Here is an example of how to use the derivative function in InfluxDB: https://docs.influxdata.com/influxdb/v1.2/query_language/functions/#examples-of-basic-syntax-1

Hi Daniel

Thanks for your reply

From cacti the values are right.

For example, from cacti I have the network port with the values below on period of: From 2017-05-25 18:00 TO 2017-05-31 11:51

What I’m trying replicate on Grafana is the Total In value which in this example the value is: 1.68TB

Doing it on Grafana using the query:

SELECT mean(“value”) AS “traffic_in” FROM “interface.traffic” WHERE “host” = ‘MyHost’ AND “namecache” =~ /Traffic - 1/0/15/ AND “type” = ‘traffic_in’ AND timeFilter GROUP BY time(__interval) fill(none)

And on dash / Axes tab using bits unit, it got the value: 33.905Tb every period, even the last 5 minutes:

The use of the derivative function in this case was just a test. I had used the derivative function multiplying by 8 to convert the bit/sec to bytes/sec.

As I said before, my goal is make something like that [1] and every month restart the value sum of the cumulative bandwidth traffic.

Thank you

[1] https://statoshi.info/dashboard/db/bandwidth-usage?panelId=2&fullscreen

I have the same question.
Did you resolve it?

Thanks

I missed following up here - it sounds like the non-negative derivative grouped by month should work. There is no need to multiply by 8 - just choose the correct unit in Grafana.

Just to clarify; I’m try the same kind of thing (grafana from influxdb being fed by collectd), and am trying to get a value for the last rolling 30 day/7day/24hour/1h periods (I presume this is what is meant by the above, and there is no way of grouping by calendar month/week etc).

To do this I have queries that look like this feeding a singlestat:

SELECT non_negative_derivative(mean(“value”), 30d) FROM “interface_rx” WHERE (“host” = ‘x’ AND “instance” = ‘y’ AND “type” = ‘if_octets’) AND time >= now() - 35d GROUP BY time(1h) fill(previous)

The thinking here is that I’m going to get the last value for the derivative, which would be the difference between the mean of the values in the past hour, vs the mean of the values in an hour 30 days ago. ‘now() - 35d’ is to ensure that I have at least 30 days of data.

I notice however that the final result is very sensitive to the value after the subtraction sign, in a way that I don’t really expect. I could see some slight variation due to the hours being calculated over a different window but not - say - a 10% variation in the final value.

Thank you for the link however I do not see your actual query. I too am having a problem with the y-axis showing Gbps when the total sum of the interfaces should be Mbps. I cannot seem to get the correct total. I have 16 cable modem downstream channels which I can graph, but when I try to total them with this:

SELECT non_negative_derivative(sum(“ifHCInOctets”), 1s) FROM “cmts” WHERE (“hostname” =~ /^CMTS/ and “ifAlias” =~ /^FiberNode/ and “ifType”=‘205’ or “hostname” =~ /^CMTS/ and “ifAlias” =~ /^FiberNode/ and “ifType”=‘278’) AND $timeFilter GROUP BY time(5m) fill(ll)

The total is incorrect. Any help would be greatly appreciated.

hi, did you solve this issue? Because I have the same problem, the total is incorrect. Thanks

No, I haven’t received any advice yet. Very weird that the individual channels are correct but the sum never works.

bad news :slightly_frowning_face:

Crickets all around. Bizarre that nobody can figure this out, yet it’s a perfect use case to show th power of these tools.

Here are my attempts https://www.reddit.com/r/grafana/comments/j4q3tk/bandwidth_usage_graph