# Grafana , vsphere, network

**URL:** <https://community.grafana.com/t/grafana-vsphere-network/104917>\
**Category:** InfluxDB\
**Tags:** influxdb\
**Created:** [October 4, 2023, 6:15pm UTC](https://community.grafana.com/t/grafana-vsphere-network/104917 "2023-10-04T18:15:58Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![nzaca](https://avatars.discourse-cdn.com/v4/letter/n/a6a055/32.png) [@nzaca](https://community.grafana.com/u/nzaca)\
**Post date:** [October 4, 2023, 6:15pm UTC](https://community.grafana.com/t/grafana-vsphere-network/104917/1 "2023-10-04T18:15:58Z")

</div>

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()

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

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

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 ?

---

<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:** [October 4, 2023, 6:27pm UTC](https://community.grafana.com/t/grafana-vsphere-network/104917/2 "2023-10-04T18:27:39Z")

</div>

it seems like there might be an error on it?  
 ![image](https://us1.discourse-cdn.com/grafana/original/3X/5/f/5f93e4396adaa7953ec23d4cf06b7f4e92fef93c.png)

---

<div class="post-metadata">

**Author:** ![nzaca](https://avatars.discourse-cdn.com/v4/letter/n/a6a055/32.png) [@nzaca](https://community.grafana.com/u/nzaca)\
**Post date:** [October 5, 2023, 6:16am UTC](https://community.grafana.com/t/grafana-vsphere-network/104917/3 "2023-10-05T06:16:02Z")

</div>

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

---

<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:** [October 5, 2023, 4:17pm UTC](https://community.grafana.com/t/grafana-vsphere-network/104917/4 "2023-10-05T16:17:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jasonmallory](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jasonmallory/32/36686_2.png) [@jasonmallory](https://community.grafana.com/u/jasonmallory)\
**Post date:** [October 5, 2023, 5:10pm UTC](https://community.grafana.com/t/grafana-vsphere-network/104917/5 "2023-10-05T17:10:46Z")

</div>

Can you run the query in Explore and get returns?

---

<div class="post-metadata">

**Author:** ![nzaca](https://avatars.discourse-cdn.com/v4/letter/n/a6a055/32.png) [@nzaca](https://community.grafana.com/u/nzaca)\
**Post date:** [October 6, 2023, 6:44am UTC](https://community.grafana.com/t/grafana-vsphere-network/104917/6 "2023-10-06T06:44:29Z")

</div>

hi yosiasz  
here what it says when i go over the icon  
 ![image](https://us1.discourse-cdn.com/grafana/original/3X/0/3/03d504885843305b2bde99333dae45a141b59f3a.png)

---

<div class="post-metadata">

**Author:** ![nzaca](https://avatars.discourse-cdn.com/v4/letter/n/a6a055/32.png) [@nzaca](https://community.grafana.com/u/nzaca)\
**Post date:** [October 6, 2023, 7:29am UTC](https://community.grafana.com/t/grafana-vsphere-network/104917/7 "2023-10-06T07:29:24Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![nzaca](https://avatars.discourse-cdn.com/v4/letter/n/a6a055/32.png) [@nzaca](https://community.grafana.com/u/nzaca)\
**Post date:** [October 6, 2023, 7:32am UTC](https://community.grafana.com/t/grafana-vsphere-network/104917/8 "2023-10-06T07:32:59Z")

</div>

> [@nzaca](#):
>
> |\> filter(fn: (r) =\> r[“esxhostname”] == “${esxhostname}”)

this should be

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

then dependency are ok

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/0/5/0540fb75ce02f2e34e3502fec48fe7bd065efdd9.png)

but still last variable for interfaces doesn’t return values

---

<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:** [October 6, 2023, 11:51am UTC](https://community.grafana.com/t/grafana-vsphere-network/104917/9 "2023-10-06T11:51:03Z")

</div>

> [@nzaca](#):
>
> ${esxhostname

Are you sure that is the proper variable name?

---

<div class="post-metadata">

**Author:** ![nzaca](https://avatars.discourse-cdn.com/v4/letter/n/a6a055/32.png) [@nzaca](https://community.grafana.com/u/nzaca)\
**Post date:** [October 6, 2023, 12:46pm UTC](https://community.grafana.com/t/grafana-vsphere-network/104917/10 "2023-10-06T12:46:55Z")

</div>

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”)

---

<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:** [October 6, 2023, 12:51pm UTC](https://community.grafana.com/t/grafana-vsphere-network/104917/11 "2023-10-06T12:51:43Z")

</div>

> [@nzaca](#):
>
> but in graph query return some crazy values

We cant your screen to see the crazy stuff 😆

---

<div class="post-metadata">

**Author:** ![nzaca](https://avatars.discourse-cdn.com/v4/letter/n/a6a055/32.png) [@nzaca](https://community.grafana.com/u/nzaca)\
**Post date:** [October 6, 2023, 1:00pm UTC](https://community.grafana.com/t/grafana-vsphere-network/104917/12 "2023-10-06T13:00:38Z")

</div>

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

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

---

<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:** [October 6, 2023, 1:48pm UTC](https://community.grafana.com/t/grafana-vsphere-network/104917/13 "2023-10-06T13:48:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nzaca](https://avatars.discourse-cdn.com/v4/letter/n/a6a055/32.png) [@nzaca](https://community.grafana.com/u/nzaca)\
**Post date:** [October 6, 2023, 2:04pm UTC](https://community.grafana.com/t/grafana-vsphere-network/104917/14 "2023-10-06T14:04:54Z")

</div>

![image](https://us1.discourse-cdn.com/grafana/original/3X/4/6/468020f3cfa5979b7ac1ac87f77ec203dd4a092c.png)

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”)

---

<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:** [October 6, 2023, 2:18pm UTC](https://community.grafana.com/t/grafana-vsphere-network/104917/15 "2023-10-06T14:18:49Z")

</div>

it actually looks **very** different from your query in grafana

![image](https://us1.discourse-cdn.com/grafana/original/3X/4/e/4e2da31b883aa9ad568b7befab8443148d68cc65.png)

these exists in your grafana query

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

```

These do not

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

```

---

<div class="post-metadata">

**Author:** ![nzaca](https://avatars.discourse-cdn.com/v4/letter/n/a6a055/32.png) [@nzaca](https://community.grafana.com/u/nzaca)\
**Post date:** [October 6, 2023, 4:47pm UTC](https://community.grafana.com/t/grafana-vsphere-network/104917/16 "2023-10-06T16:47:59Z")

</div>

yes because I have variables

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

---

<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:** [October 6, 2023, 5:02pm UTC](https://community.grafana.com/t/grafana-vsphere-network/104917/17 "2023-10-06T17:02:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nzaca](https://avatars.discourse-cdn.com/v4/letter/n/a6a055/32.png) [@nzaca](https://community.grafana.com/u/nzaca)\
**Post date:** [October 7, 2023, 5:47am UTC](https://community.grafana.com/t/grafana-vsphere-network/104917/18 "2023-10-07T05:47:12Z")

</div>

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

---

<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:** [October 7, 2023, 6:25am UTC](https://community.grafana.com/t/grafana-vsphere-network/104917/19 "2023-10-07T06:25:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nzaca](https://avatars.discourse-cdn.com/v4/letter/n/a6a055/32.png) [@nzaca](https://community.grafana.com/u/nzaca)\
**Post date:** [October 9, 2023, 1:36pm UTC](https://community.grafana.com/t/grafana-vsphere-network/104917/20 "2023-10-09T13:36:09Z")

</div>

how to put other variables in last query?.

[Next page](https://community.grafana.com/t/grafana-vsphere-network/104917.md?page=2)
