Network metrics with Flux language (Proxmox + InfluxDB + Grafana)

Hi Guys!

Now I’m starting a classis setup for our metrics system. We’re using Proxmox hypervisors and from the 7 version Proxmox support metrics sender by officially. Mostly classic metrics typs are working fine, but I don’t know how can I showing actually network usages.

Proxmox send a “nics” measurement and it has got four sub-category:

  • netin (VM network)
  • netout (VM network)
  • receive (Physical server network)
  • transmit (Physical server network)

The main problem: this values are a continuously increase number, not like a CPU value which reflects the current state.

How can I create from these value a current state graph with Flux lanuage ?

Thank you for time!

@werdf02 Monotonically incrementing metrics like this are known as “counters.” They’re really common in Prometheus-style metrics. Essentially you need to use increase() to return only positive changes in the metrics (essentially accounts for counter resets) and then difference() to return the difference between subsequent points. The difference represents that actual network usage.

In the Data Explore, go ahead and use the Query Builder to select the metrics you want, but to customize the query further, you’ll need to switch over to the script builder. Your query will look something like this:

from(bucket: "example-bucket")
    |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
    |> filter(fn: (r) => r["_measurement"] == "nics")
    |> filter(fn: (r) => r["_field"] == "recieve")
    |> filter(fn: (r) => r["instance"] == "bond0")
    |> increase()
    |> difference()

There is information on working with Prometheus counters in the Flux documentation. Although it’s specific to Prometheus metics being ingested into InfluxDB, the principles still apply here.

Hello Scott! Really thank you for your detailed answer, it works well!
If I see correctly you’re the member of staff; I noticed now I forget cover up the important info from the image. Can you edit your original post where you replace bucket name another one ? And please delete my original image, I replaced it an another one!
Thank you for time!