From 5fcff4fc8aee149c532e11741bc77825e1f898ce Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Tue, 6 Jan 2026 02:34:52 -0300 Subject: [PATCH] monitoring: refine mail overview panels --- scripts/dashboards_render_atlas.py | 129 ++++--- .../monitoring/dashboards/atlas-overview.json | 324 ++++++++++-------- .../grafana-dashboard-overview.yaml | 324 ++++++++++-------- 3 files changed, 432 insertions(+), 345 deletions(-) diff --git a/scripts/dashboards_render_atlas.py b/scripts/dashboards_render_atlas.py index 3cc9cb7..0dcd5dd 100644 --- a/scripts/dashboards_render_atlas.py +++ b/scripts/dashboards_render_atlas.py @@ -926,15 +926,6 @@ def build_overview(): {"color": "red", "value": 10}, ], } - mail_bounce_count_thresholds = { - "mode": "absolute", - "steps": [ - {"color": "green", "value": None}, - {"color": "yellow", "value": 1}, - {"color": "orange", "value": 10}, - {"color": "red", "value": 100}, - ], - } mail_limit_thresholds = { "mode": "absolute", "steps": [ @@ -944,56 +935,96 @@ def build_overview(): {"color": "red", "value": 95}, ], } - mail_api_thresholds = { + mail_success_thresholds = { "mode": "absolute", "steps": [ {"color": "red", "value": None}, - {"color": "green", "value": 1}, + {"color": "orange", "value": 90}, + {"color": "yellow", "value": 95}, + {"color": "green", "value": 98}, ], } - mail_overview_panels = [ - ( + panels.append( + stat_panel( 30, - "Mail Bounce Rate (1d)", - 'max(postmark_outbound_bounce_rate{window="1d"})', - "percent", - mail_bounce_rate_thresholds, - ), - ( - 31, - "Mail Bounced (1d)", - 'max(postmark_outbound_bounced{window="1d"})', - "none", - mail_bounce_count_thresholds, - ), - ( + "Mail Sent (1d)", + 'max(postmark_outbound_sent{window="1d"})', + {"h": 2, "w": 6, "x": 0, "y": 8}, + unit="none", + links=link_to("atlas-mail"), + ) + ) + panels.append( + { + "id": 31, + "type": "stat", + "title": "Mail Bounces (1d)", + "datasource": PROM_DS, + "gridPos": {"h": 2, "w": 6, "x": 6, "y": 8}, + "targets": [ + { + "expr": 'max(postmark_outbound_bounce_rate{window="1d"})', + "refId": "A", + "legendFormat": "Rate", + }, + { + "expr": 'max(postmark_outbound_bounced{window="1d"})', + "refId": "B", + "legendFormat": "Count", + }, + ], + "fieldConfig": { + "defaults": { + "color": {"mode": "thresholds"}, + "custom": {"displayMode": "auto"}, + "thresholds": mail_bounce_rate_thresholds, + "unit": "none", + }, + "overrides": [ + { + "matcher": {"id": "byName", "options": "Rate"}, + "properties": [{"id": "unit", "value": "percent"}], + }, + { + "matcher": {"id": "byName", "options": "Count"}, + "properties": [{"id": "unit", "value": "none"}], + }, + ], + }, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "center", + "reduceOptions": {"calcs": ["lastNotNull"], "fields": "", "values": False}, + "textMode": "name_and_value", + }, + "links": link_to("atlas-mail"), + } + ) + panels.append( + stat_panel( 32, + "Mail Success Rate (1d)", + 'clamp_min(100 - max(postmark_outbound_bounce_rate{window="1d"}), 0)', + {"h": 2, "w": 6, "x": 12, "y": 8}, + unit="percent", + thresholds=mail_success_thresholds, + decimals=1, + links=link_to("atlas-mail"), + ) + ) + panels.append( + stat_panel( + 33, "Mail Limit Used (30d)", "max(postmark_sending_limit_used_percent)", - "percent", - mail_limit_thresholds, - ), - ( - 33, - "Postmark API Up", - "max(postmark_api_up)", - "none", - mail_api_thresholds, - ), - ] - for idx, (panel_id, title, expr, unit, thresholds) in enumerate(mail_overview_panels): - panels.append( - stat_panel( - panel_id, - title, - expr, - {"h": 2, "w": 6, "x": 6 * idx, "y": 8}, - unit=unit, - thresholds=thresholds, - decimals=1 if unit == "percent" else 0, - links=link_to("atlas-mail"), - ) + {"h": 2, "w": 6, "x": 18, "y": 8}, + unit="percent", + thresholds=mail_limit_thresholds, + decimals=1, + links=link_to("atlas-mail"), ) + ) storage_panels = [ (23, "Astreae Usage", astreae_usage_expr("/mnt/astreae"), "percent"), diff --git a/services/monitoring/dashboards/atlas-overview.json b/services/monitoring/dashboards/atlas-overview.json index 707cc30..957a6ed 100644 --- a/services/monitoring/dashboards/atlas-overview.json +++ b/services/monitoring/dashboards/atlas-overview.json @@ -789,7 +789,7 @@ { "id": 30, "type": "stat", - "title": "Mail Bounce Rate (1d)", + "title": "Mail Sent (1d)", "datasource": { "type": "prometheus", "uid": "atlas-vm" @@ -802,7 +802,7 @@ }, "targets": [ { - "expr": "max(postmark_outbound_bounce_rate{window=\"1d\"})", + "expr": "max(postmark_outbound_sent{window=\"1d\"})", "refId": "A" } ], @@ -812,6 +812,81 @@ "mode": "thresholds" }, "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "rgba(115, 115, 115, 1)", + "value": null + }, + { + "color": "green", + "value": 1 + } + ] + }, + "unit": "none", + "custom": { + "displayMode": "auto" + } + }, + "overrides": [] + }, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "center", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "value" + }, + "links": [ + { + "title": "Open atlas-mail dashboard", + "url": "/d/atlas-mail", + "targetBlank": true + } + ] + }, + { + "id": 31, + "type": "stat", + "title": "Mail Bounces (1d)", + "datasource": { + "type": "prometheus", + "uid": "atlas-vm" + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 6, + "y": 8 + }, + "targets": [ + { + "expr": "max(postmark_outbound_bounce_rate{window=\"1d\"})", + "refId": "A", + "legendFormat": "Rate" + }, + { + "expr": "max(postmark_outbound_bounced{window=\"1d\"})", + "refId": "B", + "legendFormat": "Count" + } + ], + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "displayMode": "auto" + }, "thresholds": { "mode": "absolute", "steps": [ @@ -833,6 +908,103 @@ } ] }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Rate" + }, + "properties": [ + { + "id": "unit", + "value": "percent" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Count" + }, + "properties": [ + { + "id": "unit", + "value": "none" + } + ] + } + ] + }, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "center", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "name_and_value" + }, + "links": [ + { + "title": "Open atlas-mail dashboard", + "url": "/d/atlas-mail", + "targetBlank": true + } + ] + }, + { + "id": 32, + "type": "stat", + "title": "Mail Success Rate (1d)", + "datasource": { + "type": "prometheus", + "uid": "atlas-vm" + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 12, + "y": 8 + }, + "targets": [ + { + "expr": "clamp_min(100 - max(postmark_outbound_bounce_rate{window=\"1d\"}), 0)", + "refId": "A" + } + ], + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "orange", + "value": 90 + }, + { + "color": "yellow", + "value": 95 + }, + { + "color": "green", + "value": 98 + } + ] + }, "unit": "percent", "custom": { "displayMode": "auto" @@ -863,83 +1035,7 @@ ] }, { - "id": 31, - "type": "stat", - "title": "Mail Bounced (1d)", - "datasource": { - "type": "prometheus", - "uid": "atlas-vm" - }, - "gridPos": { - "h": 2, - "w": 6, - "x": 6, - "y": 8 - }, - "targets": [ - { - "expr": "max(postmark_outbound_bounced{window=\"1d\"})", - "refId": "A" - } - ], - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "yellow", - "value": 1 - }, - { - "color": "orange", - "value": 10 - }, - { - "color": "red", - "value": 100 - } - ] - }, - "unit": "none", - "custom": { - "displayMode": "auto" - }, - "decimals": 0 - }, - "overrides": [] - }, - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "center", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "value" - }, - "links": [ - { - "title": "Open atlas-mail dashboard", - "url": "/d/atlas-mail", - "targetBlank": true - } - ] - }, - { - "id": 32, + "id": 33, "type": "stat", "title": "Mail Limit Used (30d)", "datasource": { @@ -949,7 +1045,7 @@ "gridPos": { "h": 2, "w": 6, - "x": 12, + "x": 18, "y": 8 }, "targets": [ @@ -1014,74 +1110,6 @@ } ] }, - { - "id": 33, - "type": "stat", - "title": "Postmark API Up", - "datasource": { - "type": "prometheus", - "uid": "atlas-vm" - }, - "gridPos": { - "h": 2, - "w": 6, - "x": 18, - "y": 8 - }, - "targets": [ - { - "expr": "max(postmark_api_up)", - "refId": "A" - } - ], - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "red", - "value": null - }, - { - "color": "green", - "value": 1 - } - ] - }, - "unit": "none", - "custom": { - "displayMode": "auto" - }, - "decimals": 0 - }, - "overrides": [] - }, - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "center", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "value" - }, - "links": [ - { - "title": "Open atlas-mail dashboard", - "url": "/d/atlas-mail", - "targetBlank": true - } - ] - }, { "id": 23, "type": "stat", diff --git a/services/monitoring/grafana-dashboard-overview.yaml b/services/monitoring/grafana-dashboard-overview.yaml index 65ae053..cccde73 100644 --- a/services/monitoring/grafana-dashboard-overview.yaml +++ b/services/monitoring/grafana-dashboard-overview.yaml @@ -798,7 +798,7 @@ data: { "id": 30, "type": "stat", - "title": "Mail Bounce Rate (1d)", + "title": "Mail Sent (1d)", "datasource": { "type": "prometheus", "uid": "atlas-vm" @@ -811,7 +811,7 @@ data: }, "targets": [ { - "expr": "max(postmark_outbound_bounce_rate{window=\"1d\"})", + "expr": "max(postmark_outbound_sent{window=\"1d\"})", "refId": "A" } ], @@ -821,6 +821,81 @@ data: "mode": "thresholds" }, "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "rgba(115, 115, 115, 1)", + "value": null + }, + { + "color": "green", + "value": 1 + } + ] + }, + "unit": "none", + "custom": { + "displayMode": "auto" + } + }, + "overrides": [] + }, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "center", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "value" + }, + "links": [ + { + "title": "Open atlas-mail dashboard", + "url": "/d/atlas-mail", + "targetBlank": true + } + ] + }, + { + "id": 31, + "type": "stat", + "title": "Mail Bounces (1d)", + "datasource": { + "type": "prometheus", + "uid": "atlas-vm" + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 6, + "y": 8 + }, + "targets": [ + { + "expr": "max(postmark_outbound_bounce_rate{window=\"1d\"})", + "refId": "A", + "legendFormat": "Rate" + }, + { + "expr": "max(postmark_outbound_bounced{window=\"1d\"})", + "refId": "B", + "legendFormat": "Count" + } + ], + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "displayMode": "auto" + }, "thresholds": { "mode": "absolute", "steps": [ @@ -842,6 +917,103 @@ data: } ] }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Rate" + }, + "properties": [ + { + "id": "unit", + "value": "percent" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Count" + }, + "properties": [ + { + "id": "unit", + "value": "none" + } + ] + } + ] + }, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "center", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "name_and_value" + }, + "links": [ + { + "title": "Open atlas-mail dashboard", + "url": "/d/atlas-mail", + "targetBlank": true + } + ] + }, + { + "id": 32, + "type": "stat", + "title": "Mail Success Rate (1d)", + "datasource": { + "type": "prometheus", + "uid": "atlas-vm" + }, + "gridPos": { + "h": 2, + "w": 6, + "x": 12, + "y": 8 + }, + "targets": [ + { + "expr": "clamp_min(100 - max(postmark_outbound_bounce_rate{window=\"1d\"}), 0)", + "refId": "A" + } + ], + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "orange", + "value": 90 + }, + { + "color": "yellow", + "value": 95 + }, + { + "color": "green", + "value": 98 + } + ] + }, "unit": "percent", "custom": { "displayMode": "auto" @@ -872,83 +1044,7 @@ data: ] }, { - "id": 31, - "type": "stat", - "title": "Mail Bounced (1d)", - "datasource": { - "type": "prometheus", - "uid": "atlas-vm" - }, - "gridPos": { - "h": 2, - "w": 6, - "x": 6, - "y": 8 - }, - "targets": [ - { - "expr": "max(postmark_outbound_bounced{window=\"1d\"})", - "refId": "A" - } - ], - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "yellow", - "value": 1 - }, - { - "color": "orange", - "value": 10 - }, - { - "color": "red", - "value": 100 - } - ] - }, - "unit": "none", - "custom": { - "displayMode": "auto" - }, - "decimals": 0 - }, - "overrides": [] - }, - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "center", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "value" - }, - "links": [ - { - "title": "Open atlas-mail dashboard", - "url": "/d/atlas-mail", - "targetBlank": true - } - ] - }, - { - "id": 32, + "id": 33, "type": "stat", "title": "Mail Limit Used (30d)", "datasource": { @@ -958,7 +1054,7 @@ data: "gridPos": { "h": 2, "w": 6, - "x": 12, + "x": 18, "y": 8 }, "targets": [ @@ -1023,74 +1119,6 @@ data: } ] }, - { - "id": 33, - "type": "stat", - "title": "Postmark API Up", - "datasource": { - "type": "prometheus", - "uid": "atlas-vm" - }, - "gridPos": { - "h": 2, - "w": 6, - "x": 18, - "y": 8 - }, - "targets": [ - { - "expr": "max(postmark_api_up)", - "refId": "A" - } - ], - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "red", - "value": null - }, - { - "color": "green", - "value": 1 - } - ] - }, - "unit": "none", - "custom": { - "displayMode": "auto" - }, - "decimals": 0 - }, - "overrides": [] - }, - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "center", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "value" - }, - "links": [ - { - "title": "Open atlas-mail dashboard", - "url": "/d/atlas-mail", - "targetBlank": true - } - ] - }, { "id": 23, "type": "stat",