Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterize linux_system template #184

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 66 additions & 27 deletions linux_system/linux_system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down