Grafana: Pie Chart: Unterschied zwischen den Versionen
Aus Wiki-WebPerfect
Admin (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „''Following are two examples to make great '''Pie Chart with Grafana''' and '''InfluxDB Flux'''.'' == One Query -> multiple Pie slices (recommended) == ''Th…“) |
Admin (Diskussion | Beiträge) |
||
Zeile 3: | Zeile 3: | ||
== One Query -> multiple Pie slices (recommended) == | == One Query -> multiple Pie slices (recommended) == | ||
+ | [[Datei:01-grafana pie-chart.png|right]] | ||
''This works only with Grafana 8.x or higher!'' | ''This works only with Grafana 8.x or higher!'' | ||
=== InfluxDB Flux Query === | === InfluxDB Flux Query === | ||
''Create a Grafana Pie chart panel that shows the count of unique hosts per SLA. We named the SLA's (in Influx tag "sla") as precious metals for example "Gold".'' | ''Create a Grafana Pie chart panel that shows the count of unique hosts per SLA. We named the SLA's (in Influx tag "sla") as precious metals for example "Gold".'' | ||
− | |||
<pre> | <pre> |
Version vom 30. August 2021, 10:38 Uhr
Following are two examples to make great Pie Chart with Grafana and InfluxDB Flux.
One Query -> multiple Pie slices (recommended)
This works only with Grafana 8.x or higher!
InfluxDB Flux Query
Create a Grafana Pie chart panel that shows the count of unique hosts per SLA. We named the SLA's (in Influx tag "sla") as precious metals for example "Gold".
//define variables bucket = "<YOUR_BUCKET>" measurement = "<YOUR_MEASUREMENT>" field = "<YOUR_FIELD>" group = "<YOUR_GROUP/YOUR_SLICES>" //in this examples the from(bucket: bucket) |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == measurement and r._field == field ) |> last() |> group() |> unique(column: "host") |> group(columns: ["sla"]) |> count() |> rename(columns: {_value: ""}) //remove _value from Pie slice naming