From 4611f1308ae29a6e86b32fa397a7aa54d9265b75 Mon Sep 17 00:00:00 2001 From: fryorcraken <110212804+fryorcraken@users.noreply.github.com> Date: Sat, 3 Feb 2024 01:52:33 +1100 Subject: [PATCH] Add Postgres Dashboards using Prometheus source (#40) --- .../dashboards/nwaku-monitoring.json | 149 +++++++++++++++--- .../configuration/pg-exporter-queries.yml | 10 ++ 2 files changed, 133 insertions(+), 26 deletions(-) diff --git a/monitoring/configuration/dashboards/nwaku-monitoring.json b/monitoring/configuration/dashboards/nwaku-monitoring.json index 08e5bd6..3cf424b 100644 --- a/monitoring/configuration/dashboards/nwaku-monitoring.json +++ b/monitoring/configuration/dashboards/nwaku-monitoring.json @@ -2649,7 +2649,7 @@ } ] }, - "unit": "short" + "unit": "none" }, "overrides": [] }, @@ -2911,13 +2911,110 @@ ], "type": "table" }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "description": "Number of messages currently stored in the database", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": 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 + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 9, + "x": 0, + "y": 77 + }, + "id": 146, + "options": { + "legend": { + "calcs": [ + "last" + ], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "editorMode": "code", + "exemplar": false, + "expr": "pg_tb_messages_count{}", + "instant": false, + "interval": "", + "legendFormat": "messages", + "range": true, + "refId": "A" + } + ], + "title": "Unique stored messages (Postgres)", + "type": "timeseries" + }, { "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, - "y": 77 + "y": 84 }, "id": 46, "panels": [], @@ -2956,7 +3053,7 @@ "h": 3, "w": 4, "x": 0, - "y": 78 + "y": 85 }, "id": 11, "links": [], @@ -3068,7 +3165,7 @@ "h": 3, "w": 4, "x": 4, - "y": 78 + "y": 85 }, "id": 14, "interval": "", @@ -3182,7 +3279,7 @@ "h": 3, "w": 4, "x": 8, - "y": 78 + "y": 85 }, "id": 93, "links": [], @@ -3295,7 +3392,7 @@ "h": 3, "w": 4, "x": 12, - "y": 78 + "y": 85 }, "id": 102, "links": [], @@ -3406,7 +3503,7 @@ "h": 3, "w": 4, "x": 16, - "y": 78 + "y": 85 }, "id": 37, "links": [], @@ -3517,7 +3614,7 @@ "h": 3, "w": 4, "x": 20, - "y": 78 + "y": 85 }, "id": 84, "links": [], @@ -3594,7 +3691,7 @@ "h": 7, "w": 3, "x": 0, - "y": 81 + "y": 88 }, "id": 140, "libraryPanel": { @@ -3645,7 +3742,7 @@ "h": 7, "w": 3, "x": 3, - "y": 81 + "y": 88 }, "id": 16, "links": [], @@ -3716,7 +3813,7 @@ "h": 7, "w": 3, "x": 6, - "y": 81 + "y": 88 }, "id": 9, "links": [], @@ -3787,7 +3884,7 @@ "h": 7, "w": 3, "x": 9, - "y": 81 + "y": 88 }, "id": 15, "links": [], @@ -3857,7 +3954,7 @@ "h": 3, "w": 4, "x": 12, - "y": 81 + "y": 88 }, "id": 23, "links": [], @@ -3955,7 +4052,7 @@ "h": 3, "w": 4, "x": 16, - "y": 81 + "y": 88 }, "id": 125, "options": { @@ -4055,7 +4152,7 @@ "h": 8, "w": 12, "x": 12, - "y": 84 + "y": 91 }, "id": 142, "options": { @@ -4131,7 +4228,7 @@ "h": 9, "w": 12, "x": 0, - "y": 88 + "y": 95 }, "hiddenSeries": false, "id": 24, @@ -4215,7 +4312,7 @@ "h": 8, "w": 12, "x": 12, - "y": 92 + "y": 99 }, "id": 145, "libraryPanel": { @@ -4244,7 +4341,7 @@ "h": 9, "w": 12, "x": 0, - "y": 97 + "y": 104 }, "hiddenSeries": false, "id": 122, @@ -4342,7 +4439,7 @@ "h": 9, "w": 12, "x": 12, - "y": 100 + "y": 107 }, "hiddenSeries": false, "id": 121, @@ -4440,7 +4537,7 @@ "h": 9, "w": 12, "x": 0, - "y": 106 + "y": 113 }, "hiddenSeries": false, "id": 26, @@ -4534,7 +4631,7 @@ "h": 9, "w": 12, "x": 12, - "y": 109 + "y": 116 }, "hiddenSeries": false, "id": 27, @@ -4635,7 +4732,7 @@ "h": 10, "w": 12, "x": 0, - "y": 115 + "y": 122 }, "hiddenSeries": false, "id": 123, @@ -4726,7 +4823,7 @@ "h": 9, "w": 12, "x": 12, - "y": 118 + "y": 125 }, "hiddenSeries": false, "id": 111, @@ -4821,7 +4918,7 @@ "h": 10, "w": 12, "x": 0, - "y": 125 + "y": 132 }, "hiddenSeries": false, "id": 120, @@ -4912,7 +5009,7 @@ "h": 5, "w": 12, "x": 12, - "y": 127 + "y": 134 }, "hiddenSeries": false, "id": 30, @@ -5008,7 +5105,7 @@ "h": 5, "w": 12, "x": 12, - "y": 132 + "y": 139 }, "hiddenSeries": false, "id": 31, diff --git a/monitoring/configuration/pg-exporter-queries.yml b/monitoring/configuration/pg-exporter-queries.yml index 5b65a1b..bb1d732 100644 --- a/monitoring/configuration/pg-exporter-queries.yml +++ b/monitoring/configuration/pg-exporter-queries.yml @@ -272,3 +272,13 @@ pg_tb_stats: - messages: usage: "GAUGE" description: "Number of messages for the given pubsub topic" + +pg_tb_messages: + query: | + SELECT + COUNT(ID) + FROM messages + metrics: + - count: + usage: "GAUGE" + description: "Row count in `messages` table"