Dashboards Setup
Variables
Get the value from a tag
> show tag values from "snapdb" with key="db"
Get the value from a field
> select DISTINCT("vmname") from (select "ready_summation","vmname" from "vsphere_vm_cpu")
Query Syntax
InfluxDB v2 with InfluxQL
SELECT * FROM cpu WHERE time >= $__timeFrom AND time <= $__timeTo
SELECT * FROM cpu WHERE $__timeFilter(time)
SELECT $__dateBin(time) from cpu
InfluxDB v2 with Flux
Time Series: vSphere Cluster CPU Usage
from(bucket: v.defaultBucket)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "vsphere_host_cpu")
|> filter(fn: (r) => r["_field"] == "usage_average")
|> filter(fn: (r) => r["cpu"] == "instance-total")
|> filter(fn: (r) => r["clustername"] =~ /${clustername:regex}/)
|> group(columns: ["clustername"])
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: "mean")
Gauge: vSphere Datastore Status
from(bucket: v.defaultBucket)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "vsphere_datastore_disk")
|> filter(fn: (r) => r["_field"] == "capacity_latest" or r["_field"] == "used_latest")
|> filter(fn: (r) => r["source"] =~ /${datastore:regex}/)
|> group()
|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
|> map(fn: (r) => ({ r with _value: float(v: r.used_latest) / float(v: r.capacity_latest) * 100.0 }))
|> group(columns: ["source","_field"])
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
Bar gauge: vSphere Datastore Usage Capacity
from(bucket: v.defaultBucket)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "vsphere_datastore_disk")
|> filter(fn: (r) => r["_field"] == "capacity_latest" or r["_field"] == "used_latest")
|> filter(fn: (r) => r["source"] =~ /${datastore:regex}/)
|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
|> map(fn: (r) => ({ r with _value: float(v: r.used_latest) / float(v: r.capacity_latest) * 100.0 }))
|> group(columns: ["source","_field"])
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
Stat: Uptime
from(bucket: v.defaultBucket)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "vsphere_host_sys")
|> filter(fn: (r) => r["_field"] == "uptime_latest")
|> filter(fn: (r) => r["vcenter"] =~ /${vcenter:regex}/)
|> filter(fn: (r) => r["clustername"] =~ /${clustername:regex}/)
|> group(columns: ["clustername"])
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: "mean")