From 1f39908e1cdab0990dc39120755852ef59993223 Mon Sep 17 00:00:00 2001 From: Matthos Denys Date: Fri, 12 Mar 2021 13:59:41 +0300 Subject: [PATCH] prepare complete --- deletesh.sh | 4 +- srcs/grafana/Dockerfile | 2 +- srcs/grafana/cfg/dashboards.yaml | 3 +- srcs/grafana/cfg/datasources.yaml | 14 +- srcs/grafana/cfg/mdenys-dashboard.json | 1053 +++++++++++++----------- srcs/telegraf/Dockerfile | 24 +- srcs/telegraf/telegraf.conf | 76 +- srcs/yaml/influxdb.yaml | 111 +-- srcs/yaml/telegraf.yaml | 6 +- 9 files changed, 669 insertions(+), 624 deletions(-) diff --git a/deletesh.sh b/deletesh.sh index 4bc00d9..302ffb0 100755 --- a/deletesh.sh +++ b/deletesh.sh @@ -4,13 +4,11 @@ kubectl delete svc mariadb-service kubectl delete svc phpmyadmin-service kubectl delete svc ftps kubectl delete svc wp-service +kubectl delete deployment telegraf kubectl delete deployment nginx-deployment kubectl delete deployment mariadb kubectl delete deployment wp kubectl delete deployment phpmyadmin-deployment kubectl delete deployment ftps kubectl delete pods --all -# eval $(minikube docker-env) -# docker stop $(docker ps -a -q) -# docker rm $(docker ps -a -q) kubectl delete pv --all \ No newline at end of file diff --git a/srcs/grafana/Dockerfile b/srcs/grafana/Dockerfile index 631b1d9..1adbc03 100755 --- a/srcs/grafana/Dockerfile +++ b/srcs/grafana/Dockerfile @@ -5,6 +5,6 @@ RUN apk add grafana --repository http://dl-cdn.alpinelinux.org/alpine/edge/c COPY cfg/grafana.ini /usr/share/grafana/conf/custom.ini COPY cfg/datasources.yaml /usr/share/grafana/conf/provisioning/datasources/influxdb.yaml COPY cfg/dashboards.yaml /usr/share/grafana/conf/provisioning/dashboards/dashboards.yaml -COPY cfg/mdenys-dashboard.json /var/lib/grafana/dashboards/mdenys-dashboard.json +COPY cfg/mdenys-dashboard.json /var/lib/grafana/dashboards/dashboard.json EXPOSE 3000 CMD /usr/sbin/grafana-server --homepath=/usr/share/grafana \ No newline at end of file diff --git a/srcs/grafana/cfg/dashboards.yaml b/srcs/grafana/cfg/dashboards.yaml index 4fe6cf5..0d445db 100644 --- a/srcs/grafana/cfg/dashboards.yaml +++ b/srcs/grafana/cfg/dashboards.yaml @@ -1,7 +1,6 @@ # # config file version apiVersion: 1 - providers: -- name: 'mdenys dashboard' +- name: 'dashboards' options: path: /var/lib/grafana/dashboards diff --git a/srcs/grafana/cfg/datasources.yaml b/srcs/grafana/cfg/datasources.yaml index bda626d..b298476 100644 --- a/srcs/grafana/cfg/datasources.yaml +++ b/srcs/grafana/cfg/datasources.yaml @@ -1,13 +1,9 @@ apiVersion: 1 datasources: -- name: influxdb +- name: influxDB type: influxdb - orgId: 1 - url: http://influxdb-service:8086 + url: http://influxdb:8086 + password: telegraf + user: telegraf database: telegraf - version: 1 - editable: false - isDefault: true - basicAuth: true - basicAuthUser: user - basicAuthPassword: user \ No newline at end of file + editable: false \ No newline at end of file diff --git a/srcs/grafana/cfg/mdenys-dashboard.json b/srcs/grafana/cfg/mdenys-dashboard.json index dc4f51e..a5652c2 100644 --- a/srcs/grafana/cfg/mdenys-dashboard.json +++ b/srcs/grafana/cfg/mdenys-dashboard.json @@ -19,26 +19,43 @@ "panels": [ { "aliasColors": {}, - "bars": false, + "bars": true, "dashLength": 10, "dashes": false, - "datasource": "influxdb", + "datasource": "influxDB", "fieldConfig": { "defaults": { - "custom": {} + "custom": { + "align": null, + "filterable": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } }, "overrides": [] }, "fill": 1, "fillGradient": 0, "gridPos": { - "h": 8, - "w": 12, + "h": 6, + "w": 8, "x": 0, "y": 0 }, "hiddenSeries": false, - "id": 10, + "id": 20, "legend": { "avg": false, "current": false, @@ -55,7 +72,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "7.3.2", + "pluginVersion": "7.3.4", "pointradius": 2, "points": false, "renderer": "flot", @@ -68,7 +85,7 @@ "groupBy": [ { "params": [ - "10s" + "$__interval" ], "type": "time" }, @@ -79,153 +96,23 @@ "type": "fill" } ], - "measurement": "docker_container_net", + "measurement": "docker_container_cpu", "orderByTime": "ASC", "policy": "default", + "queryType": "randomWalk", "refId": "A", "resultFormat": "time_series", "select": [ [ { "params": [ - "rx_bytes" + "usage_system" ], "type": "field" }, { "params": [], - "type": "mean" - } - ] - ], - "tags": [ - { - "key": "app", - "operator": "=", - "value": "mariadb" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "mariadb", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "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": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "influxdb", - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 8, - "w": 12, - "x": 12, - "y": 0 - }, - "hiddenSeries": false, - "id": 6, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "nullPointMode": "null", - "options": { - "alertThreshold": true - }, - "percentage": false, - "pluginVersion": "7.3.2", - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "groupBy": [ - { - "params": [ - "10s" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "measurement": "docker_container_net", - "orderByTime": "ASC", - "policy": "default", - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "rx_bytes" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" + "type": "sum" } ] ], @@ -280,11 +167,19 @@ } }, { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "influxdb", + "cards": { + "cardPadding": null, + "cardRound": null + }, + "color": { + "cardColor": "#b4ff00", + "colorScale": "sqrt", + "colorScheme": "interpolateOranges", + "exponent": 0.5, + "mode": "spectrum" + }, + "dataFormat": "timeseries", + "datasource": "influxDB", "fieldConfig": { "defaults": { "custom": { @@ -308,46 +203,27 @@ }, "overrides": [] }, - "fill": 1, - "fillGradient": 0, "gridPos": { - "h": 9, - "w": 12, - "x": 0, - "y": 8 + "h": 6, + "w": 8, + "x": 8, + "y": 0 }, - "hiddenSeries": false, - "id": 2, + "heatmap": {}, + "hideZeroBuckets": false, + "highlightCards": true, + "id": 6, "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false + "show": false }, - "lines": true, - "linewidth": 1, - "nullPointMode": "null", - "options": { - "alertThreshold": true - }, - "percentage": false, - "pluginVersion": "7.3.2", - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, + "pluginVersion": "7.3.4", + "reverseYBuckets": false, "targets": [ { "groupBy": [ { "params": [ - "10s" + "$__interval" ], "type": "time" }, @@ -377,6 +253,375 @@ } ] ], + "tags": [ + { + "key": "app", + "operator": "=", + "value": "influxdb" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "influx", + "tooltip": { + "show": true, + "showHistogram": false + }, + "type": "heatmap", + "xAxis": { + "show": true + }, + "xBucketNumber": null, + "xBucketSize": null, + "yAxis": { + "decimals": null, + "format": "short", + "logBase": 1, + "max": null, + "min": null, + "show": true, + "splitFactor": null + }, + "yBucketBound": "auto", + "yBucketNumber": null, + "yBucketSize": null + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "influxDB", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 6, + "w": 8, + "x": 16, + "y": 0 + }, + "hiddenSeries": false, + "id": 10, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.4", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "groupBy": [ + { + "params": [ + "1s" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "docker_container_cpu", + "orderByTime": "ASC", + "policy": "default", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "usage_total" + ], + "type": "field" + }, + { + "params": [], + "type": "integral" + } + ] + ], + "tags": [ + { + "key": "app", + "operator": "=", + "value": "mariadb" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "mariadb", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "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": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "cards": { + "cardPadding": null, + "cardRound": null + }, + "color": { + "cardColor": "#b4ff00", + "colorScale": "sqrt", + "colorScheme": "interpolateOranges", + "exponent": 0.5, + "mode": "spectrum" + }, + "dataFormat": "timeseries", + "datasource": "influxDB", + "fieldConfig": { + "defaults": { + "custom": { + "align": null, + "filterable": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 8, + "x": 0, + "y": 6 + }, + "heatmap": {}, + "hideZeroBuckets": false, + "highlightCards": true, + "id": 18, + "legend": { + "show": false + }, + "pluginVersion": "7.3.4", + "reverseYBuckets": false, + "targets": [ + { + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "docker_container_net", + "orderByTime": "ASC", + "policy": "default", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "rx_bytes" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "app", + "operator": "=", + "value": "wp" + } + ] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "wp", + "tooltip": { + "show": true, + "showHistogram": false + }, + "type": "heatmap", + "xAxis": { + "show": true + }, + "xBucketNumber": null, + "xBucketSize": null, + "yAxis": { + "decimals": null, + "format": "short", + "logBase": 1, + "max": null, + "min": null, + "show": true, + "splitFactor": null + }, + "yBucketBound": "auto", + "yBucketNumber": null, + "yBucketSize": null + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "influxDB", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 6, + "w": 8, + "x": 8, + "y": 6 + }, + "hiddenSeries": false, + "id": 2, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.4", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "docker_container_net", + "orderByTime": "ASC", + "policy": "default", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "rx_bytes" + ], + "type": "field" + }, + { + "params": [], + "type": "distinct" + } + ] + ], "tags": [ { "key": "app", @@ -432,7 +677,7 @@ "bars": false, "dashLength": 10, "dashes": false, - "datasource": "influxdb", + "datasource": "influxDB", "fieldConfig": { "defaults": { "custom": {} @@ -442,10 +687,10 @@ "fill": 1, "fillGradient": 0, "gridPos": { - "h": 8, - "w": 12, - "x": 12, - "y": 8 + "h": 6, + "w": 8, + "x": 16, + "y": 6 }, "hiddenSeries": false, "id": 4, @@ -465,7 +710,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "7.3.2", + "pluginVersion": "7.3.4", "pointradius": 2, "points": false, "renderer": "flot", @@ -478,7 +723,7 @@ "groupBy": [ { "params": [ - "10s" + "$__interval" ], "type": "time" }, @@ -492,8 +737,6 @@ "measurement": "docker_container_net", "orderByTime": "ASC", "policy": "default", - "query": "SELECT mean(\"usage_in_kernelmode\") FROM \"docker_container_cpu\" WHERE (\"app\" = 'nginx') AND $timeFilter GROUP BY time(10s) fill(null)", - "rawQuery": false, "refId": "A", "resultFormat": "time_series", "select": [ @@ -514,7 +757,7 @@ { "key": "app", "operator": "=", - "value": "nginx" + "value": "grafana" } ] } @@ -523,7 +766,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "nginx", + "title": "grafana", "tooltip": { "shared": true, "sort": 0, @@ -565,7 +808,7 @@ "bars": false, "dashLength": 10, "dashes": false, - "datasource": null, + "datasource": "influxDB", "fieldConfig": { "defaults": { "custom": {} @@ -575,272 +818,10 @@ "fill": 1, "fillGradient": 0, "gridPos": { - "h": 8, - "w": 12, - "x": 12, - "y": 16 - }, - "hiddenSeries": false, - "id": 14, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "nullPointMode": "null", - "options": { - "alertThreshold": true - }, - "percentage": false, - "pluginVersion": "7.3.2", - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "groupBy": [ - { - "params": [ - "10s" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "measurement": "docker_container_net", - "orderByTime": "ASC", - "policy": "default", - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "rx_bytes" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - } - ] - ], - "tags": [ - { - "key": "app", - "operator": "=", - "value": "influxdb" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "influxdb", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "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": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "influxdb", - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 8, - "w": 12, + "h": 6, + "w": 8, "x": 0, - "y": 17 - }, - "hiddenSeries": false, - "id": 8, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "nullPointMode": "null", - "options": { - "alertThreshold": true - }, - "percentage": false, - "pluginVersion": "7.3.2", - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "groupBy": [ - { - "params": [ - "10s" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "measurement": "docker_container_net", - "orderByTime": "ASC", - "policy": "default", - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "rx_bytes" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - } - ] - ], - "tags": [ - { - "key": "app", - "operator": "=", - "value": "wordpress" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "wp", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "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": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "influxdb", - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 8, - "w": 12, - "x": 12, - "y": 24 + "y": 12 }, "hiddenSeries": false, "id": 16, @@ -860,7 +841,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "7.3.2", + "pluginVersion": "7.3.4", "pointradius": 2, "points": false, "renderer": "flot", @@ -873,7 +854,7 @@ "groupBy": [ { "params": [ - "10s" + "$__interval" ], "type": "time" }, @@ -958,7 +939,7 @@ "bars": false, "dashLength": 10, "dashes": false, - "datasource": "influxdb", + "datasource": "influxDB", "fieldConfig": { "defaults": { "custom": {} @@ -968,10 +949,10 @@ "fill": 1, "fillGradient": 0, "gridPos": { - "h": 8, - "w": 12, - "x": 0, - "y": 25 + "h": 6, + "w": 8, + "x": 8, + "y": 12 }, "hiddenSeries": false, "id": 12, @@ -991,7 +972,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "7.3.2", + "pluginVersion": "7.3.4", "pointradius": 2, "points": false, "renderer": "flot", @@ -1004,7 +985,7 @@ "groupBy": [ { "params": [ - "10s" + "$__interval" ], "type": "time" }, @@ -1018,8 +999,6 @@ "measurement": "docker_container_net", "orderByTime": "ASC", "policy": "default", - "query": "SELECT mean(\"value\") FROM \"docker_container_net\" WHERE (\"app\" = 'select tag value') AND $timeFilter GROUP BY time($__interval) fill(null)", - "rawQuery": false, "refId": "A", "resultFormat": "time_series", "select": [ @@ -1040,7 +1019,7 @@ { "key": "app", "operator": "=", - "value": "grafana" + "value": "nginx" } ] } @@ -1049,7 +1028,138 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "grafana", + "title": "nginx", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "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": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "influxDB", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 6, + "w": 8, + "x": 16, + "y": 12 + }, + "hiddenSeries": false, + "id": 8, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.4", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "docker_container_cpu", + "orderByTime": "ASC", + "policy": "default", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "usage_system" + ], + "type": "field" + }, + { + "params": [], + "type": "count" + } + ] + ], + "tags": [ + { + "key": "app", + "operator": "=", + "value": "metallb" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "metallb", "tooltip": { "shared": true, "sort": 0, @@ -1087,7 +1197,6 @@ } } ], - "refresh": "5s", "schemaVersion": 26, "style": "dark", "tags": [], @@ -1095,12 +1204,12 @@ "list": [] }, "time": { - "from": "now-5m", + "from": "now-15m", "to": "now" }, "timepicker": {}, "timezone": "", - "title": "mdenys", - "uid": "G2V6DKTMk", + "title": "dashboard", + "uid": "HsCakvtGz", "version": 1 } \ No newline at end of file diff --git a/srcs/telegraf/Dockerfile b/srcs/telegraf/Dockerfile index 88e97a9..73877d1 100755 --- a/srcs/telegraf/Dockerfile +++ b/srcs/telegraf/Dockerfile @@ -1,11 +1,15 @@ -FROM alpine:3.12 -RUN apk update && apk upgrade -RUN apk add wget -RUN wget https://dl.influxdata.com/telegraf/releases/telegraf-1.16.2_linux_amd64.tar.gz -RUN tar xf telegraf-1.16.2_linux_amd64.tar.gz -RUN cp -r ./telegraf-1.16.2/* / -COPY telegraf.conf /etc/telegraf/ -RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub -RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.32-r0/glibc-2.32-r0.apk -RUN apk add glibc-2.32-r0.apk +FROM alpine:3.12 +RUN apk update && apk add openrc +ADD https://dl.influxdata.com/telegraf/releases/telegraf-1.17.3_linux_amd64.tar.gz /etc/ +RUN tar -xzf /etc/telegraf-1.17.3_linux_amd64.tar.gz -C /etc/ ; \ + rm -rf /etc/telegraf-1.17.3_linux_amd64.tar.gz +RUN mv /etc/telegraf-1.17.3 /telegraf +RUN cp -r telegraf/* ./ +RUN rm -rf /telegraf +RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub \ + https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub +RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk +RUN apk add glibc-2.28-r0.apk +RUN telegraf -sample-config telegraf.conf --input-filter cpu:mem --output-filter influxdb > telegraf.conf +COPY telegraf.conf /etc/telegraf/ CMD telegraf \ No newline at end of file diff --git a/srcs/telegraf/telegraf.conf b/srcs/telegraf/telegraf.conf index 87520c9..07a3c26 100755 --- a/srcs/telegraf/telegraf.conf +++ b/srcs/telegraf/telegraf.conf @@ -1,105 +1,37 @@ [global_tags] - # Telegraf has a few options you can configure under the [agent] section of the config. [agent] - # Default data collection interval for all inputs interval = "10s" - # Rounds collection interval to interval. - # For example, if interval is set to 10s then always collect on :00, :10, :20, etc. round_interval = true - # Telegraf will send metrics to output in batch of at most metric_batch_size metrics. metric_batch_size = 1000 - # Telegraf will cache metric_buffer_limit metrics for each output, and will flush this buffer on a successful write. - # This should be a multiple of metric_batch_size and could not be less than 2 times metric_batch_size. metric_buffer_limit = 10000 - # Collection jitter is used to jitter the collection by a random amount. - # Each plugin will sleep for a random time within jitter before collecting. This can be used to avoid many plugins - # querying things like sysfs at the same time, which can have a measurable effect on the system. collection_jitter = "0s" - # Default data flushing interval for all outputs. - # You should not set this below interval. Maximum flush_interval will be flush_interval + flush_jitter flush_interval = "10s" - # Jitter the flush interval by a random amount. This is primarily to avoid large write spikes for users running a large number of Telegraf instances. - # For example, a flush_jitter of 5s and flush_interval of 10s means flushes will happen every 10-15s. flush_jitter = "0s" - # By default, precision will be set to the same timestamp order as the collection interval, with the maximum being 1s. - # Precision will NOT be used for service inputs, such as logparser and statsd. Valid values are ns, us (or µs), ms, and s. precision = "" - # Override default hostname, if empty use os.Hostname(). hostname = "" - # If true, do no set the host tag in the Telegraf agent omit_hostname = false - - # Configuration for sending metrics to InfluxDB [[outputs.influxdb]] - ## The full HTTP or UDP URL for your InfluxDB instance. - ## - ## Multiple URLs can be specified for a single cluster, only ONE of the - ## urls will be written to each interval. - urls = ["http://influxdb-service:8086"] - ## The target database for metrics; will be created as needed. - ## For UDP url endpoint database needs to be configured on server side. + urls = ["http://influxdb:8086"] database = "telegraf" - ## HTTP Basic Auth - username = "mdenys" - password = "mdenys" - + username = "telegraf" + password = "telegraf" [[inputs.cpu]] - ## Whether to report per-cpu stats or not percpu = true - ## Whether to report total system cpu stats or not totalcpu = true - ## If true, collect raw CPU time metrics. collect_cpu_time = false - ## If true, compute and report the sum of all non-idle CPU states. report_active = false - [[inputs.disk]] - ## By default stats will be gathered for all mount points. - ## Set mount_points will restrict the stats to only the specified mount points. - # mount_points = ["/"] - - ## Ignore mount points by filesystem type. ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"] - - - # REF: https://github.com/influxdata/telegraf/tree/master/plugins/inputs/docker - # Read metrics about docker containers [[inputs.docker]] - ## Docker Endpoint - ## To use TCP, set endpoint = "tcp://[ip]:[port]" - ## To use environment variables (ie, docker-machine), set endpoint = "ENV" endpoint = "unix:///var/run/docker.sock" - ## Set to true to collect Swarm metrics(desired_replicas, running_replicas) - ## Note: configure this in one of the manager nodes in a Swarm cluster. - ## configuring in multiple Swarm managers results in duplication of metrics. gather_services = false - ## Only collect metrics for these containers. Values will be appended to - ## container_name_include. - ## Deprecated (1.4.0), use container_name_include container_names = [] - ## Set the source tag for the metrics to the container ID hostname, eg first 12 chars source_tag = false - ## Containers to include and exclude. Collect all if empty. Globs accepted. container_name_include = [] container_name_exclude = [] - ## Timeout for docker list, info, and stats commands timeout = "5s" - ## Whether to report for each container per-device blkio (8:0, 8:1...) and - ## network (eth0, eth1, ...) stats or not perdevice = true - ## Whether to report for each container total blkio and network stats or not total = false - ## docker labels to include and exclude as tags. Globs accepted. - ## Note that an empty array for both will include all labels as tags docker_label_include = [] docker_label_exclude = ["annotation.kubernetes*"] - - ## Which environment variables should we use as a tag - tag_env = ["JAVA_HOME", "HEAP_SIZE"] - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false \ No newline at end of file + tag_env = ["JAVA_HOME", "HEAP_SIZE"] \ No newline at end of file diff --git a/srcs/yaml/influxdb.yaml b/srcs/yaml/influxdb.yaml index bb410a9..743f30f 100644 --- a/srcs/yaml/influxdb.yaml +++ b/srcs/yaml/influxdb.yaml @@ -1,15 +1,15 @@ apiVersion: v1 kind: Service metadata: - name: influxdb-service + name: influxdb labels: app: influxdb spec: - type: ClusterIP + type: ClusterIP ports: - - port: 8086 - name: influxdb - targetPort: 8086 + - port: 8086 + targetPort: 8086 + name: http selector: app: influxdb --- @@ -23,79 +23,82 @@ spec: selector: matchLabels: app: influxdb + strategy: + type: Recreate template: metadata: labels: app: influxdb spec: + restartPolicy: Always containers: - - name: influxdb-container - image: influxdb-image - imagePullPolicy: Never - ports: - - containerPort: 8086 - volumeMounts: - - mountPath: "/var/lib/influxdb" - name: influxdb-pv - - name: influxdb-conf - mountPath: /etc/influxdb/influxdb.conf - subPath: influxdb.conf - readOnly: true + - name: influxdb + image: influxdb-image + imagePullPolicy: Never + ports: + - containerPort: 8086 + volumeMounts: + - mountPath: "/var/lib/influxdb" + name: influxdb-data + - name: influxdb + mountPath: /etc/influxdb/influxdb.conf + subPath: influxdb.conf + readOnly: true volumes: - - name: influxdb-pv - persistentVolumeClaim: - claimName: influxdb-pvc - - name: influxdb-conf - configMap: - name: influxdb-conf + - name: influxdb-data + persistentVolumeClaim: + claimName: influxdb-data-disk + - name: influxdb + configMap: + name: influxdb +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: influxdb + labels: + app: influxdb +data: + influxdb.conf: | + bind-adress="172.17.0.1:8088" + [meta] + dir="/var/lib/influxdb/meta" + [data] + dir="/var/lib/influxdb/data" + wal-dir = "/var/lib/influxdb/wal" + trace-logging-enable=true + [http] + bind-addres=":8086" + log-enabled=true + [[graphite]] + database="telegraf" --- apiVersion: v1 kind: PersistentVolume metadata: - name: influxdb-pv + name: influxdb-data labels: type: local spec: - storageClassName: fast - capacity: - storage: 500Mi + storageClassName: manual accessModes: - ReadWriteOnce + capacity: + storage: 1Gi hostPath: - path: "/var/lib/influxdb" + path: "/mnt/influx" + type: DirectoryOrCreate claimRef: - name: mysql-pvc + name: influxdb-data-disk + namespace: default --- apiVersion: v1 kind: PersistentVolumeClaim metadata: - name: influxdb-pvc - labels: - app: influxdb + name: influxdb-data-disk spec: accessModes: - ReadWriteOnce resources: requests: - storage: 500Mi ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: influxdb-conf - labels: - app: influxdb -data: - influxdb.conf: | - bind-address = "127.0.0.1:8088" - [meta] - dir = "/var/lib/influxdb/meta" - [data] - dir = "/var/lib/influxdb/data" - wal-dir = "/var/lib/influxdb/wal" - trace-logging-enabled = true - [http] - bind-address = ":8086" - log-enabled = true - [[graphite]] - database = "telegraf" \ No newline at end of file + storage: 1Gi \ No newline at end of file diff --git a/srcs/yaml/telegraf.yaml b/srcs/yaml/telegraf.yaml index e49be72..e990d09 100644 --- a/srcs/yaml/telegraf.yaml +++ b/srcs/yaml/telegraf.yaml @@ -8,6 +8,10 @@ spec: selector: matchLabels: app: telegraf + replicas: 1 + strategy: + type: Recreate + minReadySeconds: 5 template: metadata: name: telegraf @@ -15,7 +19,7 @@ spec: app: telegraf spec: containers: - - name: telegraf-container + - name: telegraf image: telegraf-image imagePullPolicy: Never volumeMounts: