From 8f6c428305700a0af9ea12004bf32eff1ac0a1ad Mon Sep 17 00:00:00 2001 From: Kaare Hoff Skovgaard Date: Sat, 2 Aug 2025 00:34:01 +0200 Subject: [PATCH] Get some metrics and a dashboard for dovecot --- .../hetzner-instance/default.nix | 10 + .../mailserver/prometheus.nix | 103 +- .../alerts/dovecot.yaml | 10 + .../monitoring.kaareskovgaard.net/default.nix | 58 +- .../dovecot/dovecot_prometheus.json | 1181 +++++++++++++++++ 5 files changed, 1353 insertions(+), 9 deletions(-) create mode 100644 nix/systems/x86_64-linux/monitoring.kaareskovgaard.net/alerts/dovecot.yaml create mode 100644 nix/systems/x86_64-linux/monitoring.kaareskovgaard.net/grafana/dashboards/dovecot/dovecot_prometheus.json diff --git a/nix/modules/nixos/infrastructure/hetzner-instance/default.nix b/nix/modules/nixos/infrastructure/hetzner-instance/default.nix index ba6f223..55d0d39 100644 --- a/nix/modules/nixos/infrastructure/hetzner-instance/default.nix +++ b/nix/modules/nixos/infrastructure/hetzner-instance/default.nix @@ -81,6 +81,16 @@ let ]; description = "dns"; } + { + direction = "out"; + protocol = "udp"; + port = 123; + destination_ips = [ + "0.0.0.0/0" + "::/0" + ]; + description = "ntp"; + } { direction = "out"; protocol = "tcp"; diff --git a/nix/systems/aarch64-linux/mx.kaareskovgaard.net/mailserver/prometheus.nix b/nix/systems/aarch64-linux/mx.kaareskovgaard.net/mailserver/prometheus.nix index b6e2717..5b8b7dd 100644 --- a/nix/systems/aarch64-linux/mx.kaareskovgaard.net/mailserver/prometheus.nix +++ b/nix/systems/aarch64-linux/mx.kaareskovgaard.net/mailserver/prometheus.nix @@ -1,9 +1,108 @@ +let + dovecotPromPort = 9900; +in { config = { - services.prometheus.exporters.postfix = { enable = true; }; - khscodes.infrastructure.vault-prometheus-sender.exporters.enabled = [ "postfix" ]; + khscodes.infrastructure.vault-prometheus-sender.exporters.enabled = [ + "postfix" + ]; + # From https://alfaexploit.com/en/posts/monitoring_dovecot_with_prometheus/ + services.dovecot2.extraConfig = '' + ## + ## Statistics and metrics + ## + + # Dovecot supports gathering statistics from events. + # Currently there are no statistics logged by default, and therefore they must + # be explicitly added using the metric configuration blocks. + # + # Unlike old stats, the new statistics do not require any plugins loaded. + # + # See https://doc.dovecot.org/configuration_manual/stats/ for more details. + + ## + ## Example metrics + ## + + metric auth_success { + filter = event=auth_request_finished AND success=yes + } + + metric auth_failures { + filter = event=auth_request_finished AND NOT success=yes + } + + metric imap_command { + filter = event=imap_command_finished + group_by = cmd_name tagged_reply_state + } + + metric smtp_command { + filter = event=smtp_server_command_finished + group_by = cmd_name status_code duration:exponential:1:5:10 + } + + metric mail_delivery { + filter = event=mail_delivery_finished + group_by = duration:exponential:1:5:10 + } + + ## + ## Prometheus + ## + + # To allow access to statistics with Prometheus, enable http listener + # on stats process. Stats will be available on /metrics path. + # + # See https://doc.dovecot.org/configuration_manual/stats/openmetrics/ for more + # details. + + service stats { + inet_listener http { + port = ${toString dovecotPromPort} + } + } + + ## + ## Event exporting + ## + + # You can also export individual events. + # + # See https://doc.dovecot.org/configuration_manual/event_export/ for more + # details. + + #event_exporter log { + # format = json + # format_args = time-rfc3339 + # transport = log + #} + # + #metric imap_commands { + # exporter = log + # filter = event=imap_command_finished + #} + ''; + + khscodes.infrastructure.vault-prometheus-sender.exporters.external = [ "dovecot" ]; + environment.etc."alloy/dovecot_prometheus.alloy" = { + text = '' + prometheus.scrape "dovecot_exporter" { + scrape_interval = "1m" + targets = [ + { + "__address__" = "127.0.0.1:${toString dovecotPromPort}", + "instance" = constants.hostname, + "job" = "dovecot", + }, + ] + metrics_path = "/metrics" + forward_to = [otelcol.receiver.prometheus.default.receiver] + } + ''; + }; }; } diff --git a/nix/systems/x86_64-linux/monitoring.kaareskovgaard.net/alerts/dovecot.yaml b/nix/systems/x86_64-linux/monitoring.kaareskovgaard.net/alerts/dovecot.yaml new file mode 100644 index 0000000..2173c9a --- /dev/null +++ b/nix/systems/x86_64-linux/monitoring.kaareskovgaard.net/alerts/dovecot.yaml @@ -0,0 +1,10 @@ +- name: Dovecot + rules: + - alert: DovecotDown + expr: > + dovecot_up{job="dovecot"} == 0 + for: 10m + labels: + severity: critical + annotations: + summary: "Dovecot on {{ $labels.instance }} is down" diff --git a/nix/systems/x86_64-linux/monitoring.kaareskovgaard.net/default.nix b/nix/systems/x86_64-linux/monitoring.kaareskovgaard.net/default.nix index e9fc525..4e6b0e2 100644 --- a/nix/systems/x86_64-linux/monitoring.kaareskovgaard.net/default.nix +++ b/nix/systems/x86_64-linux/monitoring.kaareskovgaard.net/default.nix @@ -10,19 +10,58 @@ let loki = config.services.loki; prometheus = config.services.prometheus; nginxExporterSrc = "${pkgs.prometheus-nginx-exporter.src}/grafana/dashboard.json"; + promDataSource = { + current = { }; + includeAll = false; + label = "Datasource"; + name = "DS_PROMETHEUS"; + options = [ ]; + query = "prometheus"; + refresh = 1; + regex = ""; + type = "datasource"; + }; + srcName = src: if lib.isPath src then builtins.baseNameOf src else src.name; + patchPrometheusTemplatingDataSource = + src: + let + name = srcName src; + in + pkgs.stdenvNoCC.mkDerivation { + inherit src; + name = "patched-${name}"; + dontUnpack = true; + buildPhase = '' + cat ${src} | ${lib.getExe pkgs.jq} --raw-output --argjson src ${lib.escapeShellArg (builtins.toJSON promDataSource)} '.templating.list = [$src] + .templating.list' > ${lib.escapeShellArg name} + ''; + installPhase = '' + mv ${lib.escapeShellArg name} $out + ''; + }; postgresqlDashboard = pkgs.fetchurl { url = "https://grafana.com/api/dashboards/9628/revisions/8/download"; hash = "sha256-UhusNAZbyt7fJV/DhFUK4FKOmnTpG0R15YO2r+nDnMc="; + name = "postgresql.json"; }; - postfixDashboard = pkgs.fetchurl { - url = "https://grafana.com/api/dashboards/10013/revisions/2/download"; - hash = "sha256-SIKL1V+sJ5F7vPOwp/LuOjrGm8nCsscEX8LcLFMotfc="; - }; + postfixDashboard = patchPrometheusTemplatingDataSource ( + pkgs.fetchurl { + url = "https://grafana.com/api/dashboards/10013/revisions/2/download"; + hash = "sha256-SIKL1V+sJ5F7vPOwp/LuOjrGm8nCsscEX8LcLFMotfc="; + name = "postfix.json"; + } + ); + + oauthCredentialFile = config.khscodes.infrastructure.kanidm-client-application.secretFile; in { imports = [ "${inputs.self}/nix/profiles/nixos/khs-openstack-server.nix" ]; + systemd.services.grafana = { + unitConfig.ConditionPathExists = [ + oauthCredentialFile + ]; + }; services.grafana = { enable = true; settings = { @@ -53,7 +92,7 @@ in token_url = "https://login.kaareskovgaard.net/oauth2/token"; api_url = "https://login.kaareskovgaard.net/oauth2/openid/monitoring/userinfo"; client_id = "monitoring"; - client_secret = "$__file{${config.khscodes.infrastructure.kanidm-client-application.secretFile}}"; + client_secret = "$__file{${oauthCredentialFile}}"; scopes = "openid profile email"; use_pkce = true; skip_org_role_sync = false; @@ -81,13 +120,13 @@ in { url = "http://${loki.configuration.server.http_listen_address}:${toString loki.configuration.server.http_listen_port}"; type = "loki"; - name = "Logs"; + name = "Loki"; uid = "loki"; } { url = "http://${prometheus.listenAddress}:${toString prometheus.port}"; type = "prometheus"; - name = "Metrics"; + name = "Prometheus"; uid = "prometheus"; jsonData = { manageAlerts = true; @@ -99,6 +138,10 @@ in name = "Node Exporter"; options.path = ./grafana/dashboards/node_exporter; } + { + name = "Dovecot"; + options.path = patchPrometheusTemplatingDataSource ./grafana/dashboards/dovecot/dovecot_prometheus.json; + } { name = "Nginx"; options.path = nginxExporterSrc; @@ -127,6 +170,7 @@ in ${builtins.readFile ./alerts/postfix.yaml} ${builtins.readFile ./alerts/postgres.yaml} ${builtins.readFile ./alerts/systemd.yaml} + ${builtins.readFile ./alerts/dovecot.yaml} ${import ./alerts/job_up.nix { inherit inputs lib; }} '' ]; diff --git a/nix/systems/x86_64-linux/monitoring.kaareskovgaard.net/grafana/dashboards/dovecot/dovecot_prometheus.json b/nix/systems/x86_64-linux/monitoring.kaareskovgaard.net/grafana/dashboards/dovecot/dovecot_prometheus.json new file mode 100644 index 0000000..ff03a98 --- /dev/null +++ b/nix/systems/x86_64-linux/monitoring.kaareskovgaard.net/grafana/dashboards/dovecot/dovecot_prometheus.json @@ -0,0 +1,1181 @@ +{ + "__inputs": [ + { + "name": "DS_PROMETHEUS", + "label": "prometheus", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "__elements": {}, + "__requires": [ + { + "type": "panel", + "id": "bargauge", + "name": "Bar gauge", + "version": "" + }, + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "9.5.5" + }, + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "1.0.0" + }, + { + "type": "panel", + "id": "stat", + "name": "Stat", + "version": "" + }, + { + "type": "panel", + "id": "timeseries", + "name": "Time series", + "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" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": null, + "links": [], + "liveNow": false, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "description": "Dovecot version", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 0, + "y": 0 + }, + "id": 2, + "interval": "1m", + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "name" + }, + "pluginVersion": "9.5.5", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "dovecot_build_info", + "instant": true, + "interval": "", + "legendFormat": "{{version}}", + "refId": "A" + } + ], + "title": "Dovecot version", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "description": "Dovecot Auth Stats", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Failed Auth" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 10, + "x": 4, + "y": 0 + }, + "id": 4, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "exemplar": true, + "expr": "dovecot_auth_success_total{instance=\"$instance\"} - dovecot_auth_success_total{instance=\"$instance\"} offset $__interval", + "interval": "$__interval", + "legendFormat": "Success Auth", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "exemplar": true, + "expr": "dovecot_auth_failures_total{instance=\"$instance\"} - dovecot_auth_failures_total{instance=\"$instance\"} offset $__interval", + "hide": false, + "interval": "$__interval", + "legendFormat": "Failed Auth", + "refId": "B" + } + ], + "title": "Auth Stats", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "description": "Dovecot Auth Stats Duration", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "s" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Auth Success Duration" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-orange", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Auth Failure Duration" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-purple", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 10, + "x": 14, + "y": 0 + }, + "id": 6, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "exemplar": true, + "expr": "dovecot_auth_success_duration_seconds_total{instance=\"$instance\"} - dovecot_auth_success_duration_seconds_total{instance=\"$instance\"} offset $__interval", + "interval": "$__interval", + "legendFormat": "Auth Success Duration", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "exemplar": true, + "expr": "dovecot_auth_failures_duration_seconds_total{instance=\"$instance\"} - dovecot_auth_failures_duration_seconds_total{instance=\"$instance\"} offset $__interval", + "hide": false, + "interval": "$__interval", + "legendFormat": "Auth Failure Duration", + "refId": "B" + } + ], + "title": "Auth Stats Duration", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "description": "Dovecot IMAP Command Stats", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 6 + }, + "id": 8, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "exemplar": true, + "expr": "dovecot_imap_command_total{instance=\"$instance\"} - dovecot_imap_command_total{instance=\"$instance\"} offset $__interval", + "interval": "$__interval", + "legendFormat": "{{cmd_name}}{{tagged_reply_state}}", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "exemplar": true, + "expr": "dovecot_imap_command_count{instance=\"$instance\"} - dovecot_imap_command_count{instance=\"$instance\"} offset $__interval", + "hide": false, + "interval": "$__interval", + "legendFormat": "All Commands", + "refId": "B" + } + ], + "title": "IMAP Command Stats", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "description": "Dovecot IMAP Command Stats Duration", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "s" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "All commands" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#b20d5f", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 6 + }, + "id": 10, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "exemplar": true, + "expr": "dovecot_imap_command_duration_seconds_total{instance=\"$instance\"} - dovecot_imap_command_duration_seconds_total{instance=\"$instance\"} offset $__interval", + "interval": "$__interval", + "legendFormat": "{{cmd_name}}{{tagged_reply_state}}", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "exemplar": true, + "expr": "dovecot_imap_command_duration_seconds_sum{instance=\"$instance\"} - dovecot_imap_command_duration_seconds_sum{instance=\"$instance\"} offset $__interval", + "hide": false, + "interval": "$__interval", + "legendFormat": "All commands", + "refId": "B" + } + ], + "title": "IMAP Command Stats Duration", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "description": "Dovecot SMTP Commands Histogram", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 14 + }, + "id": 14, + "options": { + "displayMode": "gradient", + "minVizHeight": 10, + "minVizWidth": 0, + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showUnfilled": true, + "text": {}, + "valueMode": "color" + }, + "pluginVersion": "9.5.5", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "exemplar": true, + "expr": "dovecot_smtp_command_bucket{instance=\"$instance\"}", + "interval": "", + "legendFormat": "{{cmn_name}}{{le}}{{status_code}}", + "refId": "A" + } + ], + "title": "SMTP Commands Histogram", + "type": "bargauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "description": "Dovecot SMTP Mail Delivery Histogram", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 14 + }, + "id": 12, + "options": { + "displayMode": "gradient", + "minVizHeight": 10, + "minVizWidth": 0, + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showUnfilled": true, + "text": {}, + "valueMode": "color" + }, + "pluginVersion": "9.5.5", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "exemplar": true, + "expr": "dovecot_mail_delivery_bucket{instance=\"$instance\"}", + "format": "time_series", + "instant": false, + "interval": "", + "legendFormat": "{{le}}", + "refId": "A" + } + ], + "title": "SMTP Mail Delivery Histogram", + "type": "bargauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "description": "Dovecot SMTP Command Count", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 22 + }, + "id": 16, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "exemplar": true, + "expr": "dovecot_smtp_command_count{instance=\"$instance\"} - dovecot_smtp_command_count{instance=\"$instance\"} offset $__interval", + "interval": "$__interval", + "legendFormat": "{{cmd_name}}{{status_code}}", + "refId": "A" + } + ], + "title": "SMTP Command Count", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "description": "Dovecot SMTP Command Sum", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 22 + }, + "id": 18, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "exemplar": true, + "expr": "dovecot_smtp_command_sum{instance=\"$instance\"} - dovecot_smtp_command_sum{instance=\"$instance\"} offset $__interval", + "interval": "$__interval", + "legendFormat": "{{cmd_name}}{{status_code}}", + "refId": "A" + } + ], + "title": "SMTP Command Sum", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "description": "Dovecot Mail Delivery Count", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 30 + }, + "id": 20, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "exemplar": true, + "expr": "dovecot_mail_delivery_count{instance=\"$instance\"} - dovecot_mail_delivery_count{instance=\"$instance\"} offset $__interval", + "interval": "$__interval", + "legendFormat": "Mail Delivery Count", + "refId": "A" + } + ], + "title": "Mail Delivery Count", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "description": "Dovecot Mail Delivery Sum", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Mail Delivery Sum" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "semi-dark-blue", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 30 + }, + "id": 22, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "exemplar": true, + "expr": "dovecot_mail_delivery_sum{instance=\"$instance\"} - dovecot_mail_delivery_sum{instance=\"$instance\"} offset $__interval", + "interval": "$__interval", + "legendFormat": "Mail Delivery Sum", + "refId": "A" + } + ], + "title": "Mail Delivery Sum", + "type": "timeseries" + } + ], + "refresh": "5s", + "schemaVersion": 38, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "definition": "label_values(dovecot_build_info, instance)", + "hide": 0, + "includeAll": false, + "label": "Instance", + "multi": false, + "name": "instance", + "options": [], + "query": { + "query": "label_values(dovecot_build_info, instance)", + "refId": "StandardVariableQuery" + }, + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "type": "query" + } + ] + }, + "time": { + "from": "now-5m", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "Dovecot Stats", + "uid": "tpteP2Onsdt", + "version": 1, + "weekStart": "" +}