diff --git a/bundles/grafana/items.py b/bundles/grafana/items.py index 3f41725..e336093 100644 --- a/bundles/grafana/items.py +++ b/bundles/grafana/items.py @@ -123,6 +123,8 @@ for dashboard_id, monitored_node in enumerate(monitored_nodes, start=1): if 'max' in panel_config: panel['fieldConfig']['defaults']['max'] = panel_config['max'] + if 'legend' in panel_config: + panel['options']['legend'].update(panel_config['legend']) for query_name, query_config in panel_config['queries'].items(): panel['targets'].append({ @@ -131,6 +133,7 @@ for dashboard_id, monitored_node in enumerate(monitored_nodes, start=1): bucket=bucket, host=monitored_node.name, negative=query_config.get('negative', False), + resolution=query_config.get('resolution', 1) * 4, filters={ 'host': monitored_node.name, **query_config['filters'], diff --git a/bundles/telegraf/metadata.py b/bundles/telegraf/metadata.py index e889926..126e870 100644 --- a/bundles/telegraf/metadata.py +++ b/bundles/telegraf/metadata.py @@ -14,7 +14,7 @@ defaults = { 'collection_jitter': '0s', 'flush_interval': '10s', 'flush_jitter': '0s', - 'interval': '10s', + 'interval': '15s', 'metric_batch_size': 1000, 'metric_buffer_limit': 10000, 'omit_hostname': False, @@ -38,6 +38,14 @@ defaults = { 'squashfs', ], }], + 'procstat': [{ + 'interval': '1m', + 'pattern': '.', + 'fieldpass': [ + 'cpu_usage', + 'memory_rss', + ], + }], 'diskio': [{}], 'kernel': [{}], 'mem': [{}], @@ -53,6 +61,8 @@ defaults = { 'mem', 'disk_io', 'net_io', + 'proc_cpu', + 'proc_ram', }, } diff --git a/data/grafana/flux.mako b/data/grafana/flux.mako index ae8766b..291577e 100644 --- a/data/grafana/flux.mako +++ b/data/grafana/flux.mako @@ -10,5 +10,5 @@ from(bucket: "${bucket}") % if negative: |> map(fn: (r) => ({r with _value: r._value * - 1.0})) % endif - |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false) + |> aggregateWindow(every: duration(v: int(v: v.windowPeriod)*${resolution}), fn: mean, createEmpty: false) |> yield(name: "mean") diff --git a/data/grafana/rows/proc_cpu.py b/data/grafana/rows/proc_cpu.py new file mode 100644 index 0000000..68ad7e7 --- /dev/null +++ b/data/grafana/rows/proc_cpu.py @@ -0,0 +1,26 @@ +{ + 'process_cpu': { + 'stacked': True, + 'queries': { + 'cpu': { + 'filters': { + '_measurement': 'procstat', + '_field': [ + 'cpu_usage', + ], + }, + 'resolution': 6, + }, + }, + 'unit': 'percent', + 'display_name': '__field.labels.process_name', + 'legend': { + 'displayMode': 'table', + 'placement': 'right', + 'calcs': [ + 'mean', + 'max', + ], + }, + }, +} diff --git a/data/grafana/rows/proc_ram.py b/data/grafana/rows/proc_ram.py new file mode 100644 index 0000000..7b79fd8 --- /dev/null +++ b/data/grafana/rows/proc_ram.py @@ -0,0 +1,26 @@ +{ + 'process_ram': { + 'stacked': True, + 'queries': { + 'ram': { + 'filters': { + '_measurement': 'procstat', + '_field': [ + 'memory_rss', + ], + }, + 'resolution': 6, + }, + }, + 'unit': 'bytes', + 'display_name': '__field.labels.process_name', + 'legend': { + 'displayMode': 'table', + 'placement': 'right', + 'calcs': [ + 'mean', + 'max', + ], + }, + }, +}