From dfa7bea77e23b0d4d3bd37bf462105f42d9a4334 Mon Sep 17 00:00:00 2001 From: Bucky Schwarz Date: Fri, 11 Sep 2020 09:51:12 -0700 Subject: [PATCH 1/4] sure --- linux_system/linux_system.yml | 81 ++++++++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 15 deletions(-) diff --git a/linux_system/linux_system.yml b/linux_system/linux_system.yml index f52151eb..616dbb71 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,7 +425,11 @@ 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") @@ -449,7 +456,11 @@ 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") @@ -474,7 +485,11 @@ 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") @@ -492,7 +507,11 @@ 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") @@ -519,7 +538,11 @@ 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") @@ -546,7 +569,11 @@ 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") @@ -567,7 +594,11 @@ 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") @@ -593,7 +624,11 @@ 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") @@ -618,7 +653,11 @@ 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") @@ -637,12 +676,16 @@ 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,7 +721,11 @@ 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") @@ -704,7 +751,11 @@ 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") From 5ceda8c974b52c4bc0b95e5b22f427715fdfa70c Mon Sep 17 00:00:00 2001 From: Bucky Schwarz Date: Fri, 11 Sep 2020 10:40:13 -0700 Subject: [PATCH 2/4] change back to v.bucket as default --- linux_system/linux_system.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/linux_system/linux_system.yml b/linux_system/linux_system.yml index 616dbb71..a9e96b21 100644 --- a/linux_system/linux_system.yml +++ b/linux_system/linux_system.yml @@ -125,7 +125,7 @@ spec: language: flux query: |- option params = { - bucket: "telegraf" + bucket: "v.bucket" } import "influxdata/influxdb/v1" v1.measurementTagValues(bucket: params.bucket, measurement: "cpu", tag: "host") @@ -426,7 +426,7 @@ spec: queries: - query: |- option params = { - bucket: "telegraf" + bucket: "v.bucket" } from(bucket: params.bucket) @@ -457,7 +457,7 @@ spec: queries: - query: |- option params = { - bucket: "telegraf" + bucket: "v.bucket" } from(bucket: params.bucket) @@ -486,7 +486,7 @@ spec: queries: - query: |- option params = { - bucket: "telegraf" + bucket: "v.bucket" } from(bucket: params.bucket) @@ -508,7 +508,7 @@ spec: queries: - query: |- option params = { - bucket: "telegraf" + bucket: "v.bucket" } from(bucket: params.bucket) @@ -539,7 +539,7 @@ spec: queries: - query: |- option params = { - bucket: "telegraf" + bucket: "v.bucket" } from(bucket: params.bucket) @@ -570,7 +570,7 @@ spec: queries: - query: |- option params = { - bucket: "telegraf" + bucket: "v.bucket" } from(bucket: params.bucket) @@ -595,7 +595,7 @@ spec: queries: - query: |- option params = { - bucket: "telegraf" + bucket: "v.bucket" } from(bucket: params.bucket) @@ -625,7 +625,7 @@ spec: queries: - query: |- option params = { - bucket: "telegraf" + bucket: "v.bucket" } from(bucket: params.bucket) @@ -654,7 +654,7 @@ spec: queries: - query: |- option params = { - bucket: "telegraf" + bucket: "v.bucket" } from(bucket: params.bucket) @@ -677,7 +677,7 @@ spec: queries: - query: |- option params = { - bucket: "telegraf" + bucket: "v.bucket" } from(bucket: params.bucket) @@ -722,7 +722,7 @@ spec: queries: - query: |- option params = { - bucket: "telegraf" + bucket: "v.bucket" } from(bucket: params.bucket) @@ -752,7 +752,7 @@ spec: queries: - query: |- option params = { - bucket: "telegraf" + bucket: "v.bucket" } from(bucket: params.bucket) From 30bdb4e873c4dc400c6822ec99351b537b25dec7 Mon Sep 17 00:00:00 2001 From: Bucky Schwarz Date: Fri, 11 Sep 2020 11:00:20 -0700 Subject: [PATCH 3/4] add params section --- linux_system/linux_system.yml | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/linux_system/linux_system.yml b/linux_system/linux_system.yml index a9e96b21..da0e0fb7 100644 --- a/linux_system/linux_system.yml +++ b/linux_system/linux_system.yml @@ -129,6 +129,10 @@ spec: } import "influxdata/influxdb/v1" v1.measurementTagValues(bucket: params.bucket, measurement: "cpu", tag: "host") + params: + - key: bucket + default: "v.bucket" + type: string type: query --- apiVersion: influxdata.com/v2alpha1 @@ -436,6 +440,10 @@ spec: |> filter(fn: (r) => r.host == v.linux_host) |> last() |> map(fn: (r) => ({ _value: float(v: r._value) / 86400.00 })) + params: + - key: bucket + default: "v.bucket" + type: string suffix: ' days' width: 3 yPos: 1 @@ -466,6 +474,10 @@ spec: |> filter(fn: (r) => r._field == "used_percent") |> filter(fn: (r) => r.host == v.linux_host) |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false) + params: + - key: bucket + default: "v.bucket" + type: string width: 3 yPos: 2 - axes: @@ -495,6 +507,10 @@ spec: |> 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) + params: + - key: bucket + default: "v.bucket" + type: string width: 3 yPos: 5 - colors: @@ -517,6 +533,10 @@ spec: |> filter(fn: (r) => r._field == "n_cpus") |> filter(fn: (r) => r.host == v.linux_host) |> last() + params: + - key: bucket + default: "v.bucket" + type: string suffix: ' cpus' width: 2 xPos: 3 @@ -549,6 +569,10 @@ spec: |> filter(fn: (r) => r.cpu == "cpu-total") |> filter(fn: (r) => r.host == v.linux_host) |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false) + params: + - key: bucket + default: "v.bucket" + type: string width: 3 xPos: 3 yPos: 2 @@ -579,6 +603,10 @@ spec: |> 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) + params: + - key: bucket + default: "v.bucket" + type: string width: 3 xCol: _time xPos: 3 @@ -604,6 +632,10 @@ spec: |> filter(fn: (r) => r._field == "load1") |> filter(fn: (r) => r.host == v.linux_host) |> last() + params: + - key: bucket + default: "v.bucket" + type: string width: 2 xPos: 5 yPos: 1 @@ -634,6 +666,10 @@ spec: |> 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) + params: + - key: bucket + default: "v.bucket" + type: string width: 3 xPos: 6 yPos: 2 @@ -663,6 +699,10 @@ spec: |> 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) + params: + - key: bucket + default: "v.bucket" + type: string width: 3 xPos: 6 yPos: 5 @@ -687,6 +727,10 @@ spec: |> filter(fn: (r) => r.host == v.linux_host) |> last() |> map(fn: (r) => ({r with _value: float(v: r._value) / 1024.0 / 1024.0 / 1024.0})) + params: + - key: bucket + default: "v.bucket" + type: string suffix: ' GB' width: 2 xPos: 7 @@ -731,6 +775,10 @@ spec: |> filter(fn: (r) => r._field == "used_percent") |> filter(fn: (r) => r.host == v.linux_host) |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false) + params: + - key: bucket + default: "v.bucket" + type: string suffix: '%' width: 3 xPos: 9 @@ -761,6 +809,14 @@ spec: |> 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) + params: + - key: bucket + default: "v.bucket" + type: string + params: + - key: bucket + default: "v.bucket" + type: string width: 3 xPos: 9 yPos: 5 From 6b12d358478ce5b19c856ce8134d155347516c77 Mon Sep 17 00:00:00 2001 From: Bucky Schwarz Date: Fri, 11 Sep 2020 11:14:39 -0700 Subject: [PATCH 4/4] removed linux system host, changed to telegraf bucket --- linux_system/linux_system.yml | 94 +++++------------------------------ 1 file changed, 13 insertions(+), 81 deletions(-) diff --git a/linux_system/linux_system.yml b/linux_system/linux_system.yml index da0e0fb7..dbd33dc4 100644 --- a/linux_system/linux_system.yml +++ b/linux_system/linux_system.yml @@ -125,14 +125,10 @@ spec: language: flux query: |- option params = { - bucket: "v.bucket" + bucket: "telegraf" } import "influxdata/influxdb/v1" v1.measurementTagValues(bucket: params.bucket, measurement: "cpu", tag: "host") - params: - - key: bucket - default: "v.bucket" - type: string type: query --- apiVersion: influxdata.com/v2alpha1 @@ -430,20 +426,15 @@ spec: queries: - query: |- option params = { - bucket: "v.bucket" + 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 })) - params: - - key: bucket - default: "v.bucket" - type: string suffix: ' days' width: 3 yPos: 1 @@ -465,19 +456,14 @@ spec: queries: - query: |- option params = { - bucket: "v.bucket" + 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) - params: - - key: bucket - default: "v.bucket" - type: string width: 3 yPos: 2 - axes: @@ -498,19 +484,14 @@ spec: queries: - query: |- option params = { - bucket: "v.bucket" + 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) - params: - - key: bucket - default: "v.bucket" - type: string width: 3 yPos: 5 - colors: @@ -524,19 +505,14 @@ spec: queries: - query: |- option params = { - bucket: "v.bucket" + 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() - params: - - key: bucket - default: "v.bucket" - type: string suffix: ' cpus' width: 2 xPos: 3 @@ -559,7 +535,7 @@ spec: queries: - query: |- option params = { - bucket: "v.bucket" + bucket: "telegraf" } from(bucket: params.bucket) @@ -567,12 +543,7 @@ spec: |> 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) - params: - - key: bucket - default: "v.bucket" - type: string width: 3 xPos: 3 yPos: 2 @@ -594,19 +565,14 @@ spec: queries: - query: |- option params = { - bucket: "v.bucket" + 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) - params: - - key: bucket - default: "v.bucket" - type: string width: 3 xCol: _time xPos: 3 @@ -623,19 +589,14 @@ spec: queries: - query: |- option params = { - bucket: "v.bucket" + 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() - params: - - key: bucket - default: "v.bucket" - type: string width: 2 xPos: 5 yPos: 1 @@ -657,19 +618,14 @@ spec: queries: - query: |- option params = { - bucket: "v.bucket" + 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) - params: - - key: bucket - default: "v.bucket" - type: string width: 3 xPos: 6 yPos: 2 @@ -690,19 +646,14 @@ spec: queries: - query: |- option params = { - bucket: "v.bucket" + 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) - params: - - key: bucket - default: "v.bucket" - type: string width: 3 xPos: 6 yPos: 5 @@ -717,20 +668,15 @@ spec: queries: - query: |- option params = { - bucket: "v.bucket" + bucket: "telegraf" } from(bucket: params.bucket) |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "mem") |> filter(fn: (r) => r._field == "total") - |> filter(fn: (r) => r.host == v.linux_host) |> last() |> map(fn: (r) => ({r with _value: float(v: r._value) / 1024.0 / 1024.0 / 1024.0})) - params: - - key: bucket - default: "v.bucket" - type: string suffix: ' GB' width: 2 xPos: 7 @@ -766,19 +712,14 @@ spec: queries: - query: |- option params = { - bucket: "v.bucket" + 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) - params: - - key: bucket - default: "v.bucket" - type: string suffix: '%' width: 3 xPos: 9 @@ -800,23 +741,14 @@ spec: queries: - query: |- option params = { - bucket: "v.bucket" + 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) - params: - - key: bucket - default: "v.bucket" - type: string - params: - - key: bucket - default: "v.bucket" - type: string width: 3 xPos: 9 yPos: 5