nzaca
October 4, 2023, 6:15pm
1
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?
nzaca
October 5, 2023, 6:16am
3
yes, but I can not figure it what is the error
what do you see when you hover over that icon or open that variable and see if it shows you the error.
Can you run the query in Explore and get returns?
nzaca
October 6, 2023, 6:44am
6
hi yosiasz
here what it says when i go over the icon
nzaca
October 6, 2023, 7:29am
7
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
nzaca
October 6, 2023, 7:32am
8
this should be
|> filter(fn: (r) => r[“esxhostname”] == “${esxi}”)
then dependency are ok
but still last variable for interfaces doesn’t return values
nzaca:
${esxhostname
Are you sure that is the proper variable name?
nzaca
October 6, 2023, 12:46pm
10
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”)
yosiasz
October 6, 2023, 12:51pm
11
We cant your screen to see the crazy stuff
nzaca
October 6, 2023, 1:00pm
12
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
nzaca
October 6, 2023, 2:04pm
14
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
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”)
nzaca
October 6, 2023, 4:47pm
16
yes because I have variables
are the variables used to filter other variables or to be used in the query?
nzaca
October 7, 2023, 5:47am
18
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
nzaca
October 9, 2023, 1:36pm
20
how to put other variables in last query?.