From b5406d18de64f273cbebb3875a84bc31074f0f00 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 10 Nov 2022 19:31:09 +0100 Subject: prometheus: add exporter for bind --- .../group_vars/promzone-chaos-at-home/vars.yml | 2 + inventory/host_vars/ch-mimas.yml | 9 + inventory/host_vars/ch-mon.yml | 2 + inventory/host_vars/ch-pan.yml | 11 +- roles/monitoring/grafana/files/dashboard-bind.json | 2253 ++++++++++++++++++++ .../prometheus/exporter/bind/defaults/main.yml | 9 + .../prometheus/exporter/bind/handlers/main.yml | 10 + .../prometheus/exporter/bind/tasks/main.yml | 44 + .../prometheus/exporter/bind/templates/service.j2 | 30 + roles/monitoring/prometheus/exporter/meta/main.yml | 2 + .../prometheus/server/defaults/main/main.yml | 1 + .../prometheus/server/defaults/main/rules_bind.yml | 11 + roles/network/bind/defaults/main.yml | 9 +- roles/network/bind/tasks/main.yml | 22 + roles/network/bind/templates/stats.j2 | 7 + 15 files changed, 2420 insertions(+), 2 deletions(-) create mode 100644 roles/monitoring/grafana/files/dashboard-bind.json create mode 100644 roles/monitoring/prometheus/exporter/bind/defaults/main.yml create mode 100644 roles/monitoring/prometheus/exporter/bind/handlers/main.yml create mode 100644 roles/monitoring/prometheus/exporter/bind/tasks/main.yml create mode 100644 roles/monitoring/prometheus/exporter/bind/templates/service.j2 create mode 100644 roles/monitoring/prometheus/server/defaults/main/rules_bind.yml create mode 100644 roles/network/bind/templates/stats.j2 diff --git a/inventory/group_vars/promzone-chaos-at-home/vars.yml b/inventory/group_vars/promzone-chaos-at-home/vars.yml index 2cc051c0..2a71f94f 100644 --- a/inventory/group_vars/promzone-chaos-at-home/vars.yml +++ b/inventory/group_vars/promzone-chaos-at-home/vars.yml @@ -11,6 +11,7 @@ prometheus_exporter_ssl_version: 2.4.2 prometheus_exporter_blackbox_version: 0.22.0 prometheus_exporter_nut_version: 2.4.2 prometheus_exporter_smokeping_version: 0.6.1 +prometheus_exporter_bind_version: 0.5.0 prometheus_server_version: 2.38.0 prometheus_alertmanager_version: 0.24.0 @@ -27,6 +28,7 @@ prometheus_server_jobs: - ssl - ssl/probe - smokeping + - bind prometheus_zone_name: chaos@home prometheus_zone_targets: "{{ groups['promzone-chaos-at-home'] }}" diff --git a/inventory/host_vars/ch-mimas.yml b/inventory/host_vars/ch-mimas.yml index 7994ed2d..b5de8e27 100644 --- a/inventory/host_vars/ch-mimas.yml +++ b/inventory/host_vars/ch-mimas.yml @@ -21,6 +21,12 @@ bind_option_allow_recursion: - localhost bind_option_notify: 'no' +bind_stats_channels: + - addr: 127.0.0.1 + port: 8053 + allow: + - 127.0.0.1 + bind_empty_onion_zone: yes bind_slave_zones: pan: @@ -72,6 +78,9 @@ bind_slave_zones: prometheus_scrape_endpoint: "116.203.212.131:9999" +prometheus_exporters_extra: + - bind + prometheus_job_multitarget_blackbox__probe: ch-mon: - instance: "ssh-{{ inventory_hostname }}" diff --git a/inventory/host_vars/ch-mon.yml b/inventory/host_vars/ch-mon.yml index 4e324830..17fc2024 100644 --- a/inventory/host_vars/ch-mon.yml +++ b/inventory/host_vars/ch-mon.yml @@ -194,3 +194,5 @@ grafana_dashboards: datasource: "Prometheus" - file: smokeping datasource: "Prometheus" + - file: bind + datasource: "Prometheus" diff --git a/inventory/host_vars/ch-pan.yml b/inventory/host_vars/ch-pan.yml index 4198d252..0f370fb9 100644 --- a/inventory/host_vars/ch-pan.yml +++ b/inventory/host_vars/ch-pan.yml @@ -50,6 +50,12 @@ bind_option_allow_update: bind_option_allow_recursion: - localhost +bind_stats_channels: + - addr: 127.0.0.1 + port: 8053 + allow: + - 127.0.0.1 + bind_empty_onion_zone: yes bind_master_zones: @@ -99,10 +105,13 @@ bind_slave_zones: - 151.33.193.in-addr.arpa +prometheus_exporters_extra: + - bind + prometheus_job_multitarget_blackbox__probe: ch-mon: - instance: "ssh-{{ inventory_hostname }}" - target: "{{ network.primary.address | ipaddr('address') }}:{{ ansible_port | default(22) }}" + target: "{{ network.primary.address | ansible.utils.ipaddr('address') }}:{{ ansible_port | default(22) }}" module: ssh_banner - instance: "https-pan.chaos-at-home.org" target: "https://pan.chaos-at-home.org" diff --git a/roles/monitoring/grafana/files/dashboard-bind.json b/roles/monitoring/grafana/files/dashboard-bind.json new file mode 100644 index 00000000..658761ed --- /dev/null +++ b/roles/monitoring/grafana/files/dashboard-bind.json @@ -0,0 +1,2253 @@ +{ + "__inputs": [ + { + "name": "DS_PROMETHEUS", + "label": "Prometheus", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "__elements": {}, + "__requires": [ + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "9.2.3" + }, + { + "type": "panel", + "id": "graph", + "name": "Graph (old)", + "version": "" + }, + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "1.0.0" + }, + { + "type": "panel", + "id": "stat", + "name": "Stat", + "version": "" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "description": "Bind9 DNS Service Statistics.", + "editable": true, + "fiscalYearStartMonth": 0, + "gnetId": 12309, + "graphTooltip": 0, + "id": null, + "links": [ + { + "icon": "external link", + "tags": [], + "title": "Dashboard Source", + "tooltip": "", + "type": "link", + "url": "https://github.com/pecastro/grafana-dashboards/blob/master/prometheus/bind9-exporter-dns.json" + } + ], + "liveNow": false, + "panels": [ + { + "collapsed": false, + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 19, + "panels": [], + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "refId": "A" + } + ], + "title": "System", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "decimals": 1, + "mappings": [ + { + "options": { + "match": "null", + "result": { + "text": "N/A" + } + }, + "type": "special" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 6, + "x": 0, + "y": 1 + }, + "id": 1, + "links": [], + "maxDataPoints": 100, + "options": { + "colorMode": "none", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "9.2.3", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "${__to:date:seconds} - max(bind_boot_time_seconds{instance=~\"$node\"}) ", + "instant": true, + "interval": "", + "intervalFactor": 1, + "legendFormat": "", + "range": false, + "refId": "A", + "step": 600, + "target": "" + } + ], + "title": "Restarted", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "decimals": 1, + "mappings": [ + { + "options": { + "match": "null", + "result": { + "text": "N/A" + } + }, + "type": "special" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 6, + "x": 6, + "y": 1 + }, + "id": 2, + "links": [], + "maxDataPoints": 100, + "options": { + "colorMode": "none", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "9.2.3", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "${__to:date:seconds} - max(bind_config_time_seconds{instance=~\"$node\"})", + "instant": true, + "interval": "", + "intervalFactor": 1, + "legendFormat": "", + "range": false, + "refId": "A", + "step": 600, + "target": "" + } + ], + "title": "Reconfigured", + "type": "stat" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 3, + "fillGradient": 0, + "gridPos": { + "h": 4, + "w": 12, + "x": 12, + "y": 1 + }, + "hiddenSeries": false, + "id": 3, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 3, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "9.2.3", + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "increase(process_cpu_seconds_total{instance=~\"$node\"}[120s])", + "interval": "", + "intervalFactor": 2, + "legendFormat": "", + "range": true, + "refId": "A", + "step": 10, + "target": "" + } + ], + "thresholds": [], + "timeRegions": [], + "title": "Named CPU Time", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:2383", + "format": "s", + "logBase": 1, + "show": true + }, + { + "$$hashKey": "object:2384", + "format": "short", + "logBase": 1, + "show": true + } + ], + "yaxis": { + "align": false + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 4, + "w": 8, + "x": 0, + "y": 5 + }, + "hiddenSeries": false, + "id": 16, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": true, + "pluginVersion": "9.2.3", + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "(sum(rate(node_cpu_seconds_total{instance=~\"$node\"}[120s])) by (mode) * 100) / scalar(count(node_cpu_seconds_total{mode=\"user\", instance=~\"$node\"}))", + "hide": false, + "interval": "", + "intervalFactor": 2, + "legendFormat": "{{ mode }}", + "range": true, + "refId": "A", + "step": 10, + "target": "" + } + ], + "thresholds": [], + "timeRegions": [], + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:2468", + "format": "percent", + "logBase": 1, + "max": "100", + "min": "0", + "show": true + }, + { + "$$hashKey": "object:2469", + "format": "short", + "logBase": 1, + "show": false + } + ], + "yaxis": { + "align": false + } + }, + { + "aliasColors": { + "Load 15m": "#CCA300", + "Load 1m": "#890F02", + "Load 5m": "#C15C17" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 4, + "w": 8, + "x": 8, + "y": 5 + }, + "hiddenSeries": false, + "id": 17, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": true, + "pluginVersion": "9.2.3", + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "node_load1{instance=~\"$node\"}", + "interval": "", + "intervalFactor": 2, + "legendFormat": "Load 1m", + "range": true, + "refId": "A", + "step": 10, + "target": "" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "node_load5{instance=~\"$node\"}", + "interval": "", + "intervalFactor": 2, + "legendFormat": "Load 5m", + "range": true, + "refId": "B", + "step": 10, + "target": "" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "node_load15{instance=~\"$node\"}", + "interval": "", + "intervalFactor": 2, + "legendFormat": "Load 15m", + "range": true, + "refId": "C", + "step": 10, + "target": "" + } + ], + "thresholds": [], + "timeRegions": [], + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:2549", + "format": "short", + "logBase": 1, + "min": "0", + "show": true + }, + { + "$$hashKey": "object:2550", + "format": "short", + "logBase": 1, + "show": false + } + ], + "yaxis": { + "align": false + } + }, + { + "aliasColors": { + "Load 15m": "#CCA300", + "Load 1m": "#890F02", + "Load 5m": "#C15C17" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 5, + "fillGradient": 0, + "gridPos": { + "h": 4, + "w": 8, + "x": 16, + "y": 5 + }, + "hiddenSeries": false, + "id": 18, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "9.2.3", + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "node_memory_MemTotal_bytes{instance=~\"$node\"} - (node_memory_MemFree_bytes{instance=~\"$node\"} + node_memory_Buffers_bytes{instance=~\"$node\"} + node_memory_Cached_bytes{instance=~\"$node\"})", + "interval": "", + "intervalFactor": 2, + "legendFormat": "Used", + "range": true, + "refId": "A", + "step": 10, + "target": "" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "node_memory_MemFree_bytes{instance=~\"$node\"}", + "interval": "", + "intervalFactor": 2, + "legendFormat": "Mem Free", + "range": true, + "refId": "B", + "step": 10, + "target": "" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "node_memory_Buffers_bytes{instance=~\"$node\"}", + "interval": "", + "intervalFactor": 2, + "legendFormat": "Buffers", + "range": true, + "refId": "C", + "step": 10, + "target": "" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "node_memory_Cached_bytes{instance=~\"$node\"}", + "interval": "", + "intervalFactor": 2, + "legendFormat": "Cached", + "range": true, + "refId": "D", + "step": 10, + "target": "" + } + ], + "thresholds": [], + "timeRegions": [], + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "show": true, + "values": [ + "total" + ] + }, + "yaxes": [ + { + "$$hashKey": "object:2630", + "format": "bytes", + "logBase": 1, + "min": "0", + "show": true + }, + { + "$$hashKey": "object:2631", + "format": "short", + "logBase": 1, + "show": false + } + ], + "yaxis": { + "align": false + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 9 + }, + "hiddenSeries": false, + "id": 4, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "9.2.3", + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "$$hashKey": "object:2711", + "alias": "Max File Descriptors", + "fill": 0 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "process_max_fds{instance=\"$node\"}", + "interval": "", + "intervalFactor": 2, + "legendFormat": "Max", + "range": true, + "refId": "A", + "step": 10, + "target": "" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "process_open_fds{instance=\"$node\"}", + "interval": "", + "intervalFactor": 2, + "legendFormat": "Open", + "range": true, + "refId": "B", + "step": 10, + "target": "" + } + ], + "thresholds": [], + "timeRegions": [], + "title": "File Descriptors", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:2718", + "format": "short", + "logBase": 32, + "show": true + }, + { + "$$hashKey": "object:2719", + "format": "short", + "logBase": 1, + "show": true + } + ], + "yaxis": { + "align": false + } + }, + { + "aliasColors": { + "Resident": "#890F02", + "Virtual": "#0A437C", + "Virtual Memory": "#0A437C" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 2, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 9 + }, + "hiddenSeries": false, + "id": 5, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 3, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "9.2.3", + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "process_virtual_memory_bytes{instance=\"$node\"}", + "interval": "", + "intervalFactor": 2, + "legendFormat": "Virtual", + "range": true, + "refId": "A", + "step": 10, + "target": "" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "process_resident_memory_bytes{instance=\"$node\"}", + "interval": "", + "intervalFactor": 2, + "legendFormat": "Resident", + "range": true, + "refId": "B", + "step": 10, + "target": "" + } + ], + "thresholds": [], + "timeRegions": [], + "title": "Memory", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:2803", + "format": "bytes", + "logBase": 1, + "show": true + }, + { + "$$hashKey": "object:2804", + "format": "short", + "logBase": 1, + "show": true + } + ], + "yaxis": { + "align": false + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 16 + }, + "hiddenSeries": false, + "id": 9, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "9.2.3", + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "increase(bind_query_duplicates_total{instance=\"$node\"}[120s])", + "intervalFactor": 2, + "legendFormat": "Duplicates", + "range": true, + "refId": "A", + "step": 4, + "target": "" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "increase(bind_query_errors_total{instance=\"$node\"}[120s])", + "intervalFactor": 2, + "legendFormat": "{{ error }}", + "range": true, + "refId": "B", + "step": 4, + "target": "" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "increase(bind_query_recursions_total{instance=\"$node\"}[120s])", + "intervalFactor": 2, + "legendFormat": "Recursions", + "range": true, + "refId": "C", + "step": 4, + "target": "" + } + ], + "thresholds": [], + "timeRegions": [], + "title": "Queries", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:2888", + "format": "short", + "logBase": 1, + "show": true + }, + { + "$$hashKey": "object:2889", + "format": "short", + "logBase": 1, + "show": true + } + ], + "yaxis": { + "align": false + } + }, + { + "collapsed": false, + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 23 + }, + "id": 21, + "panels": [], + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "refId": "A" + } + ], + "title": "Incoming", + "type": "row" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 24 + }, + "hiddenSeries": false, + "id": 6, + "legend": { + "alignAsTable": true, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "9.2.3", + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "$$hashKey": "object:2973" + } + ], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "increase(bind_incoming_queries_total{instance=\"$node\"}[120s])", + "interval": "", + "intervalFactor": 2, + "legendFormat": "{{ type }}", + "range": true, + "refId": "A", + "step": 10, + "target": "" + } + ], + "thresholds": [], + "timeRegions": [], + "title": "Incoming Queries", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:2978", + "format": "short", + "logBase": 1, + "min": "0", + "show": true + }, + { + "$$hashKey": "object:2979", + "decimals": -1, + "format": "short", + "logBase": 1, + "min": "0", + "show": true + } + ], + "yaxis": { + "align": false + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 24 + }, + "hiddenSeries": false, + "id": 7, + "legend": { + "alignAsTable": true, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "9.2.3", + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "increase(bind_incoming_requests_total{instance=\"$node\"}[120s])", + "intervalFactor": 2, + "legendFormat": "{{ opcode }}", + "range": true, + "refId": "A", + "step": 10, + "target": "" + } + ], + "thresholds": [], + "timeRegions": [], + "title": "Incoming Request Opcodes", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:3065", + "format": "short", + "logBase": 1, + "show": true + }, + { + "$$hashKey": "object:3066", + "format": "short", + "logBase": 1, + "show": true + } + ], + "yaxis": { + "align": false + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 31 + }, + "hiddenSeries": false, + "id": 8, + "legend": { + "alignAsTable": true, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "9.2.3", + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "increase(bind_responses_total{instance=\"$node\"}[120s])", + "intervalFactor": 2, + "legendFormat": "{{ result }}", + "range": true, + "refId": "A", + "step": 4, + "target": "" + } + ], + "thresholds": [], + "timeRegions": [], + "title": "Response Results", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:3152", + "format": "short", + "logBase": 1, + "show": true + }, + { + "$$hashKey": "object:3153", + "format": "short", + "logBase": 1, + "show": true + } + ], + "yaxis": { + "align": false + } + }, + { + "collapsed": false, + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 38 + }, + "id": 23, + "panels": [], + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "refId": "A" + } + ], + "title": "Resolver", + "type": "row" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 39 + }, + "hiddenSeries": false, + "id": 15, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "9.2.3", + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "increase(bind_resolver_response_errors_total{instance=\"$node\"}[120s])", + "intervalFactor": 2, + "legendFormat": "{{ view }} / {{ error }}", + "range": true, + "refId": "A", + "step": 4, + "target": "" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "increase(bind_resolver_response_lame_total{instance=\"$node\"}[120s])", + "intervalFactor": 2, + "legendFormat": "{{ view }} / LAME", + "range": true, + "refId": "B", + "step": 4, + "target": "" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "increase(bind_resolver_response_mismatch_total{instance=\"$node\"}[120s])", + "intervalFactor": 2, + "legendFormat": "{{ view }} / MISMATCH", + "range": true, + "refId": "C", + "step": 4, + "target": "" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "increase(bind_resolver_response_truncated_total{instance=\"$node\"}[120s])", + "intervalFactor": 2, + "legendFormat": "{{ view }} / TRUNCATED", + "range": true, + "refId": "D", + "step": 4, + "target": "" + } + ], + "thresholds": [], + "timeRegions": [], + "title": "Resolver Response Errors", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:3239", + "format": "short", + "logBase": 1, + "show": true + }, + { + "$$hashKey": "object:3240", + "format": "short", + "logBase": 1, + "show": true + } + ], + "yaxis": { + "align": false + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 8, + "x": 0, + "y": 46 + }, + "hiddenSeries": false, + "id": 12, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "9.2.3", + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "increase(bind_resolver_queries_total{instance=\"$node\"}[120s])", + "intervalFactor": 2, + "legendFormat": "{{ view }} / {{ type }}", + "range": true, + "refId": "A", + "step": 10, + "target": "" + } + ], + "thresholds": [], + "timeRegions": [], + "title": "Resolver Queries", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:3490", + "format": "short", + "logBase": 1, + "show": true + }, + { + "$$hashKey": "object:3491", + "format": "short", + "logBase": 1, + "show": true + } + ], + "yaxis": { + "align": false + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 8, + "x": 8, + "y": 46 + }, + "hiddenSeries": false, + "id": 13, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "9.2.3", + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "increase(bind_resolver_query_errors_total{instance=\"$node\"}[120s])", + "intervalFactor": 2, + "legendFormat": "{{ view }} / {{ error }}", + "range": true, + "refId": "A", + "step": 10, + "target": "" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "increase(bind_resolver_query_edns0_errors_total{instance=\"$node\"}[120s])", + "intervalFactor": 2, + "legendFormat": "{{ view }} / EDNS0", + "range": true, + "refId": "B", + "step": 10, + "target": "" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "increase(bind_resolver_query_retries_total{instance=\"$node\"}[120s])", + "intervalFactor": 2, + "legendFormat": "{{ view }} / Retry", + "range": true, + "refId": "C", + "step": 10, + "target": "" + } + ], + "thresholds": [], + "timeRegions": [], + "title": "Query Errors", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:3575", + "format": "short", + "logBase": 1, + "show": true + }, + { + "$$hashKey": "object:3576", + "format": "short", + "logBase": 1, + "show": true + } + ], + "yaxis": { + "align": false + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 8, + "x": 16, + "y": 46 + }, + "hiddenSeries": false, + "id": 14, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "9.2.3", + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "increase(bind_resolver_query_duration_seconds_bucket{instance=\"$node\"}[120s])", + "intervalFactor": 2, + "legendFormat": "{{ view }} / {{ le }}", + "range": true, + "refId": "A", + "step": 10, + "target": "" + } + ], + "thresholds": [], + "timeRegions": [], + "title": "Query By Duration", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:3660", + "format": "short", + "logBase": 1, + "show": true + }, + { + "$$hashKey": "object:3661", + "format": "short", + "logBase": 1, + "show": true + } + ], + "yaxis": { + "align": false + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 53 + }, + "hiddenSeries": false, + "id": 10, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "9.2.3", + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "bind_resolver_cache_rrsets{instance=\"$node\"}", + "intervalFactor": 2, + "legendFormat": "{{ view }} / {{ type }}", + "range": true, + "refId": "A", + "step": 10, + "target": "" + } + ], + "thresholds": [], + "timeRegions": [], + "title": "Resolver Cache RR Sets", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:3745", + "format": "short", + "logBase": 1, + "show": true + }, + { + "$$hashKey": "object:3746", + "format": "short", + "logBase": 1, + "show": true + } + ], + "yaxis": { + "align": false + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 53 + }, + "hiddenSeries": false, + "id": 11, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "9.2.3", + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "increase(bind_resolver_dnssec_validation_errors_total{instance=\"$node\"}[120s])", + "intervalFactor": 2, + "legendFormat": "{{ view }} / ValErr", + "range": true, + "refId": "A", + "step": 10, + "target": "" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "increase(bind_resolver_dnssec_validation_success_total{instance=\"$node\"}[120s])", + "intervalFactor": 2, + "legendFormat": "{{ view }} / {{ result }}", + "range": true, + "refId": "B", + "step": 10, + "target": "" + } + ], + "thresholds": [], + "timeRegions": [], + "title": "DNSSEC Validation", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:3830", + "format": "short", + "logBase": 1, + "show": true + }, + { + "$$hashKey": "object:3831", + "format": "short", + "logBase": 1, + "show": true + } + ], + "yaxis": { + "align": false + } + } + ], + "refresh": "30s", + "schemaVersion": 37, + "style": "dark", + "tags": [ + "bind", + "dns", + "bind-exporter", + "prometheus" + ], + "templating": { + "list": [ + { + "current": { + "selected": false, + "text": "Prometheus", + "value": "Prometheus" + }, + "hide": 0, + "includeAll": false, + "label": "datasource", + "multi": false, + "name": "DS_PROMETHEUS", + "options": [], + "query": "prometheus", + "queryValue": "", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "type": "datasource" + }, + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "definition": "", + "hide": 0, + "includeAll": false, + "label": "Host:", + "multi": false, + "name": "node", + "options": [], + "query": { + "query": "label_values(bind_up, instance)", + "refId": "Prometheus-node-Variable-Query" + }, + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 1, + "tagValuesQuery": "", + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "Bind9", + "uid": "XTqyUORMz", + "version": 5, + "weekStart": "" +} \ No newline at end of file diff --git a/roles/monitoring/prometheus/exporter/bind/defaults/main.yml b/roles/monitoring/prometheus/exporter/bind/defaults/main.yml new file mode 100644 index 00000000..66a6fcc9 --- /dev/null +++ b/roles/monitoring/prometheus/exporter/bind/defaults/main.yml @@ -0,0 +1,9 @@ +--- +# prometheus_exporter_bind_version: + +prometheus_exporter_bind_stats_version: auto + +prometheus_exporter_bind_stats_groups: + - server + - view + - tasks diff --git a/roles/monitoring/prometheus/exporter/bind/handlers/main.yml b/roles/monitoring/prometheus/exporter/bind/handlers/main.yml new file mode 100644 index 00000000..5fa1f04d --- /dev/null +++ b/roles/monitoring/prometheus/exporter/bind/handlers/main.yml @@ -0,0 +1,10 @@ +--- +- name: restart prometheus-bind-exporter + service: + name: prometheus-bind-exporter + state: restarted + +- name: reload nginx + service: + name: nginx + state: reloaded diff --git a/roles/monitoring/prometheus/exporter/bind/tasks/main.yml b/roles/monitoring/prometheus/exporter/bind/tasks/main.yml new file mode 100644 index 00000000..1ac4b8d7 --- /dev/null +++ b/roles/monitoring/prometheus/exporter/bind/tasks/main.yml @@ -0,0 +1,44 @@ +--- +- name: generate apt pin file for exporter-bind package + when: prometheus_exporter_bind_version is defined + copy: + dest: "/etc/apt/preferences.d/prom-exporter-bind.pref" + content: | + Package: prom-exporter-bind + Pin: version {{ prometheus_exporter_bind_version }}-1 + Pin-Priority: 1001 + +- name: remove apt pin file for exporter-bind package + when: prometheus_exporter_bind_version is not defined + file: + path: "/etc/apt/preferences.d/prom-exporter-bind.pref" + state: absent + +- name: install apt packages + apt: + name: "prom-exporter-bind{% if prometheus_exporter_bind_version is defined %}={{ prometheus_exporter_bind_version }}-1{% endif %}" + state: present + allow_downgrade: yes + notify: restart prometheus-bind-exporter + +- name: generate systemd service unit + template: + src: service.j2 + dest: /etc/systemd/system/prometheus-bind-exporter.service + notify: restart prometheus-bind-exporter + +- name: make sure prometheus-bind-exporter is enabled and started + systemd: + name: prometheus-bind-exporter.service + daemon_reload: yes + state: started + enabled: yes + +- name: register exporter + copy: + content: | + location = /bind { + proxy_pass http://127.0.0.1:9119/metrics; + } + dest: /etc/prometheus/exporter/bind.locations + notify: reload nginx diff --git a/roles/monitoring/prometheus/exporter/bind/templates/service.j2 b/roles/monitoring/prometheus/exporter/bind/templates/service.j2 new file mode 100644 index 00000000..853fee18 --- /dev/null +++ b/roles/monitoring/prometheus/exporter/bind/templates/service.j2 @@ -0,0 +1,30 @@ +[Unit] +Description=Prometheus bind exporter + +[Service] +Restart=always +User=prometheus-exporter +ExecStart=/usr/bin/prometheus-bind-exporter --web.listen-address="127.0.0.1:9119" --bind.stats-version="{{ prometheus_exporter_bind_stats_version }}" --bind.stats-groups="{{ prometheus_exporter_bind_stats_groups | join(',') }}" + +# systemd hardening-options +AmbientCapabilities= +CapabilityBoundingSet= +DeviceAllow=/dev/null rw +DevicePolicy=strict +LockPersonality=true +MemoryDenyWriteExecute=true +NoNewPrivileges=true +PrivateDevices=true +PrivateTmp=true +ProtectControlGroups=true +ProtectHome=true +ProtectKernelModules=true +ProtectKernelTunables=true +ProtectSystem=strict +RemoveIPC=true +RestrictNamespaces=true +RestrictRealtime=true +SystemCallArchitectures=native + +[Install] +WantedBy=multi-user.target diff --git a/roles/monitoring/prometheus/exporter/meta/main.yml b/roles/monitoring/prometheus/exporter/meta/main.yml index 704b0f00..3999b608 100644 --- a/roles/monitoring/prometheus/exporter/meta/main.yml +++ b/roles/monitoring/prometheus/exporter/meta/main.yml @@ -15,3 +15,5 @@ dependencies: when: "'ssl' in (prometheus_exporters_default | union(prometheus_exporters_extra))" - role: monitoring/prometheus/exporter/smokeping when: "'smokeping' in (prometheus_exporters_default | union(prometheus_exporters_extra))" + - role: monitoring/prometheus/exporter/bind + when: "'bind' in (prometheus_exporters_default | union(prometheus_exporters_extra))" diff --git a/roles/monitoring/prometheus/server/defaults/main/main.yml b/roles/monitoring/prometheus/server/defaults/main/main.yml index 611b1fef..8aa06d42 100644 --- a/roles/monitoring/prometheus/server/defaults/main/main.yml +++ b/roles/monitoring/prometheus/server/defaults/main/main.yml @@ -28,6 +28,7 @@ prometheus_server_rules: ssl: "{{ prometheus_server_rules_ssl + prometheus_server_rules_ssl_extra }}" ssl/probe: "{{ prometheus_server_rules_ssl__probe + prometheus_server_rules_ssl__probe_extra }}" smokeping: "{{ prometheus_server_rules_smokeping + prometheus_server_rules_smokeping_extra }}" + bind: "{{ prometheus_server_rules_bind + prometheus_server_rules_bind_extra }}" # prometheus_server_alertmanager: # url: "127.0.0.1:9093" diff --git a/roles/monitoring/prometheus/server/defaults/main/rules_bind.yml b/roles/monitoring/prometheus/server/defaults/main/rules_bind.yml new file mode 100644 index 00000000..4c401b9d --- /dev/null +++ b/roles/monitoring/prometheus/server/defaults/main/rules_bind.yml @@ -0,0 +1,11 @@ +--- +prometheus_server_rules_bind_extra: [] +prometheus_server_rules_bind: + - alert: BindStatsUnreachable + expr: bind_up == 0 + for: 0m + labels: + severity: critical + annotations: + summary: Unable to scrape bind stats channel (instance {{ '{{' }} $labels.instance {{ '}}' }}) + description: "The bind process might have crashed.\n VALUE = {{ '{{' }} $value {{ '}}' }}\n LABELS = {{ '{{' }} $labels {{ '}}' }}" diff --git a/roles/network/bind/defaults/main.yml b/roles/network/bind/defaults/main.yml index 80dbe396..7ed9521b 100644 --- a/roles/network/bind/defaults/main.yml +++ b/roles/network/bind/defaults/main.yml @@ -1,4 +1,12 @@ --- +## stats + +# bind_stats_channels: +# - addr: 127.0.0.1 +# port: 8053 +# allow: +# - 127.0.0.1 + ## options # bind_option_empty_zones_enable: yes @@ -9,7 +17,6 @@ # bind_option_also_notify: [] # bind_option_allow_transfer: [] - ## zone configs bind_empty_onion_zone: no diff --git a/roles/network/bind/tasks/main.yml b/roles/network/bind/tasks/main.yml index 2303e76c..49898162 100644 --- a/roles/network/bind/tasks/main.yml +++ b/roles/network/bind/tasks/main.yml @@ -89,6 +89,28 @@ notify: reload bind +- name: add stats configuration + when: bind_stats_channels is defined + template: + src: stats.j2 + dest: /etc/bind/named.conf.stats + notify: reload bind + +- name: remove stats configuration + when: bind_stats_channels is not defined + file: + path: /etc/bind/named.conf.stats + state: absent + notify: reload bind + +- name: enable/disable stats configuration + lineinfile: + path: /etc/bind/named.conf + line: 'include "/etc/bind/named.conf.stats";' + state: "{{ bind_stats_channels is defined | ternary('present', 'absent') }}" + notify: reload bind + + - name: add slave zone configuration when: bind_slave_zones is defined template: diff --git a/roles/network/bind/templates/stats.j2 b/roles/network/bind/templates/stats.j2 new file mode 100644 index 00000000..06a1f514 --- /dev/null +++ b/roles/network/bind/templates/stats.j2 @@ -0,0 +1,7 @@ +// Stats + +statistics-channels { +{% for channel in bind_stats_channels %} + inet {{ channel.addr | default('*') }}{% if 'port' in channel %} port {{ channel.port }}{% endif %}{% if 'allow' in channel %} allow { {{ channel.allow | join('; ') }}; }{% endif %}; +{% endfor %} +}; -- cgit v1.2.3