Windows performance counters and search for disk instance(s)

Dear.
How to filter instances of disks of selected host in flux? For “host1” i want to recieve C: and D: for “host2” i want C: and E: etc.

For now i can find all available disks instances across all hosts:

import “influxdata/influxdb/schema”
import “strings”
schema.measurementTagValues(bucket: “bucket_name”, measurement: “win_disk”, tag: “instance”)
|> filter(fn: (r) => strings.containsStr(v: r._value, substr: “:”))

returns C: D: E: F: G:

I want to have variable(drop down list) in Grafana

Hello @Peter_Bielik,
Im not a grafana expert…but I think the process looks like this:
To create a variable (dropdown list) in Grafana that filters disk instances based on the selected host, you can follow these steps:

  1. Add a variable in Grafana:a. Go to the dashboard settings (click the gear icon in the top-right corner).b. Go to the “Variables” section and click on “Add variable”.c. Configure the variable settings:
  • Name: Choose a name for the variable, e.g., host.
  • Type: Query.
  • Data Source: Select your InfluxDB data source.
  • Query: Write a query to retrieve the host values. For instance:

phpCopy code

import "influxdata/influxdb/schema"
schema.tagValues(bucket: "bucket_name", tag: "host")
```d. Save the variable.

Hi. Thanks for answer. No, it is not /yet/ about Grafana - there i have a couple of variables to select influx buckets and other data and it is functional.

I have 100+ windows hosts with different amount od disks. Using standard telegraf config [[inputs.win_perf_counters]] and i am recieving data. All is working nice in buckets and also in grafana

My Grafana dashboard is copy of nice work from

but it is based on influxQL and this will work most probably:
SHOW TAG VALUES FROM "win_disk" WITH KEY = "instance" WHERE host =~ /$hostname/"

i just need to have it in influx not in InfluxQL.

On the end it is about dynamicaly creating rows and panels in grafana - different hosts should have different amout of rows and panels based on correct disk instances. As writen above for “host1” i want to recieve C: and D:, for “host2” i want C: and E: etc… host2 doesnt have D:…

with import “influxdata/influxdb/schema”… i can find all possible disks letters but i need to filter them based on hostname

This will create variable Disk in Grafana
import “influxdata/influxdb/schema”
import “strings”

schema.tagValues(bucket: “${bucket}”, tag: “instance”, predicate: (r) => r.host == “${host}”)
|> filter(fn: (r) => strings.strlen(v: r._value) <= 2)
|> filter(fn: (r) => strings.containsStr(v: r._value, substr: “:”))

and then use:

from(bucket: “${bucket}”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “win_disk”)
|> filter(fn: (r) => r[“_field”] == “Percent_Free_Space”)
|> filter(fn: (r) => r[“host”] == “${host}”)
|> filter(fn: (r) => r[“instance”] == “${Disk}”)
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: “mean”)