Grafana , vsphere, network

Hello ,

hope you are all well .

I use Grafana 9 , Telegraf and InfluxDB v2.0 to collect matric from vsphere environment.
End is work fine but I have en issues to create variables for network interface - vmnic .
I create several variables.

First variables is for vcenter :

from(bucket: v.defaultBucket)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “vsphere_host_cpu”)
|> keep(columns: [“vcenter”])
|> distinct(column: “vcenter”)
|> group()

Second variables for cluster :

from(bucket: v.defaultBucket)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “vsphere_host_cpu”)
|> filter(fn: (r) => r[“vcenter”] == “${vcenter}”)
|> keep(columns: [“clustername”])
|> distinct(column: “clustername”)
|> group()

third variables for esxi host
from(bucket: v.defaultBucket)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “vsphere_host_net”)
|> filter(fn: (r) => r[“clustername”] == “${clustername}”)
|> keep(columns: [“esxhostname”])
|> distinct(column: “esxhostname”)
|> group()

and 4th variables for vmnic .

from(bucket: v.defaultBucket)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “vsphere_host_net”)
|> filter(fn: (r) => r[“esxhostname”] == “${esxhostname}”)
|> keep(columns: [“interface”])
|> distinct(column: “interface”)
|> group()

My Issues is that last variable is not working , It not return any interface , but when I try same query in script editor on Influxd I get result , return all vmnics
|> keep(columns: [“interface”])
|> distinct(column: “interface”)
|> group()

I can’t seem to connect it properly .Does any had similar issues ?

it seems like there might be an error on it?
image

yes, but I can not figure it what is the error

what do you see when you hover over that icon :warning: or open that variable and see if it shows you the error.

Can you run the query in Explore and get returns?

hi yosiasz
here what it says when i go over the icon
image

hi jasonmallory,

I try that , but query is a little bit different ,because in query I set value for vcenter ,cluster and esxi host.
So it’s look like this

this should be

|> filter(fn: (r) => r[“esxhostname”] == “${esxi}”)

then dependency are ok

but still last variable for interfaces doesn’t return values

Are you sure that is the proper variable name?

no , it should be |> filter(fn: (r) => r[“esxhostname”] == “${esxi}”)

now in variable I have to choose vmnic , but in graph query return some crazy values ,

from(bucket: v.defaultBucket)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “vsphere_host_net”)
|> filter(fn: (r) => r[“_field”] == “bytesRx_average”)
|> filter(fn: (r) => r[“esxhostname”] =~ /${esxi:regex}/)
|> group(columns: [“_field”])
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: “mean”)

We cant your screen to see the crazy stuff :laughing:

vmnic is off, so there should be no traffic, it should return zero

what happens if you ran the same identical query on influxdb itself now that you have corrected the $esxi parameter

the query looks a little different. I manually set the values in the query
which I have variables in graphana

from(bucket: “vmware”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“vcenter”] == “my vCSA”)
|> filter(fn: (r) => r[“clustername”] == “MyCluster”)
|> filter(fn: (r) => r[“esxhostname”] == “myHost”)
|> filter(fn: (r) => r[“_measurement”] == “vsphere_host_net”)
|> filter(fn: (r) => r[“_field”] == “bytesRx_average”)
|> filter(fn: (r) => r[“interface”] == “vmnic0”)
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: “mean”)

it actually looks very different from your query in grafana

image

these exists in your grafana query

|> filter(fn: (r) => r[“_measurement”] == “vsphere_host_net”)
|> filter(fn: (r) => r[“_field”] == “bytesRx_average”)
|> filter(fn: (r) => r[“esxhostname”] == “myHost”)

These do not

|> filter(fn: (r) => r[“vcenter”] == “my vCSA”)
|> filter(fn: (r) => r[“clustername”] == “MyCluster”)
|> filter(fn: (r) => r[“interface”] == “vmnic0”)

yes because I have variables

are the variables used to filter other variables or to be used in the query?

Filter for other variables. look at my first post . First variable is for vcenter, second for cluster ,…

But you dont use a lot of those: center, cluster, interface in your final query hence the issue you are seeing. I believe it is working as intended unless you put the other variables in the last query

how to put other variables in last query?.