def dashboard_row_cpu(panel_id, node): queries_cpu = [] queries_load = [] for measurement in [ 'user', 'system', 'steal', 'iowait', 'nice', 'softirq', 'guest', 'guest_nice', ]: queries_cpu.append({ 'groupBy': [ {'type': 'time', 'params': ['$__interval']}, {'type': 'fill', 'params': ['linear']}, ], 'orderByTime': "ASC", 'policy': "default", 'query': f"""from(bucket: "telegraf") |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r["_measurement"] == "cpu" and r["_field"] == "usage_{measurement}" and r["host"] == "{node.name}" ) |> map(fn: (r) => ({{ r with _field: "{measurement}" }}) ) |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false) |> yield(name: "{measurement}")""", 'resultFormat': 'time_series', 'select': [[ {'type': 'field', 'params': ['value']}, {'type': 'mean', 'params': []}, ]], "tags": [] }) for measurement in [ 'load1', 'load5', 'load15', ]: queries_load.append({ 'groupBy': [ {'type': 'time', 'params': ['$__interval']}, {'type': 'fill', 'params': ['linear']}, ], 'orderByTime': "ASC", 'policy': "default", 'query': f"""from(bucket: "telegraf") |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r["_measurement"] == "system" and r["_field"] == "{measurement}" and r["host"] == "{node.name}" ) |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false) |> yield(name: "{measurement}")""", 'resultFormat': 'time_series', 'select': [[ {'type': 'field', 'params': ['value']}, {'type': 'mean', 'params': []}, ]], "tags": [] }) return { 'title': 'cpu/load', 'collapse': False, 'editable': False, 'height': '250px', 'panels': [ { 'aliasColors': {}, 'bars': False, 'dashLength': 10, 'dashes': False, 'datasource': None, 'fieldConfig': { 'defaults': { 'displayName': '${__field.name}' }, 'overrides': [] }, 'fill': 10, 'fillGradient': 0, 'hiddenSeries': False, 'id': next(panel_id), 'legend': { 'alignAsTable': False, 'avg': False, 'current': False, 'max': False, 'min': False, 'rightSide': False, 'show': True, 'total': False, 'values': False }, 'lines': True, 'linewidth': 0, 'NonePointMode': 'None', 'options': { 'alertThreshold': True }, 'percentage': False, 'pluginVersion': '7.5.5', 'pointradius': 2, 'points': False, 'renderer': 'flot', 'seriesOverrides': [], 'spaceLength': 10, 'span': 6, 'stack': True, 'steppedLine': False, 'targets': queries_cpu, 'thresholds': [], 'timeRegions': [], 'title': 'cpu', 'tooltip': { 'shared': True, 'sort': 0, 'value_type': 'individual' }, 'type': 'graph', 'xaxis': { 'buckets': None, 'mode': 'time', 'name': None, 'show': True, 'values': [] }, 'yaxes': [ { 'format': 'percent', 'label': None, 'logBase': 1, 'max': 100, 'min': 0, 'show': True, }, { 'format': 'short', 'label': None, 'logBase': 1, 'max': None, 'min': None, 'show': False, } ], 'yaxis': { 'align': False, 'alignLevel': None } }, { 'aliasColors': {}, 'bars': False, 'dashLength': 10, 'dashes': False, 'datasource': None, 'fieldConfig': { 'defaults': { 'displayName': '${__field.name}' }, 'overrides': [] }, 'fill': 1, 'fillGradient': 0, 'hiddenSeries': False, 'id': next(panel_id), 'legend': { 'alignAsTable': False, 'avg': False, 'current': False, 'max': False, 'min': False, 'rightSide': False, 'show': True, 'total': False, 'values': False }, 'lines': True, 'linewidth': 1, 'NonePointMode': 'None', 'options': { 'alertThreshold': True }, 'percentage': False, 'pluginVersion': '7.5.5', 'pointradius': 2, 'points': False, 'renderer': 'flot', 'seriesOverrides': [], 'spaceLength': 10, 'span': 6, 'stack': False, 'steppedLine': False, 'targets': queries_load, 'thresholds': [], 'timeRegions': [], 'title': 'load', 'tooltip': { 'shared': True, 'sort': 0, 'value_type': 'individual' }, 'type': 'graph', 'xaxis': { 'buckets': None, 'mode': 'time', 'name': None, 'show': True, 'values': [] }, 'yaxes': [ { 'format': 'short', 'label': None, 'logBase': 1, 'max': None, 'min': None, 'show': True, 'decimals': 0, }, { 'format': 'short', 'label': None, 'logBase': 1, 'max': None, 'min': None, 'show': False, } ], 'yaxis': { 'align': False, 'alignLevel': None } }, ], }