From 18f7a0ae8fa9c193776db27e60e7e0fd85eebc66 Mon Sep 17 00:00:00 2001 From: NagyZoltanPeter <113987313+NagyZoltanPeter@users.noreply.github.com> Date: Thu, 20 Jun 2024 12:06:37 +0200 Subject: [PATCH 1/2] Added proper per shard bandwidth metric calculation and proper logging of in/out messages Changed rate limit metrics for dashboard Updated monitoring dashboard for bw and rate metrics --- .../dashboards/nwaku-monitoring.json | 1185 ++++++++++++----- waku/common/ratelimit.nim | 4 +- waku/common/waku_service_metrics.nim | 12 +- waku/waku_lightpush/protocol.nim | 6 +- waku/waku_relay/protocol.nim | 99 +- waku/waku_store/protocol.nim | 8 +- waku/waku_store_legacy/protocol.nim | 8 +- 7 files changed, 943 insertions(+), 379 deletions(-) diff --git a/apps/liteprotocoltester/monitoring/configuration/dashboards/nwaku-monitoring.json b/apps/liteprotocoltester/monitoring/configuration/dashboards/nwaku-monitoring.json index 2b024e32fc..f269b0aeb8 100644 --- a/apps/liteprotocoltester/monitoring/configuration/dashboards/nwaku-monitoring.json +++ b/apps/liteprotocoltester/monitoring/configuration/dashboards/nwaku-monitoring.json @@ -88,7 +88,7 @@ "sizing": "auto", "valueMode": "color" }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "targets": [ { "datasource": { @@ -155,10 +155,11 @@ "fields": "", "values": false }, + "showPercentChange": false, "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "targets": [ { "datasource": { @@ -218,10 +219,11 @@ "fields": "", "values": false }, + "showPercentChange": false, "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "targets": [ { "datasource": { @@ -285,10 +287,11 @@ "fields": "", "values": false }, + "showPercentChange": false, "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "targets": [ { "datasource": { @@ -494,6 +497,196 @@ "title": "Average msg size (kBytes)", "type": "timeseries" }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "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 + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "binBps" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 9, + "x": 0, + "y": 16 + }, + "id": 147, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "editorMode": "code", + "expr": "rate(waku_relay_network_bytes_total{direction=\"in\"}[$__rate_interval])", + "legendFormat": "{{topic}}", + "range": true, + "refId": "A" + } + ], + "title": "Relay traffic per shard (in)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "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 + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "binBps" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 9, + "x": 9, + "y": 16 + }, + "id": 148, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "editorMode": "code", + "expr": "rate(waku_relay_network_bytes_total{direction=\"out\"}[$__rate_interval])", + "legendFormat": "{{topic}}", + "range": true, + "refId": "A" + } + ], + "title": "Relay traffic per shard (out)", + "type": "timeseries" + }, { "datasource": { "type": "prometheus", @@ -532,7 +725,7 @@ "h": 5, "w": 3, "x": 0, - "y": 16 + "y": 25 }, "id": 2, "options": { @@ -547,7 +740,7 @@ }, "showHeader": true }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "targets": [ { "datasource": { @@ -610,7 +803,7 @@ "h": 5, "w": 3, "x": 3, - "y": 16 + "y": 25 }, "id": 22, "options": { @@ -625,10 +818,11 @@ "fields": "", "values": false }, + "showPercentChange": false, "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "targets": [ { "datasource": { @@ -688,7 +882,7 @@ "h": 5, "w": 3, "x": 6, - "y": 16 + "y": 25 }, "id": 32, "options": { @@ -703,10 +897,11 @@ "fields": "", "values": false }, + "showPercentChange": false, "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "targets": [ { "datasource": { @@ -754,7 +949,7 @@ "h": 5, "w": 3, "x": 9, - "y": 16 + "y": 25 }, "id": 33, "options": { @@ -769,10 +964,11 @@ "fields": "", "values": false }, + "showPercentChange": false, "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "targets": [ { "datasource": { @@ -833,7 +1029,7 @@ "h": 5, "w": 3, "x": 12, - "y": 16 + "y": 25 }, "id": 25, "options": { @@ -848,10 +1044,11 @@ "fields": "", "values": false }, + "showPercentChange": false, "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "targets": [ { "datasource": { @@ -899,7 +1096,7 @@ "h": 5, "w": 3, "x": 15, - "y": 16 + "y": 25 }, "id": 28, "options": { @@ -914,10 +1111,11 @@ "fields": "", "values": false }, + "showPercentChange": false, "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "targets": [ { "datasource": { @@ -962,7 +1160,7 @@ "h": 5, "w": 3, "x": 0, - "y": 21 + "y": 30 }, "id": 10, "options": { @@ -977,10 +1175,11 @@ "fields": "", "values": false }, + "showPercentChange": false, "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "targets": [ { "datasource": { @@ -1028,7 +1227,7 @@ "h": 10, "w": 15, "x": 3, - "y": 21 + "y": 30 }, "id": 44, "options": { @@ -1043,10 +1242,11 @@ "fields": "", "values": false }, + "showPercentChange": false, "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "targets": [ { "datasource": { @@ -1061,7 +1261,6 @@ } ], "title": "Connected Peers (Direction/Protocol)", - "transformations": [], "type": "stat" }, { @@ -1091,7 +1290,7 @@ "h": 5, "w": 3, "x": 0, - "y": 26 + "y": 35 }, "id": 36, "options": { @@ -1106,25 +1305,311 @@ "fields": "", "values": false }, - "textMode": "auto", - "wideLayout": true + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.4.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "editorMode": "code", + "expr": "waku_peer_store_size", + "legendFormat": "__auto", + "range": true, + "refId": "A" + } + ], + "title": "Peer Store Size", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "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 + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "binBps" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 9, + "x": 0, + "y": 40 + }, + "id": 8, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "editorMode": "code", + "expr": "rate(libp2p_network_bytes_total{direction=\"in\"}[$__rate_interval])", + "legendFormat": "traffic_{{direction}}", + "range": true, + "refId": "A" + } + ], + "title": "libp2p traffic (in)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "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 + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "binBps" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 9, + "x": 9, + "y": 40 + }, + "id": 29, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "editorMode": "code", + "expr": "rate(libp2p_network_bytes_total{direction=\"out\"}[$__rate_interval])", + "legendFormat": "traffic_{{direction}}", + "range": true, + "refId": "A" + } + ], + "title": "libp2p traffic (out)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "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 + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 6, + "x": 0, + "y": 49 + }, + "id": 4, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } }, - "pluginVersion": "10.2.3", + "pluginVersion": "9.3.2", "targets": [ { "datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" }, - "editorMode": "code", - "expr": "waku_peer_store_size", - "legendFormat": "__auto", + "editorMode": "builder", + "expr": "libp2p_peers", + "legendFormat": "{{__name__}}", "range": true, "refId": "A" } ], - "title": "Peer Store Size", - "type": "stat" + "title": "Connected Peers", + "type": "timeseries" }, { "datasource": { @@ -1181,17 +1666,18 @@ "value": 80 } ] - } + }, + "unit": "reqps" }, "overrides": [] }, "gridPos": { - "h": 9, - "w": 6, - "x": 0, - "y": 31 + "h": 10, + "w": 12, + "x": 6, + "y": 49 }, - "id": 4, + "id": 149, "options": { "legend": { "calcs": [], @@ -1204,21 +1690,20 @@ "sort": "none" } }, - "pluginVersion": "9.3.2", "targets": [ { "datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" }, - "editorMode": "builder", - "expr": "libp2p_peers", - "legendFormat": "{{__name__}}", + "editorMode": "code", + "expr": "rate(waku_service_requests_total[$__rate_interval])", + "legendFormat": "{{proto}}/{{state}}", "range": true, "refId": "A" } ], - "title": "Connected Peers", + "title": "Protocol request rates", "type": "timeseries" }, { @@ -1283,11 +1768,11 @@ }, "gridPos": { "h": 9, - "w": 6, - "x": 6, - "y": 31 + "w": 9, + "x": 0, + "y": 59 }, - "id": 8, + "id": 150, "options": { "legend": { "calcs": [], @@ -1307,13 +1792,13 @@ "uid": "PBFA97CFB590B2093" }, "editorMode": "code", - "expr": "rate(libp2p_network_bytes_total{direction=\"in\"}[$__rate_interval])", - "legendFormat": "traffic_{{direction}}", + "expr": "rate(waku_service_network_bytes_total{direction=\"in\"}[$__rate_interval])", + "legendFormat": "{{service}}", "range": true, "refId": "A" } ], - "title": "libp2p traffic (in)", + "title": "Non relay protocol traffic (in)", "type": "timeseries" }, { @@ -1378,11 +1863,11 @@ }, "gridPos": { "h": 9, - "w": 6, - "x": 12, - "y": 31 + "w": 9, + "x": 9, + "y": 59 }, - "id": 29, + "id": 151, "options": { "legend": { "calcs": [], @@ -1402,13 +1887,13 @@ "uid": "PBFA97CFB590B2093" }, "editorMode": "code", - "expr": "rate(libp2p_network_bytes_total{direction=\"out\"}[$__rate_interval])", - "legendFormat": "traffic_{{direction}}", + "expr": "rate(waku_service_network_bytes_total{direction=\"out\"}[$__rate_interval])", + "legendFormat": "{{service}}", "range": true, "refId": "A" } ], - "title": "libp2p traffic (out)", + "title": "Non relay protocol traffic (out)", "type": "timeseries" }, { @@ -1475,7 +1960,7 @@ "h": 8, "w": 6, "x": 0, - "y": 40 + "y": 68 }, "id": 20, "options": { @@ -1570,7 +2055,7 @@ "h": 8, "w": 6, "x": 6, - "y": 40 + "y": 68 }, "id": 18, "options": { @@ -1662,12 +2147,12 @@ "overrides": [] }, "gridPos": { - "h": 8, + "h": 6, "w": 6, "x": 12, - "y": 40 + "y": 68 }, - "id": 128, + "id": 135, "options": { "legend": { "calcs": [], @@ -1688,7 +2173,7 @@ }, "disableTextWrap": false, "editorMode": "builder", - "expr": "waku_rln_number_registered_memberships", + "expr": "waku_rln_membership_insertion_duration_seconds", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -1698,7 +2183,7 @@ "useBackend": false } ], - "title": "RLN Registered Memberships", + "title": "RLN Membership Insertion (seconds)", "type": "timeseries" }, { @@ -1761,12 +2246,12 @@ "overrides": [] }, "gridPos": { - "h": 6, + "h": 8, "w": 6, - "x": 0, - "y": 48 + "x": 12, + "y": 74 }, - "id": 127, + "id": 128, "options": { "legend": { "calcs": [], @@ -1787,7 +2272,7 @@ }, "disableTextWrap": false, "editorMode": "builder", - "expr": "waku_rln_proof_generation_duration_seconds", + "expr": "waku_rln_number_registered_memberships", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -1797,7 +2282,7 @@ "useBackend": false } ], - "title": "RLN Proof Generation (seconds)", + "title": "RLN Registered Memberships", "type": "timeseries" }, { @@ -1862,10 +2347,10 @@ "gridPos": { "h": 6, "w": 6, - "x": 6, - "y": 48 + "x": 0, + "y": 76 }, - "id": 126, + "id": 127, "options": { "legend": { "calcs": [], @@ -1886,7 +2371,7 @@ }, "disableTextWrap": false, "editorMode": "builder", - "expr": "waku_rln_proof_verification_duration_seconds", + "expr": "waku_rln_proof_generation_duration_seconds", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -1896,7 +2381,7 @@ "useBackend": false } ], - "title": "RLN Proof Verification (seconds)", + "title": "RLN Proof Generation (seconds)", "type": "timeseries" }, { @@ -1961,10 +2446,10 @@ "gridPos": { "h": 6, "w": 6, - "x": 12, - "y": 48 + "x": 6, + "y": 76 }, - "id": 135, + "id": 126, "options": { "legend": { "calcs": [], @@ -1985,7 +2470,7 @@ }, "disableTextWrap": false, "editorMode": "builder", - "expr": "waku_rln_membership_insertion_duration_seconds", + "expr": "waku_rln_proof_verification_duration_seconds", "fullMetaSearch": false, "includeNullMetadata": true, "instant": false, @@ -1995,7 +2480,7 @@ "useBackend": false } ], - "title": "RLN Membership Insertion (seconds)", + "title": "RLN Proof Verification (seconds)", "type": "timeseries" }, { @@ -2061,7 +2546,7 @@ "h": 6, "w": 6, "x": 0, - "y": 54 + "y": 82 }, "id": 134, "options": { @@ -2160,7 +2645,7 @@ "h": 6, "w": 6, "x": 6, - "y": 54 + "y": 82 }, "id": 137, "options": { @@ -2259,7 +2744,7 @@ "h": 6, "w": 6, "x": 12, - "y": 54 + "y": 82 }, "id": 136, "options": { @@ -2358,7 +2843,7 @@ "h": 6, "w": 6, "x": 0, - "y": 60 + "y": 88 }, "id": 133, "options": { @@ -2457,7 +2942,7 @@ "h": 6, "w": 6, "x": 6, - "y": 60 + "y": 88 }, "id": 130, "options": { @@ -2556,7 +3041,7 @@ "h": 6, "w": 6, "x": 12, - "y": 60 + "y": 88 }, "id": 138, "options": { @@ -2657,7 +3142,7 @@ "h": 11, "w": 9, "x": 0, - "y": 66 + "y": 94 }, "id": 141, "options": { @@ -2794,7 +3279,7 @@ "h": 11, "w": 9, "x": 9, - "y": 66 + "y": 94 }, "id": 144, "options": { @@ -2812,7 +3297,7 @@ "showHeader": true, "sortBy": [] }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "targets": [ { "datasource": { @@ -2964,31 +3449,209 @@ } ] }, - "unit": "none" + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 9, + "x": 0, + "y": 105 + }, + "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" + }, + { + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "Prometheus", + "description": "Clients executing Statements.\n\nSource: pg_stat_activity", + "fieldConfig": { + "defaults": { + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 9, + "y": 105 + }, + "id": 23, + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.4.2", + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "expr": "sum(pg_stat_activity_count{state=\"active\",instance=\"$Instance\"})", + "refId": "A" + } + ], + "thresholds": "", + "title": "Active clients (Postgres)", + "type": "stat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFA97CFB590B2093" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "dateTimeAsIso" }, "overrides": [] }, "gridPos": { - "h": 7, - "w": 9, - "x": 0, - "y": 77 + "h": 3, + "w": 4, + "x": 13, + "y": 105 }, - "id": 146, + "id": 125, "options": { - "legend": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { "calcs": [ - "last" + "lastNotNull" ], - "displayMode": "list", - "placement": "bottom", - "showLegend": true + "fields": "", + "values": false }, - "tooltip": { - "mode": "single", - "sort": "none" - } + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true }, + "pluginVersion": "10.4.2", "targets": [ { "datasource": { @@ -2996,17 +3659,14 @@ "uid": "PBFA97CFB590B2093" }, "editorMode": "code", - "exemplar": false, - "expr": "pg_tb_messages_count{}", - "instant": false, - "interval": "", - "legendFormat": "messages", + "expr": "pg_postmaster_start_time_seconds*1000", + "legendFormat": "__auto", "range": true, "refId": "A" } ], - "title": "Unique stored messages (Postgres)", - "type": "timeseries" + "title": "Postgres start time", + "type": "stat" }, { "collapsed": false, @@ -3014,7 +3674,7 @@ "h": 1, "w": 24, "x": 0, - "y": 84 + "y": 112 }, "id": 46, "panels": [], @@ -3033,8 +3693,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" } ] } @@ -3053,10 +3712,9 @@ "h": 3, "w": 4, "x": 0, - "y": 85 + "y": 113 }, "id": 11, - "links": [], "mappingType": 1, "mappingTypes": [ { @@ -3082,10 +3740,11 @@ "fields": "", "values": false }, + "showPercentChange": false, "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "postfix": "", "postfixFontSize": "50%", "prefix": "", @@ -3141,8 +3800,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -3165,11 +3823,10 @@ "h": 3, "w": 4, "x": 4, - "y": 85 + "y": 113 }, "id": 14, "interval": "", - "links": [], "mappingType": 1, "mappingTypes": [ { @@ -3195,10 +3852,11 @@ "fields": "", "values": false }, + "showPercentChange": false, "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "postfix": "", "postfixFontSize": "50%", "prefix": "", @@ -3255,8 +3913,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -3279,10 +3936,9 @@ "h": 3, "w": 4, "x": 8, - "y": 85 + "y": 113 }, "id": 93, - "links": [], "mappingType": 1, "mappingTypes": [ { @@ -3308,10 +3964,11 @@ "fields": "", "values": false }, + "showPercentChange": false, "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "postfix": "", "postfixFontSize": "50%", "prefix": "", @@ -3368,8 +4025,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -3392,10 +4048,9 @@ "h": 3, "w": 4, "x": 12, - "y": 85 + "y": 113 }, "id": 102, - "links": [], "mappingType": 1, "mappingTypes": [ { @@ -3421,10 +4076,11 @@ "fields": "", "values": false }, + "showPercentChange": false, "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "postfix": "", "postfixFontSize": "50%", "prefix": "", @@ -3482,8 +4138,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" } ] }, @@ -3503,10 +4158,9 @@ "h": 3, "w": 4, "x": 16, - "y": 85 + "y": 113 }, "id": 37, - "links": [], "mappingType": 1, "mappingTypes": [ { @@ -3532,10 +4186,11 @@ "fields": "", "values": false }, + "showPercentChange": false, "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "postfix": "", "postfixFontSize": "50%", "prefix": "", @@ -3590,8 +4245,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -3614,10 +4268,9 @@ "h": 3, "w": 4, "x": 20, - "y": 85 + "y": 113 }, "id": 84, - "links": [], "mappingType": 1, "mappingTypes": [ { @@ -3643,10 +4296,11 @@ "fields": "", "values": false }, + "showPercentChange": false, "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "postfix": "", "postfixFontSize": "50%", "prefix": "", @@ -3727,10 +4381,9 @@ "h": 7, "w": 3, "x": 0, - "y": 88 + "y": 116 }, "id": 16, - "links": [], "options": { "minVizHeight": 75, "minVizWidth": 75, @@ -3746,7 +4399,7 @@ "showThresholdMarkers": true, "sizing": "auto" }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "targets": [ { "expr": "sum(pg_stat_database_blks_hit{instance=~\"$Instance\"})/(sum(pg_stat_database_blks_hit{instance=~\"$Instance\"})+sum(pg_stat_database_blks_read{instance=~\"$Instance\"}))*100", @@ -3777,8 +4430,7 @@ "mode": "absolute", "steps": [ { - "color": "semi-dark-green", - "value": null + "color": "semi-dark-green" }, { "color": "semi-dark-yellow", @@ -3798,10 +4450,9 @@ "h": 7, "w": 3, "x": 3, - "y": 88 + "y": 116 }, "id": 9, - "links": [], "options": { "minVizHeight": 75, "minVizWidth": 75, @@ -3817,7 +4468,7 @@ "showThresholdMarkers": true, "sizing": "auto" }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "targets": [ { "expr": "sum(pg_stat_database_numbackends)/max(pg_settings_max_connections)", @@ -3848,8 +4499,7 @@ "mode": "absolute", "steps": [ { - "color": "semi-dark-red", - "value": null + "color": "semi-dark-red" }, { "color": "#EAB839", @@ -3869,10 +4519,9 @@ "h": 7, "w": 3, "x": 6, - "y": 88 + "y": 116 }, "id": 15, - "links": [], "options": { "minVizHeight": 75, "minVizWidth": 75, @@ -3888,7 +4537,7 @@ "showThresholdMarkers": true, "sizing": "auto" }, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "targets": [ { "expr": "sum(pg_stat_database_xact_commit{instance=\"$Instance\"})/(sum(pg_stat_database_xact_commit{instance=\"$Instance\"}) + sum(pg_stat_database_xact_rollback{instance=\"$Instance\"}))", @@ -3898,180 +4547,6 @@ "title": "Commit Ratio (Postgres)", "type": "gauge" }, - { - "colorBackground": false, - "colorValue": false, - "colors": [ - "#299c46", - "rgba(237, 129, 40, 0.89)", - "#d44a3a" - ], - "datasource": "Prometheus", - "description": "Clients executing Statements.\n\nSource: pg_stat_activity", - "fieldConfig": { - "defaults": { - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "format": "none", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "gridPos": { - "h": 3, - "w": 4, - "x": 12, - "y": 88 - }, - "id": 23, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto", - "wideLayout": true - }, - "pluginVersion": "10.2.3", - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": true - }, - "tableColumn": "", - "targets": [ - { - "expr": "sum(pg_stat_activity_count{state=\"active\",instance=\"$Instance\"})", - "refId": "A" - } - ], - "thresholds": "", - "title": "Active clients (Postgres)", - "type": "stat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "current" - }, - { - "datasource": { - "type": "prometheus", - "uid": "PBFA97CFB590B2093" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - }, - "unit": "dateTimeAsIso" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 4, - "x": 16, - "y": 88 - }, - "id": 125, - "options": { - "colorMode": "value", - "graphMode": "none", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto", - "wideLayout": true - }, - "pluginVersion": "10.2.3", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "PBFA97CFB590B2093" - }, - "editorMode": "code", - "expr": "pg_postmaster_start_time_seconds*1000", - "legendFormat": "__auto", - "range": true, - "refId": "A" - } - ], - "title": "Postgres start time", - "type": "stat" - }, { "datasource": { "type": "prometheus", @@ -4120,8 +4595,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -4137,7 +4611,7 @@ "h": 8, "w": 12, "x": 12, - "y": 91 + "y": 116 }, "id": 142, "options": { @@ -4213,7 +4687,7 @@ "h": 9, "w": 12, "x": 0, - "y": 95 + "y": 123 }, "hiddenSeries": false, "id": 24, @@ -4245,7 +4719,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "pointradius": 2, "points": false, "renderer": "flot", @@ -4312,7 +4786,7 @@ "h": 9, "w": 12, "x": 12, - "y": 99 + "y": 124 }, "hiddenSeries": false, "id": 121, @@ -4344,7 +4818,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "pointradius": 2, "points": false, "renderer": "flot", @@ -4411,7 +4885,7 @@ "h": 9, "w": 12, "x": 0, - "y": 104 + "y": 132 }, "hiddenSeries": false, "id": 122, @@ -4436,7 +4910,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "pointradius": 2, "points": false, "renderer": "flot", @@ -4508,7 +4982,7 @@ "h": 9, "w": 12, "x": 12, - "y": 108 + "y": 133 }, "hiddenSeries": false, "id": 27, @@ -4530,7 +5004,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "pointradius": 2, "points": false, "renderer": "flot", @@ -4609,7 +5083,7 @@ "h": 9, "w": 12, "x": 0, - "y": 113 + "y": 141 }, "hiddenSeries": false, "id": 26, @@ -4630,7 +5104,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "pointradius": 2, "points": false, "renderer": "flot", @@ -4703,7 +5177,7 @@ "h": 9, "w": 12, "x": 12, - "y": 117 + "y": 142 }, "hiddenSeries": false, "id": 111, @@ -4725,7 +5199,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "pointradius": 2, "points": false, "renderer": "flot", @@ -4798,7 +5272,7 @@ "h": 10, "w": 12, "x": 0, - "y": 122 + "y": 150 }, "hiddenSeries": false, "id": 123, @@ -4825,7 +5299,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "pointradius": 2, "points": false, "renderer": "flot", @@ -4889,7 +5363,7 @@ "h": 5, "w": 12, "x": 12, - "y": 126 + "y": 151 }, "hiddenSeries": false, "id": 30, @@ -4918,7 +5392,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "pointradius": 2, "points": false, "renderer": "flot", @@ -4985,7 +5459,7 @@ "h": 5, "w": 12, "x": 12, - "y": 131 + "y": 156 }, "hiddenSeries": false, "id": 31, @@ -5014,7 +5488,7 @@ "alertThreshold": true }, "percentage": false, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "pointradius": 2, "points": false, "renderer": "flot", @@ -5081,7 +5555,7 @@ "h": 10, "w": 12, "x": 0, - "y": 132 + "y": 160 }, "hiddenSeries": false, "id": 120, @@ -5098,13 +5572,12 @@ }, "lines": true, "linewidth": 1, - "links": [], "nullPointMode": "null", "options": { "alertThreshold": true }, "percentage": false, - "pluginVersion": "10.2.3", + "pluginVersion": "10.4.2", "pointradius": 2, "points": false, "renderer": "flot", @@ -5154,7 +5627,6 @@ } } ], - "refresh": "1m", "revision": 1, "schemaVersion": 39, "tags": [], @@ -5162,9 +5634,10 @@ "list": [ { "current": { + "isNone": true, "selected": false, - "text": "postgres-exporter:9187", - "value": "postgres-exporter:9187" + "text": "None", + "value": "" }, "datasource": { "type": "prometheus", @@ -5281,8 +5754,8 @@ ] }, "time": { - "from": "now-15m", - "to": "now" + "from": "2024-06-26T02:42:06.763Z", + "to": "2024-06-26T04:42:06.771Z" }, "timepicker": { "refresh_intervals": [ diff --git a/waku/common/ratelimit.nim b/waku/common/ratelimit.nim index 8fb91219a7..70001086b2 100644 --- a/waku/common/ratelimit.nim +++ b/waku/common/ratelimit.nim @@ -43,10 +43,10 @@ template checkUsageLimit*( bodyWithinLimit, bodyRejected: untyped, ) = if t.checkUsage(proto, conn): - waku_service_requests.inc(labelValues = [proto]) + waku_service_requests.inc(labelValues = [proto, "served"]) bodyWithinLimit else: - waku_service_requests_rejected.inc(labelValues = [proto]) + waku_service_requests.inc(labelValues = [proto, "rejected"]) bodyRejected func `$`*(ob: Option[TokenBucket]): string {.inline.} = diff --git a/waku/common/waku_service_metrics.nim b/waku/common/waku_service_metrics.nim index a58c48d1b8..0ea85205cf 100644 --- a/waku/common/waku_service_metrics.nim +++ b/waku/common/waku_service_metrics.nim @@ -6,13 +6,7 @@ else: import metrics declarePublicCounter waku_service_requests, - "number of non-relay service requests received", ["service"] -declarePublicCounter waku_service_requests_rejected, - "number of non-relay service requests received being rejected due to limit overdue", - ["service"] + "number of non-relay service requests received", ["service", "state"] -declarePublicCounter waku_service_inbound_network_bytes, - "total incoming traffic of specific waku services", labels = ["service"] - -declarePublicCounter waku_service_outbound_network_bytes, - "total outgoing traffic of specific waku services", labels = ["service"] +declarePublicCounter waku_service_network_bytes, + "total incoming traffic of specific waku services", labels = ["service", "direction"] diff --git a/waku/waku_lightpush/protocol.nim b/waku/waku_lightpush/protocol.nim index 1e270ccc7a..f0ca0910fa 100644 --- a/waku/waku_lightpush/protocol.nim +++ b/waku/waku_lightpush/protocol.nim @@ -73,8 +73,8 @@ proc initProtocolHandler(wl: WakuLightPush) = wl.requestRateLimiter.checkUsageLimit(WakuLightPushCodec, conn): let buffer = await conn.readLp(DefaultMaxRpcSize) - waku_service_inbound_network_bytes.inc( - amount = buffer.len().int64, labelValues = [WakuLightPushCodec] + waku_service_network_bytes.inc( + amount = buffer.len().int64, labelValues = [WakuLightPushCodec, "in"] ) rpc = await handleRequest(wl, conn.peerId, buffer) @@ -115,4 +115,4 @@ proc new*( requestRateLimiter: newTokenBucket(rateLimitSetting), ) wl.initProtocolHandler() - return wl \ No newline at end of file + return wl diff --git a/waku/waku_relay/protocol.nim b/waku/waku_relay/protocol.nim index 03d5b596ec..85777d8b2e 100644 --- a/waku/waku_relay/protocol.nim +++ b/waku/waku_relay/protocol.nim @@ -59,6 +59,9 @@ const TopicParameters = TopicParams( invalidMessageDeliveriesDecay: 0.5, ) +declareCounter waku_relay_network_bytes, + "total traffic per topic", labels = ["topic", "direction"] + # see: https://rfc.vac.dev/spec/29/#gossipsub-v10-parameters const GossipsubParameters = GossipSubParams.init( pruneBackoff = chronos.minutes(1), @@ -150,6 +153,94 @@ proc initProtocolHandler(w: WakuRelay) = w.handler = handler w.codec = WakuRelayCodec +proc initRelayMetricObserver(w: WakuRelay) = + proc decodeRpcMessageInfo( + peer: PubSubPeer, msg: Message + ): Result[ + tuple[msgId: string, topic: string, wakuMessage: WakuMessage, msgSize: int], void + ] = + let msg_id = w.msgIdProvider(msg).valueOr: + warn "Error generating message id", + my_peer_id = w.switch.peerInfo.peerId, + from_peer_id = peer.peerId, + topic = msg.topic, + error = $error + return err() + + let msg_id_short = shortLog(msg_id) + + let wakuMessage = WakuMessage.decode(msg.data).valueOr: + warn "Error decoding to Waku Message", + my_peer_id = w.switch.peerInfo.peerId, + msg_id = msg_id_short, + from_peer_id = peer.peerId, + topic = msg.topic, + error = $error + return err() + + let msgSize = msg.data.len + msg.topic.len + return ok((msg_id_short, msg.topic, wakuMessage, msgSize)) + + proc logMessageInfo( + peer: PubSubPeer, + topic: string, + msg_id_short: string, + msg: WakuMessage, + onRecv: bool, + ) = + let msg_hash = computeMessageHash(topic, msg).to0xHex() + + if onRecv: + notice "received relay message", + my_peer_id = w.switch.peerInfo.peerId, + msg_hash = msg_hash, + msg_id = msg_id_short, + from_peer_id = peer.peerId, + topic = topic, + receivedTime = getNowInNanosecondTime(), + payloadSizeBytes = msg.payload.len + else: + notice "sent relay message", + my_peer_id = w.switch.peerInfo.peerId, + msg_hash = msg_hash, + msg_id = msg_id_short, + to_peer_id = peer.peerId, + topic = topic, + sentTime = getNowInNanosecondTime(), + payloadSizeBytes = msg.payload.len + + proc updateMetrics( + peer: PubSubPeer, + pubsub_topic: string, + msg: WakuMessage, + msgSize: int, + onRecv: bool, + ) = + # TODO: Calculate the size of the message + + waku_relay_network_bytes.inc( + msgSize.int64, labelValues = [pubsub_topic, if onRecv: "in" else: "out"] + ) + + proc onRecv(peer: PubSubPeer, msgs: var RPCMsg) = + for msg in msgs.messages: + let (msg_id_short, topic, wakuMessage, msgSize) = decodeRpcMessageInfo(peer, msg).valueOr: + continue + # logMessageInfo(peer, topic, msg_id_short, wakuMessage, onRecv = true) + updateMetrics(peer, topic, wakuMessage, msgSize, onRecv = true) + discard + + proc onSend(peer: PubSubPeer, msgs: var RPCMsg) = + for msg in msgs.messages: + let (msg_id_short, topic, wakuMessage, msgSize) = decodeRpcMessageInfo(peer, msg).valueOr: + continue + logMessageInfo(peer, topic, msg_id_short, wakuMessage, onRecv = false) + updateMetrics(peer, topic, wakuMessage, msgSize, onRecv = false) + + let administrativeObserver = PubSubObserver(onRecv: onRecv, onSend: onSend) + + w.addObserver(administrativeObserver) + proc new*( T: type WakuRelay, switch: Switch, maxMessageSize = int(DefaultMaxWakuMessageSize) ): WakuRelayResult[T] = @@ -170,6 +261,7 @@ proc new*( procCall GossipSub(w).initPubSub() w.initProtocolHandler() + w.initRelayMetricObserver() except InitializationError: return err("initialization error: " & getCurrentExceptionMsg()) @@ -180,6 +272,9 @@ proc addValidator*( ) {.gcsafe.} = w.wakuValidators.add((handler, errorMessage)) +proc addObserver*(w: WakuRelay, observer: PubSubObserver) {.gcsafe.} = + procCall GossipSub(w).addObserver(observer) + method start*(w: WakuRelay) {.async, base.} = debug "start" await procCall GossipSub(w).start() @@ -311,4 +406,6 @@ proc publish*( let msgHash = computeMessageHash(pubsubTopic, message).to0xHex() notice "start publish Waku message", msg_hash = msgHash, pubsubTopic = pubsubTopic - return await procCall GossipSub(w).publish(pubsubTopic, data) + let relayedPeerCount = await procCall GossipSub(w).publish(pubsubTopic, data) + + return relayedPeerCount diff --git a/waku/waku_store/protocol.nim b/waku/waku_store/protocol.nim index 357d303b25..57ac221b0b 100644 --- a/waku/waku_store/protocol.nim +++ b/waku/waku_store/protocol.nim @@ -103,8 +103,8 @@ proc initProtocolHandler(self: WakuStore) = error "Connection read error", error = error.msg return - waku_service_inbound_network_bytes.inc( - amount = reqBuf.len().int64, labelValues = [WakuStoreCodec] + waku_service_network_bytes.inc( + amount = reqBuf.len().int64, labelValues = [WakuStoreCodec, "in"] ) resBuf = await self.handleQueryRequest(conn.peerId, reqBuf) @@ -120,8 +120,8 @@ proc initProtocolHandler(self: WakuStore) = error "Connection write error", error = writeRes.error.msg return - waku_service_outbound_network_bytes.inc( - amount = resBuf.len().int64, labelValues = [WakuStoreCodec] + waku_service_network_bytes.inc( + amount = resBuf.len().int64, labelValues = [WakuStoreCodec, "out"] ) self.handler = handler diff --git a/waku/waku_store_legacy/protocol.nim b/waku/waku_store_legacy/protocol.nim index c0ede7b85f..4df4520c6b 100644 --- a/waku/waku_store_legacy/protocol.nim +++ b/waku/waku_store_legacy/protocol.nim @@ -118,8 +118,8 @@ proc initProtocolHandler(ws: WakuStore) = error "Connection read error", error = error.msg return - waku_service_inbound_network_bytes.inc( - amount = reqBuf.len().int64, labelValues = [WakuLegacyStoreCodec] + waku_service_network_bytes.inc( + amount = reqBuf.len().int64, labelValues = [WakuLegacyStoreCodec, "in"] ) resBuf = await ws.handleLegacyQueryRequest(conn.peerId, reqBuf) @@ -135,8 +135,8 @@ proc initProtocolHandler(ws: WakuStore) = error "Connection write error", error = writeRes.error.msg return - waku_service_outbound_network_bytes.inc( - amount = resBuf.len().int64, labelValues = [WakuLegacyStoreCodec] + waku_service_network_bytes.inc( + amount = resBuf.len().int64, labelValues = [WakuLegacyStoreCodec, "out"] ) ws.handler = handler From 25c5b5d756a6ab50e2faf4baeb17d298420f3447 Mon Sep 17 00:00:00 2001 From: NagyZoltanPeter <113987313+NagyZoltanPeter@users.noreply.github.com> Date: Fri, 28 Jun 2024 00:41:52 +0200 Subject: [PATCH 2/2] Applied review suggestions --- waku/waku_relay/protocol.nim | 42 +++++++++++------------------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/waku/waku_relay/protocol.nim b/waku/waku_relay/protocol.nim index 85777d8b2e..e52ef85421 100644 --- a/waku/waku_relay/protocol.nim +++ b/waku/waku_relay/protocol.nim @@ -163,7 +163,7 @@ proc initRelayMetricObserver(w: WakuRelay) = warn "Error generating message id", my_peer_id = w.switch.peerInfo.peerId, from_peer_id = peer.peerId, - topic = msg.topic, + pubsub_topic = msg.topic, error = $error return err() @@ -174,7 +174,7 @@ proc initRelayMetricObserver(w: WakuRelay) = my_peer_id = w.switch.peerInfo.peerId, msg_id = msg_id_short, from_peer_id = peer.peerId, - topic = msg.topic, + pubsub_topic = msg.topic, error = $error return err() @@ -182,32 +182,18 @@ proc initRelayMetricObserver(w: WakuRelay) = return ok((msg_id_short, msg.topic, wakuMessage, msgSize)) proc logMessageInfo( - peer: PubSubPeer, - topic: string, - msg_id_short: string, - msg: WakuMessage, - onRecv: bool, + peer: PubSubPeer, topic: string, msg_id_short: string, msg: WakuMessage ) = let msg_hash = computeMessageHash(topic, msg).to0xHex() - if onRecv: - notice "received relay message", - my_peer_id = w.switch.peerInfo.peerId, - msg_hash = msg_hash, - msg_id = msg_id_short, - from_peer_id = peer.peerId, - topic = topic, - receivedTime = getNowInNanosecondTime(), - payloadSizeBytes = msg.payload.len - else: - notice "sent relay message", - my_peer_id = w.switch.peerInfo.peerId, - msg_hash = msg_hash, - msg_id = msg_id_short, - to_peer_id = peer.peerId, - topic = topic, - sentTime = getNowInNanosecondTime(), - payloadSizeBytes = msg.payload.len + notice "sent relay message", + my_peer_id = w.switch.peerInfo.peerId, + msg_hash = msg_hash, + msg_id = msg_id_short, + to_peer_id = peer.peerId, + topic = topic, + sentTime = getNowInNanosecondTime(), + payloadSizeBytes = msg.payload.len proc updateMetrics( peer: PubSubPeer, @@ -216,8 +202,6 @@ proc initRelayMetricObserver(w: WakuRelay) = msgSize: int, onRecv: bool, ) = - # TODO: Calculate the size of the message - waku_relay_network_bytes.inc( msgSize.int64, labelValues = [pubsub_topic, if onRecv: "in" else: "out"] ) @@ -226,7 +210,7 @@ proc initRelayMetricObserver(w: WakuRelay) = for msg in msgs.messages: let (msg_id_short, topic, wakuMessage, msgSize) = decodeRpcMessageInfo(peer, msg).valueOr: continue - # logMessageInfo(peer, topic, msg_id_short, wakuMessage, onRecv = true) + # message receive log happens in treaceHandler as this one is called before checks updateMetrics(peer, topic, wakuMessage, msgSize, onRecv = true) discard @@ -234,7 +218,7 @@ proc initRelayMetricObserver(w: WakuRelay) = for msg in msgs.messages: let (msg_id_short, topic, wakuMessage, msgSize) = decodeRpcMessageInfo(peer, msg).valueOr: continue - logMessageInfo(peer, topic, msg_id_short, wakuMessage, onRecv = false) + logMessageInfo(peer, topic, msg_id_short, wakuMessage) updateMetrics(peer, topic, wakuMessage, msgSize, onRecv = false) let administrativeObserver = PubSubObserver(onRecv: onRecv, onSend: onSend)