Grafana: Graph - Noise Range: Unterschied zwischen den Versionen

Aus Wiki-WebPerfect
Wechseln zu: Navigation, Suche
Zeile 1: Zeile 1:
If you want a Grafana Graph that shows the average CPU usage as a line but also the min and max value as a area in the background, then following this site. <br>
+
If you want a Grafana Graph that shows the '''average CPU usage''' as a line but also the '''min''' and '''max''' value as a area in the background for example like the image below, then following this site. <br>
 
[[Datei:01-noise range.png|1200px]] <br>
 
[[Datei:01-noise range.png|1200px]] <br>
  
 +
== Example Flux Query ==
 +
The image above is from the following Flux query:
 +
<pre>
 +
//define variables
 +
bucket = "telegraf"
  
 +
data = from(bucket: bucket)
 +
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
 +
  |> filter(fn: (r) =>
 +
    r._measurement == "hyperv_logical_processor" and
 +
    r._field == "Percent_Total_Run_Time"
 +
  )
 +
  |> group(columns: ["instance"])
  
  
 +
mean = data
 +
  |> aggregateWindow(every: 10m, fn: mean, createEmpty: false)
 +
  |> set(key: "_field", value: "mean")
 +
 +
min = data
 +
  |> aggregateWindow(every: 10m, fn: min, createEmpty: false)
 +
  |> set(key: "_field", value: "min")
 +
 +
max = data
 +
  |> aggregateWindow(every: 10m, fn: max, createEmpty: false)
 +
  |> set(key: "_field", value: "max")
 +
 +
union(tables: [mean, min, max])
 +
  |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
 +
  |> keep(columns: ["_time", "instance", "mean", "min", "max"])
 +
</pre>
  
  

Version vom 16. September 2021, 13:25 Uhr

If you want a Grafana Graph that shows the average CPU usage as a line but also the min and max value as a area in the background for example like the image below, then following this site.
01-noise range.png

Example Flux Query

The image above is from the following Flux query:

//define variables
bucket = "telegraf"

data = from(bucket: bucket)
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => 
    r._measurement == "hyperv_logical_processor" and
    r._field == "Percent_Total_Run_Time"
  )
  |> group(columns: ["instance"])


mean = data
  |> aggregateWindow(every: 10m, fn: mean, createEmpty: false)
  |> set(key: "_field", value: "mean") 

min = data
  |> aggregateWindow(every: 10m, fn: min, createEmpty: false)
  |> set(key: "_field", value: "min") 

max = data
  |> aggregateWindow(every: 10m, fn: max, createEmpty: false)
  |> set(key: "_field", value: "max") 

union(tables: [mean, min, max]) 
  |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
  |> keep(columns: ["_time", "instance", "mean", "min", "max"])