From a27715b28f7c54de29dae1e1dda525694ae9562d Mon Sep 17 00:00:00 2001 From: nicolargo Date: Sat, 29 May 2021 10:38:53 +0200 Subject: Generate specific tag from stats' key for InfluxDB and InfluxDB2 export #1871 --- conf/glances-grafana.json | 1724 ++++++++-------------------------- conf/glances.conf | 22 +- docs/gw/influxdb.rst | 48 +- glances/exports/glances_influxdb.py | 11 +- glances/exports/glances_influxdb2.py | 79 +- 5 files changed, 517 insertions(+), 1367 deletions(-) diff --git a/conf/glances-grafana.json b/conf/glances-grafana.json index 94a62d5f..2c8063a0 100644 --- a/conf/glances-grafana.json +++ b/conf/glances-grafana.json @@ -64,7 +64,7 @@ "gnetId": null, "graphTooltip": 0, "id": null, - "iteration": 1622127318973, + "iteration": 1622127318980, "links": [], "panels": [ { @@ -145,7 +145,9 @@ "type": "time" } ], - "measurement": "$host.load", + "measurement": "load", + "orderByTime": "ASC", + "policy": "default", "query": "SELECT mean(\"cpucore\") FROM \"$host.load\" WHERE $timeFilter GROUP BY time($interval)", "refId": "A", "resultFormat": "time_series", @@ -159,12 +161,18 @@ }, { "params": [], - "type": "mean" + "type": "max" } ] ], "series": "load", - "tags": [] + "tags": [ + { + "key": "hostname", + "operator": "=~", + "value": "/^$host$/" + } + ] } ], "thresholds": "", @@ -259,7 +267,7 @@ "type": "fill" } ], - "measurement": "$host.load", + "measurement": "load", "orderByTime": "ASC", "policy": "default", "query": "SELECT mean(\"min1\") FROM \"$host.load\" WHERE $timeFilter GROUP BY time($interval) fill(null)", @@ -280,7 +288,13 @@ ] ], "series": "load", - "tags": [], + "tags": [ + { + "key": "hostname", + "operator": "=~", + "value": "/^$host$/" + } + ], "target": "randomWalk('random walk')" }, { @@ -302,7 +316,7 @@ "type": "fill" } ], - "measurement": "$host.load", + "measurement": "load", "orderByTime": "ASC", "policy": "default", "query": "SELECT mean(\"min5\") FROM \"$host.load\" WHERE $timeFilter GROUP BY time($interval) fill(null)", @@ -323,7 +337,13 @@ ] ], "series": "load", - "tags": [], + "tags": [ + { + "key": "hostname", + "operator": "=~", + "value": "/^$host$/" + } + ], "target": "" }, { @@ -345,7 +365,7 @@ "type": "fill" } ], - "measurement": "$host.load", + "measurement": "load", "orderByTime": "ASC", "policy": "default", "query": "SELECT mean(\"min15\") FROM \"$host.load\" WHERE $timeFilter GROUP BY time($interval) fill(null)", @@ -366,7 +386,13 @@ ] ], "series": "load", - "tags": [], + "tags": [ + { + "key": "hostname", + "operator": "=", + "value": "XPS13-9333" + } + ], "target": "" } ], @@ -489,7 +515,7 @@ "type": "time" } ], - "measurement": "$host.processcount", + "measurement": "processcount", "orderByTime": "ASC", "policy": "default", "query": "SELECT mean(\"total\") FROM \"$host.processcount\" WHERE $timeFilter GROUP BY time($interval)", @@ -510,7 +536,13 @@ ] ], "series": "processcount", - "tags": [] + "tags": [ + { + "key": "hostname", + "operator": "=~", + "value": "/^$host$/" + } + ] } ], "thresholds": "", @@ -595,7 +627,7 @@ "type": "fill" } ], - "measurement": "$host.cpu", + "measurement": "cpu", "orderByTime": "ASC", "policy": "default", "query": "SELECT mean(\"user\") FROM \"$host.cpu\" WHERE $timeFilter GROUP BY time($interval) fill(null)", @@ -616,7 +648,13 @@ ] ], "series": "cpu", - "tags": [] + "tags": [ + { + "key": "hostname", + "operator": "=~", + "value": "/^$host$/" + } + ] }, { "alias": "System", @@ -637,7 +675,7 @@ "type": "fill" } ], - "measurement": "$host.cpu", + "measurement": "cpu", "orderByTime": "ASC", "policy": "default", "query": "SELECT mean(\"system\") FROM \"$host.cpu\" WHERE $timeFilter GROUP BY time($interval) fill(null)", @@ -658,7 +696,13 @@ ] ], "series": "cpu", - "tags": [], + "tags": [ + { + "key": "hostname", + "operator": "=~", + "value": "/^$host$/" + } + ], "target": "" }, { @@ -680,7 +724,7 @@ "type": "fill" } ], - "measurement": "$host.cpu", + "measurement": "cpu", "orderByTime": "ASC", "policy": "default", "query": "SELECT mean(\"iowait\") FROM \"$host.cpu\" WHERE $timeFilter GROUP BY time($interval) fill(null)", @@ -701,7 +745,13 @@ ] ], "series": "cpu", - "tags": [], + "tags": [ + { + "key": "hostname", + "operator": "=~", + "value": "/^$host$/" + } + ], "target": "" } ], @@ -806,13 +856,19 @@ "$__interval" ], "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" } ], - "measurement": "$host.mem", + "measurement": "mem", "orderByTime": "ASC", "policy": "default", - "query": "SELECT mean(\"used\") FROM \"$host.mem\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", - "rawQuery": true, + "query": "SELECT mean(\"used\") FROM \"mem\" WHERE (\"hostname\" =~ /^$host$/) AND $timeFilter GROUP BY time($__interval) fill(none)", + "rawQuery": false, "refId": "A", "resultFormat": "time_series", "select": [ @@ -830,7 +886,13 @@ ] ], "series": "mem", - "tags": [] + "tags": [ + { + "key": "hostname", + "operator": "=~", + "value": "/^$host$/" + } + ] }, { "alias": "Max", @@ -843,13 +905,19 @@ "$__interval" ], "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" } ], - "measurement": "$host.mem", + "measurement": "mem", "orderByTime": "ASC", "policy": "default", - "query": "SELECT mean(\"total\") FROM \"$host.mem\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", - "rawQuery": true, + "query": "SELECT mean(\"total\") FROM \"mem\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", + "rawQuery": false, "refId": "B", "resultFormat": "time_series", "select": [ @@ -867,7 +935,13 @@ ] ], "series": "mem", - "tags": [], + "tags": [ + { + "key": "hostname", + "operator": "=~", + "value": "/^$host$/" + } + ], "target": "" } ], @@ -891,13 +965,15 @@ }, "yaxes": [ { + "$$hashKey": "object:2371", "format": "bytes", "logBase": 1, "max": null, - "min": null, + "min": "0", "show": true }, { + "$$hashKey": "object:2372", "format": "short", "logBase": 1, "max": null, @@ -987,7 +1063,7 @@ "measurement": "$host.network", "orderByTime": "ASC", "policy": "default", - "query": "SELECT mean(\"rx\")/mean(\"time_since_update\")*8 FROM \"$host.network\" WHERE (\"interface_name\" =~ /^$interface$/) AND $timeFilter GROUP BY time($interval) fill(none)", + "query": "SELECT mean(\"rx\")/mean(\"time_since_update\")*8 FROM \"network\" WHERE (\"hostname\" =~ /^$host$/) AND (\"interface_name\" =~ /^$interface$/) AND $timeFilter GROUP BY time($interval) fill(none)", "rawQuery": true, "refId": "A", "resultFormat": "time_series", @@ -1030,7 +1106,7 @@ "measurement": "$host.network", "orderByTime": "ASC", "policy": "default", - "query": "SELECT mean(\"tx\")/mean(\"time_since_update\")*-8 FROM \"$host.network\" WHERE (\"interface_name\" =~ /^$interface$/) AND $timeFilter GROUP BY time($interval) fill(none)", + "query": "SELECT mean(\"tx\")/mean(\"time_since_update\")*-8 FROM \"network\" WHERE (\"hostname\" =~ /^$host$/) AND (\"interface_name\" =~ /^$interface$/) AND $timeFilter GROUP BY time($interval) fill(none)", "rawQuery": true, "refId": "B", "resultFormat": "time_series", @@ -1073,6 +1149,7 @@ }, "yaxes": [ { + "$$hashKey": "object:2467", "format": "bps", "logBase": 1, "max": null, @@ -1080,6 +1157,7 @@ "show": true }, { + "$$hashKey": "object:2468", "format": "short", "logBase": 1, "max": null, @@ -1159,7 +1237,7 @@ "measurement": "$host.memswap", "orderByTime": "ASC", "policy": "default", - "query": "SELECT mean(\"used\") FROM \"$host.memswap\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", + "query": "SELECT mean(\"used\") FROM \"memswap\" WHERE (\"hostname\" =~ /^$host$/) AND $timeFilter GROUP BY time($__interval) fill(none)", "rawQuery": true, "refId": "A", "resultFormat": "time_series", @@ -1196,7 +1274,7 @@ "measurement": "$host.memswap", "orderByTime": "ASC", "policy": "default", - "query": "SELECT mean(\"total\") FROM \"$host.memswap\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", + "query": "SELECT mean(\"total\") FROM \"memswap\" WHERE (\"hostname\" =~ /^$host$/) AND $timeFilter GROUP BY time($__interval) fill(none)", "rawQuery": true, "refId": "B", "resultFormat": "time_series", @@ -1239,13 +1317,15 @@ }, "yaxes": [ { + "$$hashKey": "object:2690", "format": "bytes", "logBase": 1, "max": null, - "min": null, + "min": "0", "show": true }, { + "$$hashKey": "object:2691", "format": "short", "logBase": 1, "max": null, @@ -1334,7 +1414,7 @@ "measurement": "$host.diskio", "orderByTime": "ASC", "policy": "default", - "query": "SELECT mean(\"read_bytes\")/mean(\"time_since_update\") FROM \"$host.diskio\" WHERE (\"disk_name\" =~ /^$disk$/) AND $timeFilter GROUP BY time($__interval) fill(none)", + "query": "SELECT mean(\"read_bytes\")/mean(\"time_since_update\") FROM \"diskio\" WHERE (\"hostname\" =~ /^$host$/) AND (\"disk_name\" =~ /^$disk$/) AND $timeFilter GROUP BY time($__interval) fill(none)", "rawQuery": true, "refId": "A", "resultFormat": "time_series", @@ -1377,7 +1457,7 @@ "measurement": "$host.diskio", "orderByTime": "ASC", "policy": "default", - "query": "SELECT mean(\"write_bytes\")/mean(\"time_since_update\") FROM \"$host.diskio\" WHERE (\"disk_name\" =~ /^$disk$/) AND $timeFilter GROUP BY time($__interval) fill(none)", + "query": "SELECT mean(\"write_bytes\")/mean(\"time_since_update\") FROM \"diskio\" WHERE (\"hostname\" =~ /^$host$/) AND (\"disk_name\" =~ /^$disk$/) AND $timeFilter GROUP BY time($__interval) fill(none)", "rawQuery": true, "refId": "B", "resultFormat": "time_series", @@ -1420,6 +1500,7 @@ }, "yaxes": [ { + "$$hashKey": "object:2782", "format": "bytes", "logBase": 1, "max": null, @@ -1427,6 +1508,7 @@ "show": true }, { + "$$hashKey": "object:2783", "format": "bytes", "logBase": 1, "max": null, @@ -1487,8 +1569,10 @@ "renderer": "flot", "seriesOverrides": [ { + "$$hashKey": "object:3095", "alias": "Used", - "fill": 10 + "fill": 10, + "fillGradient": 8 } ], "spaceLength": 10, @@ -1514,7 +1598,7 @@ "type": "fill" } ], - "measurement": "$host.fs", + "measurement": "fs", "orderByTime": "ASC", "policy": "default", "query": "SELECT mean(\"/.used\") FROM \"$host.fs\" WHERE $timeFilter GROUP BY time($interval) fill(null)", @@ -1540,6 +1624,12 @@ "key": "mnt_point", "operator": "=", "value": "/" + }, + { + "condition": "AND", + "key": "hostname", + "operator": "=~", + "value": "/^$host$/" } ] }, @@ -1562,7 +1652,7 @@ "type": "fill" } ], - "measurement": "$host.fs", + "measurement": "fs", "orderByTime": "ASC", "policy": "default", "query": "SELECT mean(\"/.size\") FROM \"$host.fs\" WHERE $timeFilter GROUP BY time($interval) fill(null)", @@ -1588,6 +1678,12 @@ "key": "mnt_point", "operator": "=", "value": "/" + }, + { + "condition": "AND", + "key": "hostname", + "operator": "=~", + "value": "/^$host$/" } ], "target": "" @@ -1613,6 +1709,7 @@ }, "yaxes": [ { + "$$hashKey": "object:2891", "format": "bytes", "logBase": 1, "max": null, @@ -1620,6 +1717,7 @@ "show": true }, { + "$$hashKey": "object:2892", "format": "short", "logBase": 1, "max": null, @@ -1710,7 +1808,7 @@ "type": "time" } ], - "measurement": "$host.fs", + "measurement": "fs", "orderByTime": "ASC", "policy": "default", "query": "SELECT mean(\"/.percent\") FROM \"$host.fs\" WHERE $timeFilter GROUP BY time($interval)", @@ -1736,6 +1834,12 @@ "key": "mnt_point", "operator": "=", "value": "/" + }, + { + "condition": "AND", + "key": "hostname", + "operator": "=~", + "value": "/^$host$/" } ] } @@ -1831,10 +1935,11 @@ "type": "time" } ], - "measurement": "$host.fs", + "measurement": "fs", "orderByTime": "ASC", "policy": "default", - "query": "SELECT mean(\"/boot/efi.percent\") FROM \"$host.fs\" WHERE $timeFilter GROUP BY time($interval)", + "query": "SELECT mean(\"percent\") FROM \"fs\" WHERE (\"hostname\" =~ /^$host$/) AND (\"mnt_point\" = '/boot') AND $timeFilter GROUP BY time($__interval)", + "rawQuery": true, "refId": "A", "resultFormat": "time_series", "select": [ @@ -1876,8 +1981,6 @@ }, { "datasource": null, - "editable": true, - "error": false, "fieldConfig": { "defaults": {}, "overrides": [] @@ -1888,99 +1991,54 @@ "x": 0, "y": 27 }, - "id": 13, + "id": 22, "links": [], "options": { "content": "", "mode": "markdown" }, "pluginVersion": "7.5.3", - "style": {}, - "title": "Containers", + "title": "Sensors", "type": "text" }, { - "aliasColors": { - "$host.docker.mean": "#ba43a9", - "CPU%": "#cca300", - "MEM": "#2f575e" + "cards": { + "cardPadding": null, + "cardRound": null }, - "bars": false, - "dashLength": 10, - "dashes": false, + "color": { + "cardColor": "rgb(255, 0, 0)", + "colorScale": "sqrt", + "colorScheme": "interpolateReds", + "exponent": 1, + "min": null, + "mode": "opacity" + }, + "dataFormat": "timeseries", "datasource": "${DS_GLANCES}", "fieldConfig": { "defaults": {}, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "MEM" - }, - "properties": [ - { - "id": "unit", - "value": "decbytes" - } - ] - } - ] + "overrides": [] }, - "fill": 0, - "fillGradient": 0, "gridPos": { - "h": 8, - "w": 24, + "h": 6, + "w": 12, "x": 0, "y": 30 }, - "hiddenSeries": false, - "id": 25, + "heatmap": {}, + "hideZeroBuckets": false, + "highlightCards": true, + "id": 21, "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false + "show": false }, - "lines": true, - "linewidth": 2, "links": [], - "nullPointMode": "null", - "options": { - "alertThreshold": true - }, - "percentage": false, - "pluginVersion": "7.5.3", - "pointradius": 5, - "points": false, - "renderer": "flot", - "repeat": "container", - "repeatDirection": "v", - "seriesOverrides": [ - { - "alias": "$host.docker.mean", - "fill": 0 - }, - { - "alias": "MEM", - "yaxis": 2 - }, - { - "alias": "MEM", - "fill": 10, - "steppedLine": true, - "zindex": -3 - } - ], - "spaceLength": 10, - "stack": false, - "steppedLine": false, + "reverseYBuckets": false, "targets": [ { - "alias": "CPU%", + "alias": "AmbientTemperature", + "dsType": "influxdb", "groupBy": [ { "params": [ @@ -1990,24 +2048,21 @@ }, { "params": [ - "none" + "null" ], "type": "fill" } ], - "hide": false, - "measurement": "$host.docker", + "measurement": "sensors", "orderByTime": "ASC", "policy": "default", - "query": "SELECT mean(\"cpu_percent\") FROM \"$host.docker\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", - "rawQuery": false, "refId": "A", "resultFormat": "time_series", "select": [ [ { "params": [ - "cpu_percent" + "value" ], "type": "field" }, @@ -2019,1147 +2074,42 @@ ], "tags": [ { - "key": "name", - "operator": "=~", - "value": "/^$container$/" - } - ] - }, - { - "alias": "MEM", - "groupBy": [ - { - "params": [ - "$__interval" - ], - "type": "time" + "key": "label", + "operator": "=", + "value": "Ambient" }, { - "params": [ - "none" - ], - "type": "fill" - } - ], - "hide": false, - "measurement": "$host.docker", - "orderByTime": "ASC", - "policy": "default", - "query": "SELECT mean(\"cpu_percent\") FROM \"$host.docker\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", - "rawQuery": false, - "refId": "B", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "memory_usage" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - } - ] - ], - "tags": [ - { - "key": "name", + "condition": "AND", + "key": "hostname", "operator": "=~", - "value": "/^$container$/" + "value": "/^$host$/" } ] } ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "$container container", + "title": "Ambiant temperature", "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" + "show": true, + "showHistogram": false }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "decbytes", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "datasource": null, - "editable": true, - "error": false, - "fieldConfig": { - "defaults": {}, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 24, - "x": 0, - "y": 54 - }, - "id": 26, - "links": [], - "options": { - "content": "", - "mode": "markdown" - }, - "pluginVersion": "7.5.3", - "style": {}, - "title": "CPU details", - "type": "text" - }, - { - "aliasColors": { - "max": "#890F02" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "${DS_GLANCES}", - "editable": true, - "error": false, - "fieldConfig": { - "defaults": {}, - "overrides": [] - }, - "fill": 0, - "fillGradient": 0, - "grid": {}, - "gridPos": { - "h": 4, - "w": 24, - "x": 0, - "y": 57 - }, - "hiddenSeries": false, - "id": 12, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": false, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "options": { - "alertThreshold": true - }, - "percentage": false, - "pluginVersion": "7.5.3", - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "max", - "fillBelowTo": "min", - "lines": false - }, - { - "alias": "min", - "lines": false - }, - { - "alias": "mean", - "linewidth": 2, - "zindex": 3 - } - ], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "alias": "mean", - "column": "user", - "dsType": "influxdb", - "function": "mean", - "groupBy": [ - { - "params": [ - "auto" - ], - "type": "time" - }, - { - "params": [ - "none" - ], - "type": "fill" - } - ], - "interval": "60s", - "measurement": "$host.cpu", - "orderByTime": "ASC", - "policy": "default", - "query": "SELECT mean(\"user\") FROM \"$host.cpu\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", - "rawQuery": false, - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "user" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - } - ] - ], - "series": "cpu", - "tags": [] - }, - { - "alias": "min", - "column": "user", - "dsType": "influxdb", - "function": "min", - "groupBy": [ - { - "params": [ - "auto" - ], - "type": "time" - }, - { - "params": [ - "none" - ], - "type": "fill" - } - ], - "interval": "60s", - "measurement": "$host.cpu", - "orderByTime": "ASC", - "policy": "default", - "query": "SELECT min(\"user\") FROM \"$host.cpu\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", - "rawQuery": false, - "refId": "B", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "user" - ], - "type": "field" - }, - { - "params": [], - "type": "min" - } - ] - ], - "series": "cpu", - "tags": [], - "target": "" - }, - { - "alias": "max", - "column": "user", - "dsType": "influxdb", - "function": "max", - "groupBy": [ - { - "params": [ - "auto" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "interval": "60s", - "measurement": "$host.cpu", - "orderByTime": "ASC", - "policy": "default", - "query": "SELECT max(\"user\") FROM \"$host.cpu\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", - "rawQuery": false, - "refId": "C", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "user" - ], - "type": "field" - }, - { - "params": [], - "type": "max" - } - ] - ], - "series": "cpu", - "tags": [], - "target": "" - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "CPU user", - "tooltip": { - "shared": false, - "sort": 0, - "value_type": "cumulative" - }, - "transparent": true, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "percent", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "max": "#890F02" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "${DS_GLANCES}", - "editable": true, - "error": false, - "fieldConfig": { - "defaults": {}, - "overrides": [] - }, - "fill": 0, - "fillGradient": 0, - "grid": {}, - "gridPos": { - "h": 4, - "w": 24, - "x": 0, - "y": 61 - }, - "hiddenSeries": false, - "id": 14, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": false, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "options": { - "alertThreshold": true - }, - "percentage": false, - "pluginVersion": "7.5.3", - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "max", - "fillBelowTo": "min", - "lines": false - }, - { - "alias": "min", - "lines": false - }, - { - "alias": "mean", - "linewidth": 2, - "zindex": 3 - } - ], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "alias": "mean", - "column": "system", - "dsType": "influxdb", - "function": "mean", - "groupBy": [ - { - "params": [ - "auto" - ], - "type": "time" - }, - { - "params": [ - "none" - ], - "type": "fill" - } - ], - "interval": "60s", - "measurement": "$host.cpu", - "orderByTime": "ASC", - "policy": "default", - "query": "SELECT mean(\"system\") FROM \"$host.cpu\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", - "rawQuery": false, - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "system" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - } - ] - ], - "series": "cpu", - "tags": [] - }, - { - "alias": "min", - "column": "system", - "dsType": "influxdb", - "function": "min", - "groupBy": [ - { - "params": [ - "auto" - ], - "type": "time" - }, - { - "params": [ - "none" - ], - "type": "fill" - } - ], - "interval": "60s", - "measurement": "$host.cpu", - "orderByTime": "ASC", - "policy": "default", - "query": "SELECT min(\"system\") FROM \"$host.cpu\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", - "rawQuery": false, - "refId": "B", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "system" - ], - "type": "field" - }, - { - "params": [], - "type": "min" - } - ] - ], - "series": "cpu", - "tags": [], - "target": "" - }, - { - "alias": "max", - "column": "system", - "dsType": "influxdb", - "function": "max", - "groupBy": [ - { - "params": [ - "auto" - ], - "type": "time" - }, - { - "params": [ - "none" - ], - "type": "fill" - } - ], - "interval": "60s", - "measurement": "$host.cpu", - "orderByTime": "ASC", - "policy": "default", - "query": "SELECT max(\"system\") FROM \"$host.cpu\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", - "rawQuery": false, - "refId": "C", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "system" - ], - "type": "field" - }, - { - "params": [], - "type": "max" - } - ] - ], - "series": "cpu", - "tags": [], - "target": "" - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "CPU system", - "tooltip": { - "shared": false, - "sort": 0, - "value_type": "cumulative" - }, - "transparent": true, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "percent", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "max": "#890F02" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "${DS_GLANCES}", - "editable": true, - "error": false, - "fieldConfig": { - "defaults": {}, - "overrides": [] - }, - "fill": 0, - "fillGradient": 0, - "grid": {}, - "gridPos": { - "h": 4, - "w": 24, - "x": 0, - "y": 65 - }, - "hiddenSeries": false, - "id": 15, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "hideEmpty": false, - "max": false, - "min": false, - "show": false, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "options": { - "alertThreshold": true - }, - "percentage": false, - "pluginVersion": "7.5.3", - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "max", - "fillBelowTo": "min", - "lines": false - }, - { - "alias": "min", - "lines": false - }, - { - "alias": "mean", - "linewidth": 2, - "zindex": 3 - } - ], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "alias": "mean", - "column": "iowait", - "dsType": "influxdb", - "function": "mean", - "groupBy": [ - { - "params": [ - "auto" - ], - "type": "time" - }, - { - "params": [ - "none" - ], - "type": "fill" - } - ], - "interval": "60s", - "measurement": "$host.cpu", - "orderByTime": "ASC", - "policy": "default", - "query": "SELECT mean(\"iowait\") FROM \"$host.cpu\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", - "rawQuery": false, - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "iowait" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - } - ] - ], - "series": "cpu", - "tags": [] - }, - { - "alias": "min", - "column": "iowait", - "dsType": "influxdb", - "function": "min", - "groupBy": [ - { - "params": [ - "auto" - ], - "type": "time" - }, - { - "params": [ - "none" - ], - "type": "fill" - } - ], - "interval": "60s", - "measurement": "$host.cpu", - "orderByTime": "ASC", - "policy": "default", - "query": "SELECT min(\"iowait\") FROM \"$host.cpu\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", - "rawQuery": false, - "refId": "B", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "iowait" - ], - "type": "field" - }, - { - "params": [], - "type": "min" - } - ] - ], - "series": "cpu", - "tags": [], - "target": "" - }, - { - "alias": "max", - "column": "iowait", - "dsType": "influxdb", - "function": "max", - "groupBy": [ - { - "params": [ - "auto" - ], - "type": "time" - }, - { - "params": [ - "none" - ], - "type": "fill" - } - ], - "interval": "60s", - "measurement": "$host.cpu", - "orderByTime": "ASC", - "policy": "default", - "query": "SELECT max(\"iowait\") FROM \"$host.cpu\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", - "rawQuery": false, - "refId": "C", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "iowait" - ], - "type": "field" - }, - { - "params": [], - "type": "max" - } - ] - ], - "series": "cpu", - "tags": [], - "target": "" - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "CPU iowait", - "tooltip": { - "shared": false, - "sort": 0, - "value_type": "cumulative" - }, - "transparent": true, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "percent", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "max": "#890F02" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "${DS_GLANCES}", - "editable": true, - "error": false, - "fieldConfig": { - "defaults": {}, - "overrides": [] - }, - "fill": 0, - "fillGradient": 0, - "grid": {}, - "gridPos": { - "h": 4, - "w": 24, - "x": 0, - "y": 69 - }, - "hiddenSeries": false, - "id": 19, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "hideEmpty": false, - "max": false, - "min": false, - "show": false, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "options": { - "alertThreshold": true - }, - "percentage": false, - "pluginVersion": "7.5.3", - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "alias": "mean", - "column": "iowait", - "dsType": "influxdb", - "function": "mean", - "groupBy": [ - { - "params": [ - "auto" - ], - "type": "time" - }, - { - "params": [ - "none" - ], - "type": "fill" - } - ], - "interval": "60s", - "measurement": "$host.cpu", - "orderByTime": "ASC", - "policy": "default", - "query": "SELECT mean(\"ctx_switches\") / mean(\"time_since_update\") FROM \"$host.cpu\" WHERE $timeFilter GROUP BY time($interval)", - "rawQuery": false, - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "time_since_update" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - } - ] - ], - "series": "cpu", - "tags": [] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Context switches", - "tooltip": { - "shared": false, - "sort": 0, - "value_type": "cumulative" - }, - "transparent": true, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "none", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": { - "max": "#890F02" - }, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "${DS_GLANCES}", - "editable": true, - "error": false, - "fieldConfig": { - "defaults": {}, - "overrides": [] - }, - "fill": 0, - "fillGradient": 0, - "grid": {}, - "gridPos": { - "h": 4, - "w": 24, - "x": 0, - "y": 73 - }, - "hiddenSeries": false, - "id": 20, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "hideEmpty": false, - "max": false, - "min": false, - "show": false, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "null", - "options": { - "alertThreshold": true - }, - "percentage": false, - "pluginVersion": "7.5.3", - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "alias": "mean", - "column": "iowait", - "dsType": "influxdb", - "function": "mean", - "groupBy": [ - { - "params": [ - "auto" - ], - "type": "time" - }, - { - "params": [ - "none" - ], - "type": "fill" - } - ], - "interval": "60s", - "measurement": "$host.cpu", - "orderByTime": "ASC", - "policy": "default", - "query": "SELECT mean(\"interrupts\") / mean(\"time_since_update\") FROM \"$host.cpu\" WHERE $timeFilter GROUP BY time($interval)", - "rawQuery": false, - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "time_since_update" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - } - ] - ], - "series": "cpu", - "tags": [] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Interrupts", - "tooltip": { - "shared": false, - "sort": 0, - "value_type": "cumulative" - }, - "transparent": true, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "none", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "datasource": null, - "fieldConfig": { - "defaults": {}, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 24, - "x": 0, - "y": 77 + "type": "heatmap", + "xAxis": { + "show": true }, - "id": 22, - "links": [], - "options": { - "content": "", - "mode": "markdown" + "xBucketNumber": null, + "xBucketSize": null, + "yAxis": { + "decimals": null, + "format": "celsius", + "logBase": 1, + "max": null, + "min": "0", + "show": true, + "splitFactor": null }, - "pluginVersion": "7.5.3", - "title": "Sensors", - "type": "text" + "yBucketBound": "auto", + "yBucketNumber": null, + "yBucketSize": null }, { "cards": { @@ -3169,9 +2119,8 @@ "color": { "cardColor": "rgb(255, 0, 0)", "colorScale": "sqrt", - "colorScheme": "interpolateReds", + "colorScheme": "interpolateOranges", "exponent": 1, - "min": null, "mode": "opacity" }, "dataFormat": "timeseries", @@ -3181,15 +2130,15 @@ "overrides": [] }, "gridPos": { - "h": 7, - "w": 24, - "x": 0, - "y": 80 + "h": 6, + "w": 12, + "x": 12, + "y": 30 }, "heatmap": {}, "hideZeroBuckets": false, "highlightCards": true, - "id": 21, + "id": 23, "legend": { "show": false }, @@ -3197,7 +2146,7 @@ "reverseYBuckets": false, "targets": [ { - "alias": "AmbientTemperature", + "alias": "CpuTemperature", "dsType": "influxdb", "groupBy": [ { @@ -3213,7 +2162,7 @@ "type": "fill" } ], - "measurement": "$host.sensors", + "measurement": "sensors", "orderByTime": "ASC", "policy": "default", "refId": "A", @@ -3236,12 +2185,18 @@ { "key": "label", "operator": "=", - "value": "Ambient" + "value": "CPU" + }, + { + "condition": "AND", + "key": "hostname", + "operator": "=", + "value": "XPS13-9333" } ] } ], - "title": "Ambiant temperature", + "title": "CPU temperature", "tooltip": { "show": true, "showHistogram": false @@ -3266,42 +2221,111 @@ "yBucketSize": null }, { - "cards": { - "cardPadding": null, - "cardRound": null + "datasource": null, + "editable": true, + "error": false, + "fieldConfig": { + "defaults": {}, + "overrides": [] }, - "color": { - "cardColor": "rgb(255, 0, 0)", - "colorScale": "sqrt", - "colorScheme": "interpolateOranges", - "exponent": 1, - "mode": "opacity" + "gridPos": { + "h": 3, + "w": 24, + "x": 0, + "y": 36 }, - "dataFormat": "timeseries", + "id": 13, + "links": [], + "options": { + "content": "", + "mode": "markdown" + }, + "pluginVersion": "7.5.3", + "style": {}, + "title": "Containers", + "type": "text" + }, + { + "aliasColors": { + "$host.docker.mean": "#ba43a9", + "CPU%": "#cca300", + "MEM": "#2f575e" + }, + "bars": false, + "dashLength": 10, + "dashes": false, "datasource": "${DS_GLANCES}", "fieldConfig": { "defaults": {}, - "overrides": [] + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "MEM" + }, + "properties": [ + { + "id": "unit", + "value": "decbytes" + } + ] + } + ] }, + "fill": 0, + "fillGradient": 0, "gridPos": { - "h": 7, + "h": 8, "w": 24, "x": 0, - "y": 87 + "y": 39 }, - "heatmap": {}, - "hideZeroBuckets": false, - "highlightCards": true, - "id": 23, + "hiddenSeries": false, + "id": 25, "legend": { - "show": false + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false }, + "lines": true, + "linewidth": 2, "links": [], - "reverseYBuckets": false, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.3", + "pointradius": 5, + "points": false, + "renderer": "flot", + "repeat": "container", + "repeatDirection": "v", + "seriesOverrides": [ + { + "$$hashKey": "object:3517", + "alias": "MEM", + "yaxis": 2 + }, + { + "$$hashKey": "object:3518", + "alias": "MEM", + "fill": 10, + "fillGradient": 8, + "steppedLine": true, + "zindex": -3 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, "targets": [ { - "alias": "CpuTemperature", - "dsType": "influxdb", + "alias": "CPU%", "groupBy": [ { "params": [ @@ -3311,21 +2335,24 @@ }, { "params": [ - "null" + "none" ], "type": "fill" } ], - "measurement": "$host.sensors", + "hide": false, + "measurement": "docker", "orderByTime": "ASC", "policy": "default", + "query": "SELECT mean(\"cpu_percent\") FROM \"$host.docker\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", + "rawQuery": false, "refId": "A", "resultFormat": "time_series", "select": [ [ { "params": [ - "value" + "cpu_percent" ], "type": "field" }, @@ -3337,36 +2364,113 @@ ], "tags": [ { - "key": "label", - "operator": "=", - "value": "CPU" + "key": "name", + "operator": "=~", + "value": "/^$container$/" + }, + { + "condition": "AND", + "key": "hostname", + "operator": "=~", + "value": "/^$host$/" + } + ] + }, + { + "alias": "MEM", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "docker", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"cpu_percent\") FROM \"$host.docker\" WHERE $timeFilter GROUP BY time($__interval) fill(none)", + "rawQuery": false, + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "memory_usage" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "name", + "operator": "=~", + "value": "/^$container$/" + }, + { + "condition": "AND", + "key": "hostname", + "operator": "=~", + "value": "/^$host$/" } ] } ], - "title": "Cpu Temperature", + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "$container container", "tooltip": { - "show": true, - "showHistogram": false - }, - "type": "heatmap", - "xAxis": { - "show": true + "shared": true, + "sort": 0, + "value_type": "individual" }, - "xBucketNumber": null, - "xBucketSize": null, - "yAxis": { - "decimals": null, - "format": "celsius", - "logBase": 1, - "max": null, - "min": "0", + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, "show": true, - "splitFactor": null + "values": [] }, - "yBucketBound": "auto", - "yBucketNumber": null, - "yBucketSize": null + "yaxes": [ + { + "$$hashKey": "object:3541", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "$$hashKey": "object:3542", + "format": "decbytes", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } } ], "refresh": "5s", @@ -3379,7 +2483,7 @@ "allValue": null, "current": {}, "datasource": "${DS_GLANCES}", - "definition": "", + "definition": "show tag values with key=\"hostname\"", "description": null, "error": null, "hide": 0, @@ -3388,9 +2492,9 @@ "multi": false, "name": "host", "options": [], - "query": "show measurements", + "query": "show tag values with key=\"hostname\"", "refresh": 1, - "regex": "/(.*)\\..*/", + "regex": "", "skipUrlSync": false, "sort": 0, "tagValuesQuery": "", @@ -3474,7 +2578,7 @@ ] }, "time": { - "from": "now-15m", + "from": "now-1h", "to": "now" }, "timepicker": { @@ -3511,5 +2615,5 @@ "timezone": "browser", "title": "Glances", "uid": "000000002", - "version": 3 + "version": 4 } \ No newline at end of file diff --git a/conf/glances.conf b/conf/glances.conf index b90afe20..aca36468 100644 --- a/conf/glances.conf +++ b/conf/glances.conf @@ -449,12 +449,11 @@ db=glances # => foo.cpu # => foo.mem # You can also use dynamic values -#prefix=`hostname` -prefix=localhost -# Tags will be added for all measurements -#tags=foo:bar,spam:eggs -# You can also use dynamic values -#tags=system:`uname -s` +#prefix=foo +# Followings tags will be added for all measurements +# You can also use dynamic values. +# Note: hostname is always added as a tag +#tags=foo:bar,spam:eggs,domain:`domainname` [influxdb2] # Configuration for the --export influxdb2 option @@ -470,12 +469,11 @@ token=EjFUTWe8U-MIseEAkaVIgVnej_TrnbdvEcRkaB1imstW7gapSqy6_6-8XD-yd51V0zUUpDy-kA # => foo.cpu # => foo.mem # You can also use dynamic values -#prefix=`hostname` -prefix=localhost -# Tags will be added for all measurements -#tags=foo:bar,spam:eggs -# You can also use dynamic values -#tags=system:`uname -s` +#prefix=foo +# Followings tags will be added for all measurements +# You can also use dynamic values. +# Note: hostname is always added as a tag +#tags=foo:bar,spam:eggs,domain:`domainname` [cassandra] # Configuration for the --export cassandra option diff --git a/docs/gw/influxdb.rst b/docs/gw/influxdb.rst index ea795ffe..ce64cd3a 100644 --- a/docs/gw/influxdb.rst +++ b/docs/gw/influxdb.rst @@ -5,9 +5,29 @@ InfluxDB You can export statistics to an ``InfluxDB`` server (time series server). -In Glances version 3.1.8 and higher, the value of the key field will be -converted as a tag. For example, in the Docker plugin, the key = name, -so the container name will be tag and not a field. +In Glances version 3.1.8 and higher, the way Glances exports stats to +InfluxDB changes. The following fields will be added as tags: +- key stats (for example *interface_name* for network, container *name* for docker...) +- hostname (shortname) +- tags + +Glances InfluxDB data model: + ++---------------+-----------------------+-----------------------+ +| Measurement | Fields | Tags | ++===============+=======================+=======================+ +| cpu | user | hostname | +| | system | | +| | iowait... | | ++---------------+-----------------------+-----------------------+ +| network | rx | | +| | tx | | +| | time_since_update... | hostname | +|  | | interface_name | ++---------------+-----------------------+-----------------------+ +| docker | cpu_percent | hostname | +| | memory_usage... | name | ++---------------+-----------------------+-----------------------+ InfluxDB (up to version 1.7.x) ------------------------------ @@ -29,12 +49,11 @@ following: # => foo.cpu # => foo.mem # You can also use dynamic values - #prefix=`hostname` - prefix=localhost - # Tags will be added for all measurements - #tags=foo:bar,spam:eggs - # You can also use dynamic values - #tags=system:`uname -s` + #prefix=foo + # Followings tags will be added for all measurements + # You can also use dynamic values. + # Note: hostname is always added as a tag + #tags=foo:bar,spam:eggs,domain:`domainname` and run Glances with: @@ -72,12 +91,11 @@ following: # => foo.cpu # => foo.mem # You can also use dynamic values - #prefix=`hostname` - prefix=localhost - # Tags will be added for all measurements - #tags=foo:bar,spam:eggs - # You can also use dynamic values - #tags=system:`uname -s` + #prefix=foo + # Followings tags will be added for all measurements + # You can also use dynamic values. + # Note: hostname is always added as a tag + #tags=foo:bar,spam:eggs,domain:`domainname` and run Glances with: diff --git a/glances/exports/glances_influxdb.py b/glances/exports/glances_influxdb.py index 9dc67fb9..f1314998 100644 --- a/glances/exports/glances_influxdb.py +++ b/glances/exports/glances_influxdb.py @@ -20,6 +20,7 @@ """InfluxDB (up to InfluxDB 1.7.x) interface class.""" import sys +from platform import node from glances.logger import logger from glances.exports.glances_export import GlancesExport @@ -56,6 +57,9 @@ class Export(GlancesExport): if not self.export_enable: sys.exit(2) + # The hostname is always add as a tag + self.hostname = node().split('.')[0] + # Init the InfluxDB client self.client = self.init() @@ -115,7 +119,7 @@ class Export(GlancesExport): else: fields = data_dict # Transform to InfluxDB datamodel - # https://docs.influxdata.com/influxdb/v1.5/write_protocols/line_protocol_reference/ + # https://docs.influxdata.com/influxdb/v1.8/write_protocols/line_protocol_reference/ for k in fields: # Do not export empty (None) value if fields[k] is None: @@ -137,6 +141,8 @@ class Export(GlancesExport): tags[fields['key']] = str(fields[fields['key']]) # Remove it from the field list (can not be a field and a tag) fields.pop(fields['key']) + # Add the hostname as a tag + tags['hostname'] = self.hostname # Add the measurement to the list ret.append({'measurement': name, 'tags': tags, @@ -153,7 +159,8 @@ class Export(GlancesExport): logger.debug("Cannot export empty {} stats to InfluxDB".format(name)) else: try: - self.client.write_points(self._normalize(name, columns, points), time_precision="s") + self.client.write_points(self._normalize(name, columns, points), + time_precision="s") except Exception as e: # Log level set to debug instead of error (see: issue #1561) logger.debug("Cannot export {} stats to InfluxDB ({})".format(name, e)) diff --git a/glances/exports/glances_influxdb2.py b/glances/exports/glances_influxdb2.py index 1e619642..3b1ec47c 100644 --- a/glances/exports/glances_influxdb2.py +++ b/glances/exports/glances_influxdb2.py @@ -2,7 +2,7 @@ # # This file is part of Gl