diff --git a/linux_system/linux_system.yml b/linux_system/linux_system.yml index f52151eb..dbd33dc4 100644 --- a/linux_system/linux_system.yml +++ b/linux_system/linux_system.yml @@ -124,8 +124,11 @@ spec: name: linux-system-template language: flux query: |- + option params = { + bucket: "telegraf" + } import "influxdata/influxdb/v1" - v1.measurementTagValues(bucket: v.bucket, measurement: "cpu", tag: "host") + v1.measurementTagValues(bucket: params.bucket, measurement: "cpu", tag: "host") type: query --- apiVersion: influxdata.com/v2alpha1 @@ -422,11 +425,14 @@ spec: name: System Uptime queries: - query: |- - from(bucket: v.bucket) + option params = { + bucket: "telegraf" + } + + from(bucket: params.bucket) |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "system") |> filter(fn: (r) => r._field == "uptime") - |> filter(fn: (r) => r.host == v.linux_host) |> last() |> map(fn: (r) => ({ _value: float(v: r._value) / 86400.00 })) suffix: ' days' @@ -449,11 +455,14 @@ spec: name: Disk Usage queries: - query: |- - from(bucket: v.bucket) + option params = { + bucket: "telegraf" + } + + from(bucket: params.bucket) |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "disk") |> filter(fn: (r) => r._field == "used_percent") - |> filter(fn: (r) => r.host == v.linux_host) |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false) width: 3 yPos: 2 @@ -474,11 +483,14 @@ spec: name: Disk IO queries: - query: |- - from(bucket: v.bucket) + option params = { + bucket: "telegraf" + } + + from(bucket: params.bucket) |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "diskio") |> filter(fn: (r) => r._field == "read_bytes" or r._field == "write_bytes") - |> filter(fn: (r) => r.host == v.linux_host) |> derivative(unit: v.windowPeriod, nonNegative: false) width: 3 yPos: 5 @@ -492,11 +504,14 @@ spec: name: nCPUs queries: - query: |- - from(bucket: v.bucket) + option params = { + bucket: "telegraf" + } + + from(bucket: params.bucket) |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "system") |> filter(fn: (r) => r._field == "n_cpus") - |> filter(fn: (r) => r.host == v.linux_host) |> last() suffix: ' cpus' width: 2 @@ -519,12 +534,15 @@ spec: name: CPU Usage queries: - query: |- - from(bucket: v.bucket) + option params = { + bucket: "telegraf" + } + + from(bucket: params.bucket) |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "cpu") |> filter(fn: (r) => r._field == "usage_user" or r._field == "usage_system" or r._field == "usage_idle") |> filter(fn: (r) => r.cpu == "cpu-total") - |> filter(fn: (r) => r.host == v.linux_host) |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false) width: 3 xPos: 3 @@ -546,11 +564,14 @@ spec: name: Network queries: - query: |- - from(bucket: v.bucket) + option params = { + bucket: "telegraf" + } + + from(bucket: params.bucket) |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "net") |> filter(fn: (r) => r._field == "bytes_recv" or r._field == "bytes_sent") - |> filter(fn: (r) => r.host == v.linux_host) |> derivative(unit: v.windowPeriod, nonNegative: false) width: 3 xCol: _time @@ -567,11 +588,14 @@ spec: name: System Load queries: - query: |- - from(bucket: v.bucket) + option params = { + bucket: "telegraf" + } + + from(bucket: params.bucket) |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "system") |> filter(fn: (r) => r._field == "load1") - |> filter(fn: (r) => r.host == v.linux_host) |> last() width: 2 xPos: 5 @@ -593,11 +617,14 @@ spec: name: System Load queries: - query: |- - from(bucket: v.bucket) + option params = { + bucket: "telegraf" + } + + from(bucket: params.bucket) |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "system") |> filter(fn: (r) => r._field == "load1" or r._field == "load5" or r._field == "load15") - |> filter(fn: (r) => r.host == v.linux_host) |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false) width: 3 xPos: 6 @@ -618,11 +645,14 @@ spec: name: Processes queries: - query: |- - from(bucket: v.bucket) + option params = { + bucket: "telegraf" + } + + from(bucket: params.bucket) |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "processes") |> filter(fn: (r) => r._field == "running" or r._field == "blocked" or r._field == "idle" or r._field == "unknown") - |> filter(fn: (r) => r.host == v.linux_host) |> aggregateWindow(every: v.windowPeriod, fn: max) width: 3 xPos: 6 @@ -637,12 +667,15 @@ spec: name: Total Memory queries: - query: |- - from(bucket: v.bucket) + option params = { + bucket: "telegraf" + } + + from(bucket: params.bucket) |> range(start: v.timeRangeStart, stop: v.timeRangeStop) - |> filter(fn: (r) => r._measurement == "mem") + |> filter(fn: (r) => r._measurement == "mem") |> filter(fn: (r) => r._field == "total") - |> filter(fn: (r) => r.host == v.linux_host) - |> last() + |> last() |> map(fn: (r) => ({r with _value: float(v: r._value) / 1024.0 / 1024.0 / 1024.0})) suffix: ' GB' width: 2 @@ -678,11 +711,14 @@ spec: name: Memory Usage queries: - query: |- - from(bucket: v.bucket) + option params = { + bucket: "telegraf" + } + + from(bucket: params.bucket) |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "mem") |> filter(fn: (r) => r._field == "used_percent") - |> filter(fn: (r) => r.host == v.linux_host) |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false) suffix: '%' width: 3 @@ -704,11 +740,14 @@ spec: name: Swap queries: - query: |- - from(bucket: v.bucket) + option params = { + bucket: "telegraf" + } + + from(bucket: params.bucket) |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "swap") |> filter(fn: (r) => r._field == "total" or r._field == "used") - |> filter(fn: (r) => r.host == v.linux_host) |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false) width: 3 xPos: 9