This commit is contained in:
mwiegand 2021-07-04 22:55:43 +02:00
parent 9ed91592f8
commit 7eff2aa76e
9 changed files with 58 additions and 20 deletions

View file

@ -112,10 +112,17 @@ for dashboard_id, monitored_node in enumerate(monitored_nodes, start=1):
if 'display_name' in panel_config:
panel['fieldConfig']['defaults']['displayName'] = '${'+panel_config['display_name']+'}'
if panel_config.get('stacked', False):
if panel_config.get('stacked'):
panel['fieldConfig']['defaults']['custom']['stacking']['mode'] = 'normal'
else:
panel['fieldConfig']['defaults']['custom']['stacking']['mode'] = 'none'
if 'unit' in panel_config:
panel['fieldConfig']['defaults']['unit'] = panel_config['unit']
if 'min' in panel_config:
panel['fieldConfig']['defaults']['min'] = panel_config['min']
if 'max' in panel_config:
panel['fieldConfig']['defaults']['max'] = panel_config['max']
for query_name, query_config in panel_config['queries'].items():
panel['targets'].append({
@ -123,6 +130,7 @@ for dashboard_id, monitored_node in enumerate(monitored_nodes, start=1):
'query': flux_template.render(
bucket=bucket,
host=monitored_node.name,
negative=query_config.get('negative', False),
filters={
'host': monitored_node.name,
**query_config['filters'],

View file

@ -1,7 +1,7 @@
from tomlkit import dumps
files['/etc/telegraf/telegraf.conf'] = {
'content': dumps(node.metadata.get('telegraf/config')),
'content': dumps(node.metadata.get('telegraf/config'), sort_keys=True),
'triggers': [
'svc_systemd:telegraf:restart',
],

View file

@ -44,12 +44,14 @@ defaults = {
'processes': [{}],
'swap': [{}],
'system': [{}],
'net': [{}],
},
},
},
'grafana_rows': [
'cpu',
'disk_io',
'net_io',
],
}

View file

@ -8,5 +8,8 @@ from(bucket: "${bucket}")
|> derivative()
% else:
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
% endif
% if negative:
|> map(fn: (r) => ({r with _value: r._value * - 1.0}))
% endif
|> yield(name: "mean")

View file

@ -23,10 +23,9 @@
'showPoints': 'never',
'pointSize': 5,
'stacking': {
'mode': 'normal',
'mode': 'none',
'group': 'A'
},
# 'axisPlacement': 'hidden',
'axisLabel': '',
'scaleDistribution': {
'type': 'linear'
@ -46,22 +45,8 @@
'color': {
'mode': 'palette-classic',
},
'thresholds': {
'mode': 'percentage',
'steps': [
{
'color': 'green',
'value': None,
},
{
'color': 'dark-red',
'value': 80,
},
],
},
'mappings': [],
'displayName': '${__field.name}',
'unit': 'percent',
},
'overrides': [],
},

View file

@ -15,6 +15,8 @@
'function': 'mean',
},
},
'min': 0,
'max': 100,
},
'load': {
'stacked': False,

View file

@ -12,6 +12,7 @@
'function': 'derivative',
},
},
'unit': 'decbytes',
'display_name': '__field.labels.name'
},
'write': {
@ -27,6 +28,7 @@
'function': 'derivative',
},
},
'unit': 'decbytes',
'display_name': '__field.labels.name'
},
}

View file

@ -0,0 +1,34 @@
{
'in': {
'stacked': True,
'queries': {
'in': {
'filters': {
'_measurement': 'net',
'_field': [
'bytes_recv',
],
},
'function': 'derivative',
},
},
'unit': 'decbytes',
'display_name': '__field.labels.interface'
},
'out': {
'stacked': True,
'queries': {
'out': {
'filters': {
'_measurement': 'net',
'_field': [
'bytes_sent',
],
},
'function': 'derivative',
},
},
'unit': 'decbytes',
'display_name': '__field.labels.interface'
},
}

View file

@ -1,3 +1,5 @@
from ipaddress import ip_interface
def get_a_records(metadata):
return {
'A': [