From ce77cc7869d8868d7cb4287d5dc53e6e463d0934 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Thu, 24 Oct 2024 17:40:46 -0700 Subject: [PATCH 1/2] add psql datasource to grafana --- .../kubernetes/observability-prometheus-stack.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/localnet/kubernetes/observability-prometheus-stack.yaml b/localnet/kubernetes/observability-prometheus-stack.yaml index 99894b497..59e36ba41 100644 --- a/localnet/kubernetes/observability-prometheus-stack.yaml +++ b/localnet/kubernetes/observability-prometheus-stack.yaml @@ -17,6 +17,20 @@ grafana: viewers_can_edit: true security: allow_embedding: true + additionalDataSources: + - name: PostgreSQL + type: postgres + access: proxy + url: postgres-service:5432 + database: postgres + user: postgres + secureJsonData: + password: postgres + jsonData: + sslmode: disable + postgresVersion: 1604 # Adjust to match your PostgreSQL version + # timescaledb: false # Set to true if you are using TimescaleDB + schema: localnet # Specify your schema here prometheus: prometheusSpec: From 814d0a2eaa1f94e9dfd502a041d893570832b071 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Tue, 29 Oct 2024 18:19:28 -0700 Subject: [PATCH 2/2] more dashboards --- Tiltfile | 4 + cmd/poktrolld/cmd/config.go | 3 +- config.yml | 15 +- .../cosmos_sdk_insights.json | 38 +- .../permissionless_demand_observability.json | 1314 +++++++++++++++++ .../grafana-dashboards/tokenomics_relays.json | 523 +++++++ localnet/poktrolld/config/app.toml | 2 +- pkg/relayer/proxy/metrics.go | 2 +- pkg/relayer/proxy/synchronous.go | 2 +- 9 files changed, 1884 insertions(+), 19 deletions(-) create mode 100644 localnet/grafana-dashboards/permissionless_demand_observability.json create mode 100644 localnet/grafana-dashboards/tokenomics_relays.json diff --git a/Tiltfile b/Tiltfile index 9cb6ea837..12ef5a70a 100644 --- a/Tiltfile +++ b/Tiltfile @@ -240,6 +240,7 @@ helm_resource( "--set=logs.format=" + str(localnet_config["validator"]["logs"]["format"]), "--set=serviceMonitor.enabled=" + str(localnet_config["observability"]["enabled"]), "--set=development.delve.enabled=" + str(localnet_config["validator"]["delve"]["enabled"]), + "--set=image.repository=poktrolld", ], image_deps=["poktrolld"], image_keys=[("image.repository", "image.tag")], @@ -259,6 +260,7 @@ for x in range(localnet_config["relayminers"]["count"]): "--set=metrics.serviceMonitor.enabled=" + str(localnet_config["observability"]["enabled"]), "--set=development.delve.enabled=" + str(localnet_config["relayminers"]["delve"]["enabled"]), "--set=logLevel=" + str(localnet_config["relayminers"]["logs"]["level"]), + "--set=image.repository=poktrolld", ], image_deps=["poktrolld"], image_keys=[("image.repository", "image.tag")], @@ -300,6 +302,7 @@ for x in range(localnet_config["appgateservers"]["count"]): "--set=metrics.serviceMonitor.enabled=" + str(localnet_config["observability"]["enabled"]), "--set=development.delve.enabled=" + str(localnet_config["appgateservers"]["delve"]["enabled"]), "--set=logLevel=" + str(localnet_config["appgateservers"]["logs"]["level"]), + "--set=image.repository=poktrolld", ], image_deps=["poktrolld"], image_keys=[("image.repository", "image.tag")], @@ -342,6 +345,7 @@ for x in range(localnet_config["gateways"]["count"]): "--set=metrics.serviceMonitor.enabled=" + str(localnet_config["observability"]["enabled"]), "--set=development.delve.enabled=" + str(localnet_config["gateways"]["delve"]["enabled"]), "--set=logLevel=" + str(localnet_config["gateways"]["logs"]["level"]), + "--set=image.repository=poktrolld", ], image_deps=["poktrolld"], image_keys=[("image.repository", "image.tag")], diff --git a/cmd/poktrolld/cmd/config.go b/cmd/poktrolld/cmd/config.go index ac46dc0c9..844bef61a 100644 --- a/cmd/poktrolld/cmd/config.go +++ b/cmd/poktrolld/cmd/config.go @@ -130,7 +130,8 @@ func initAppConfig() (string, interface{}) { srvCfg.MinGasPrices = "0.000000001upokt" // Also adjust ignite's `config.yml`. srvCfg.Mempool.MaxTxs = 10000 srvCfg.Telemetry.Enabled = true - srvCfg.Telemetry.PrometheusRetentionTime = 60 * 10 // in seconds. This turns on Prometheus support. + // Positive value turns on prometheus support. Prometheus metrics are removed from the exporter when retention time is reached. + srvCfg.Telemetry.PrometheusRetentionTime = 60 * 60 * 24 // in seconds. srvCfg.Telemetry.MetricsSink = "mem" srvCfg.Pruning = "nothing" // archiving node by default srvCfg.API.Enable = true diff --git a/config.yml b/config.yml index 2f9bf2700..18fd0e6be 100644 --- a/config.yml +++ b/config.yml @@ -91,7 +91,6 @@ validators: # minimum-gas-prices: 0.000000001upokt telemetry: enabled: true - prometheus-retention-time: "10" # seconds. Let's see if block time * 5 gives a better data. poktroll: telemetry: # "high" produces a lot of timeseries. Only suitable for small networks such as LocalNet. @@ -143,13 +142,13 @@ genesis: denom: upokt bank: supply: - - amount: "1003000204" + - amount: "1102000204" denom: upokt balances: # Application module - address: pokt1rl3gjgzexmplmds3tq3r3yk84zlwdl6djzgsvm coins: - - amount: "1000068" # Equals to the total of all app stakes below + - amount: "100000068" # Equals to the total of all app stakes below denom: upokt # Supplier module - address: pokt1j40dzzmn6cn9kxku7a5tjnud6hv37vesr5ccaa @@ -175,9 +174,8 @@ genesis: denom: upokt applicationList: - address: pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4 - delegatee_gateway_addresses: [ - pokt15vzxjqklzjtlz7lahe8z2dfe9nm5vxwwmscne4 - ] + delegatee_gateway_addresses: + [pokt15vzxjqklzjtlz7lahe8z2dfe9nm5vxwwmscne4] service_configs: - service_id: anvil stake: @@ -186,9 +184,8 @@ genesis: amount: "100000068" # ~100 POKT denom: upokt - address: pokt184zvylazwu4queyzpl0gyz9yf5yxm2kdhh9hpm - delegatee_gateway_addresses: [ - pokt15vzxjqklzjtlz7lahe8z2dfe9nm5vxwwmscne4 - ] + delegatee_gateway_addresses: + [pokt15vzxjqklzjtlz7lahe8z2dfe9nm5vxwwmscne4] service_configs: - service_id: rest stake: diff --git a/localnet/grafana-dashboards/cosmos_sdk_insights.json b/localnet/grafana-dashboards/cosmos_sdk_insights.json index 6081a0c1b..8eb10af1b 100644 --- a/localnet/grafana-dashboards/cosmos_sdk_insights.json +++ b/localnet/grafana-dashboards/cosmos_sdk_insights.json @@ -17,7 +17,7 @@ }, "editable": true, "fiscalYearStartMonth": 0, - "graphTooltip": 0, + "graphTooltip": 1, "links": [], "panels": [ { @@ -349,7 +349,7 @@ "unit": "s" } }, - "pluginVersion": "11.2.1", + "pluginVersion": "11.2.2+security-01", "targets": [ { "datasource": { @@ -472,7 +472,7 @@ "editorMode": "code", "expr": "sum(poktroll_proof_validation{job=\"$job\"}) by (quantile)", "instant": false, - "legendFormat": "{{module}}: q{{quantile}}", + "legendFormat": " q{{quantile}}", "range": true, "refId": "A" }, @@ -485,7 +485,7 @@ "expr": "sum(poktroll_proof_validation_sum{job=\"$job\"}) / sum(poktroll_proof_validation_count{job=\"$job\"})", "hide": false, "instant": false, - "legendFormat": "{{module}}: avg", + "legendFormat": "avg", "range": true, "refId": "B" } @@ -1050,7 +1050,20 @@ ] } }, - "overrides": [] + "overrides": [ + { + "matcher": { + "id": "byFrameRefID", + "options": "D" + }, + "properties": [ + { + "id": "custom.lineWidth", + "value": 3 + } + ] + } + ] }, "gridPos": { "h": 6, @@ -1109,6 +1122,19 @@ "legendFormat": "slashed by {{module}}", "range": true, "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "sum(increase(poktroll_minted_tokens{job=\"$job\"}[1m])) - sum(increase(poktroll_burned_tokens{job=\"$job\"}[1m]))", + "hide": false, + "instant": false, + "legendFormat": "Minted total (minus burned)", + "range": true, + "refId": "D" } ], "title": "Minted / Burned / Slashed Tokens", @@ -1208,7 +1234,7 @@ "refId": "A" } ], - "title": "Compute Units", + "title": "Claims", "type": "timeseries" } ], diff --git a/localnet/grafana-dashboards/permissionless_demand_observability.json b/localnet/grafana-dashboards/permissionless_demand_observability.json new file mode 100644 index 000000000..9fffee6e9 --- /dev/null +++ b/localnet/grafana-dashboards/permissionless_demand_observability.json @@ -0,0 +1,1314 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 1, + "links": [], + "panels": [ + { + "datasource": { + "default": true, + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "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": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 0 + }, + "id": 1, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "max(cometbft_consensus_block_size_bytes{})", + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A" + } + ], + "title": "Block size", + "type": "timeseries" + }, + { + "datasource": { + "default": false, + "type": "grafana-postgresql-datasource", + "uid": "PCC52D03280B7034C" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "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": 8, + "w": 12, + "x": 12, + "y": 0 + }, + "id": 2, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "PCC52D03280B7034C" + }, + "editorMode": "code", + "format": "time_series", + "rawQuery": true, + "rawSql": "SELECT\n b.timestamp AS time,\n COUNT(m.id) AS num_proofs\nFROM\n localnet.messages m\nJOIN\n localnet.transactions t ON t.id = m.transaction_id\nJOIN\n localnet.blocks b ON b.id = t.block_id\nWHERE\n m.type_url = '/poktroll.proof.MsgSubmitProof'\n AND b.timestamp BETWEEN $__timeFrom() AND $__timeTo()\nGROUP BY\n b.timestamp\nORDER BY\n b.timestamp;\n", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Number of proofs", + "type": "timeseries" + }, + { + "datasource": { + "default": true, + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "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": 8, + "w": 12, + "x": 0, + "y": 8 + }, + "id": 3, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "increase(appgateserver_relay_requests_total[1m])", + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A" + } + ], + "title": "Actual relays", + "type": "timeseries" + }, + { + "datasource": { + "default": false, + "type": "grafana-postgresql-datasource", + "uid": "PCC52D03280B7034C" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "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": 8, + "w": 12, + "x": 12, + "y": 8 + }, + "id": 4, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "PCC52D03280B7034C" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(b.\"timestamp\", '1m') AS time,\n SUM(trim(both '\"' from ea_num_relays.value)::bigint) AS total_num_relays,\n (ea_claim.value::json ->> 'supplier_operator_address') AS supplier_operator_address,\n (ea_claim.value::json -> 'session_header' ->> 'service_id') AS service_id\nFROM\n localnet.events e\nJOIN\n localnet.event_attributes ea_num_relays ON ea_num_relays.event_id = e.id\n AND ea_num_relays.key = 'num_relays'\nJOIN\n localnet.event_attributes ea_claim ON ea_claim.event_id = e.id\n AND ea_claim.key = 'claim'\nJOIN\n localnet.blocks b ON b.id = e.block_id\nWHERE\n e.type = 'poktroll.proof.EventClaimCreated'\n AND b.\"timestamp\" BETWEEN $__timeFrom() AND $__timeTo()\nGROUP BY\n time, supplier_operator_address, service_id\nORDER BY\n time;\n", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "On chain relays from claims", + "type": "timeseries" + }, + { + "datasource": { + "default": true, + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "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": 8, + "w": 12, + "x": 0, + "y": 16 + }, + "id": 11, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "sum(poktroll_relay_ema{service_id=~\"$service_id\"}) by (service_id)", + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A" + } + ], + "title": "EMA by service", + "type": "timeseries" + }, + { + "datasource": { + "default": true, + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "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": 8, + "w": 12, + "x": 12, + "y": 16 + }, + "id": 12, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "sum(poktroll_relay_mining_difficulty{service_id=~\"$service_id\"}) by (service_id)", + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A" + } + ], + "title": "RM difficulty by service", + "type": "timeseries" + }, + { + "datasource": { + "default": false, + "type": "grafana-postgresql-datasource", + "uid": "PCC52D03280B7034C" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 1, + "scaleDistribution": { + "type": "linear" + }, + "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": 24 + }, + "id": 8, + "options": { + "barRadius": 0, + "barWidth": 0.97, + "fullHighlight": false, + "groupWidth": 0.7, + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "orientation": "auto", + "showValue": "auto", + "stacking": "none", + "tooltip": { + "mode": "single", + "sort": "none" + }, + "xTickLabelRotation": 0, + "xTickLabelSpacing": 0 + }, + "targets": [ + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "PCC52D03280B7034C" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "-- Average number of proofs per application\n\nWITH proofs_per_block AS (\n SELECT\n b.height AS block_height,\n m.json::jsonb -> 'sessionHeader' ->> 'applicationAddress' AS application_address,\n COUNT(m.id) AS num_proofs\n FROM\n localnet.messages m\n JOIN\n localnet.transactions t ON t.id = m.transaction_id\n JOIN\n localnet.blocks b ON b.id = t.block_id\n WHERE\n m.type_url = '/poktroll.proof.MsgSubmitProof'\n AND b.timestamp BETWEEN $__timeFrom() AND $__timeTo()\n GROUP BY\n b.height, application_address\n)\n\nSELECT\n application_address AS application,\n AVG(num_proofs) AS avg_num_proofs\nFROM\n proofs_per_block\nGROUP BY\n application\nORDER BY\n avg_num_proofs DESC;\n", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Average Number of Proofs per Application", + "type": "barchart" + }, + { + "datasource": { + "default": false, + "type": "grafana-postgresql-datasource", + "uid": "PCC52D03280B7034C" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 1, + "scaleDistribution": { + "type": "linear" + }, + "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": 24 + }, + "id": 9, + "options": { + "barRadius": 0, + "barWidth": 0.97, + "fullHighlight": false, + "groupWidth": 0.7, + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "orientation": "auto", + "showValue": "auto", + "stacking": "none", + "tooltip": { + "mode": "single", + "sort": "none" + }, + "xTickLabelRotation": 0, + "xTickLabelSpacing": 0 + }, + "targets": [ + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "PCC52D03280B7034C" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "-- Average number of proofs per service\n\nWITH proofs_per_block AS (\n SELECT\n b.height AS block_height,\n m.json::jsonb -> 'sessionHeader' ->> 'serviceId' AS service_id,\n COUNT(m.id) AS num_proofs\n FROM\n localnet.messages m\n JOIN\n localnet.transactions t ON t.id = m.transaction_id\n JOIN\n localnet.blocks b ON b.id = t.block_id\n WHERE\n m.type_url = '/poktroll.proof.MsgSubmitProof'\n AND b.timestamp BETWEEN $__timeFrom() AND $__timeTo()\n GROUP BY\n b.height, service_id\n)\n\nSELECT\n service_id AS service,\n AVG(num_proofs) AS avg_num_proofs\nFROM\n proofs_per_block\nGROUP BY\n service\nORDER BY\n avg_num_proofs DESC;\n", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Average Number of Proofs per Service", + "type": "barchart" + }, + { + "datasource": { + "default": false, + "type": "grafana-postgresql-datasource", + "uid": "PCC52D03280B7034C" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 1, + "scaleDistribution": { + "type": "linear" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 0, + "y": 32 + }, + "id": 5, + "options": { + "barRadius": 0, + "barWidth": 0.97, + "fullHighlight": false, + "groupWidth": 0.7, + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "orientation": "auto", + "showValue": "auto", + "stacking": "none", + "tooltip": { + "mode": "single", + "sort": "none" + }, + "xTickLabelRotation": 0, + "xTickLabelSpacing": 0 + }, + "targets": [ + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "PCC52D03280B7034C" + }, + "editorMode": "code", + "format": "time_series", + "rawQuery": true, + "rawSql": "SELECT\n b.timestamp AS time,\n COUNT(m.id) AS num_proofs,\n m.json::jsonb -> 'sessionHeader' ->> 'applicationAddress' AS application_address\nFROM\n localnet.messages m\nJOIN\n localnet.transactions t ON t.id = m.transaction_id\nJOIN\n localnet.blocks b ON b.id = t.block_id\nWHERE\n m.type_url = '/poktroll.proof.MsgSubmitProof'\n AND b.timestamp BETWEEN $__timeFrom() AND $__timeTo()\nGROUP BY\n b.timestamp, application_address\nORDER BY\n b.timestamp;\n", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Proof per application", + "type": "barchart" + }, + { + "datasource": { + "default": false, + "type": "grafana-postgresql-datasource", + "uid": "PCC52D03280B7034C" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 1, + "scaleDistribution": { + "type": "linear" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 8, + "y": 32 + }, + "id": 6, + "options": { + "barRadius": 0, + "barWidth": 0.97, + "fullHighlight": false, + "groupWidth": 0.7, + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "orientation": "auto", + "showValue": "auto", + "stacking": "none", + "tooltip": { + "mode": "single", + "sort": "none" + }, + "xTickLabelRotation": 0, + "xTickLabelSpacing": 0 + }, + "targets": [ + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "PCC52D03280B7034C" + }, + "editorMode": "code", + "format": "time_series", + "rawQuery": true, + "rawSql": "SELECT\n b.timestamp AS time,\n COUNT(m.id) AS num_proofs,\n m.json::jsonb -> 'sessionHeader' ->> 'serviceId' AS service_id\nFROM\n localnet.messages m\nJOIN\n localnet.transactions t ON t.id = m.transaction_id\nJOIN\n localnet.blocks b ON b.id = t.block_id\nWHERE\n m.type_url = '/poktroll.proof.MsgSubmitProof'\n AND b.timestamp BETWEEN $__timeFrom() AND $__timeTo()\nGROUP BY\n b.timestamp, service_id\nORDER BY\n b.timestamp;\n", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Proof per service", + "type": "barchart" + }, + { + "datasource": { + "default": false, + "type": "grafana-postgresql-datasource", + "uid": "PCC52D03280B7034C" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 1, + "scaleDistribution": { + "type": "linear" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 16, + "y": 32 + }, + "id": 7, + "options": { + "barRadius": 0, + "barWidth": 0.97, + "fullHighlight": false, + "groupWidth": 0.7, + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "orientation": "auto", + "showValue": "auto", + "stacking": "none", + "tooltip": { + "mode": "single", + "sort": "none" + }, + "xTickLabelRotation": 0, + "xTickLabelSpacing": 0 + }, + "targets": [ + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "PCC52D03280B7034C" + }, + "editorMode": "code", + "format": "time_series", + "rawQuery": true, + "rawSql": "SELECT\n b.timestamp AS time,\n COUNT(m.id) AS num_proofs,\n m.json::jsonb ->> 'supplierOperatorAddress' AS supplier_operator_address\nFROM\n localnet.messages m\nJOIN\n localnet.transactions t ON t.id = m.transaction_id\nJOIN\n localnet.blocks b ON b.id = t.block_id\nWHERE\n m.type_url = '/poktroll.proof.MsgSubmitProof'\n AND b.timestamp BETWEEN $__timeFrom() AND $__timeTo()\nGROUP BY\n b.timestamp, supplier_operator_address\nORDER BY\n b.timestamp;\n", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Proof per supplier operator", + "type": "barchart" + }, + { + "datasource": { + "default": false, + "type": "grafana-postgresql-datasource", + "uid": "PCC52D03280B7034C" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 1, + "scaleDistribution": { + "type": "linear" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 40 + }, + "id": 10, + "options": { + "barRadius": 0, + "barWidth": 0.97, + "fullHighlight": false, + "groupWidth": 0.7, + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "orientation": "auto", + "showValue": "auto", + "stacking": "none", + "tooltip": { + "mode": "single", + "sort": "none" + }, + "xTickLabelRotation": 0, + "xTickLabelSpacing": 0 + }, + "targets": [ + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "PCC52D03280B7034C" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "-- Serviced relays (from claims)\nWITH serviced_relays AS (\n SELECT\n (ea_claim.value::json ->> 'supplier_operator_address') AS supplier_operator_address,\n SUM(trim(both '\"' from ea_num_relays.value)::bigint) AS total_serviced_relays\n FROM\n localnet.events e\n JOIN\n localnet.event_attributes ea_num_relays ON ea_num_relays.event_id = e.id\n AND ea_num_relays.key = 'num_relays'\n JOIN\n localnet.event_attributes ea_claim ON ea_claim.event_id = e.id\n AND ea_claim.key = 'claim'\n JOIN\n localnet.blocks b ON b.id = e.block_id\n WHERE\n e.type = 'poktroll.proof.EventClaimCreated'\n AND b.\"timestamp\" BETWEEN $__timeFrom() AND $__timeTo()\n GROUP BY\n supplier_operator_address\n),\n\n-- Estimated relays (from proofs)\nestimated_relays AS (\n SELECT\n (ea_proof.value::json ->> 'supplier_operator_address') AS supplier_operator_address,\n SUM(trim(both '\"' from ea_num_relays.value)::bigint) AS total_estimated_relays\n FROM\n localnet.events e\n JOIN\n localnet.event_attributes ea_num_relays ON ea_num_relays.event_id = e.id\n AND ea_num_relays.key = 'num_relays'\n JOIN\n localnet.event_attributes ea_proof ON ea_proof.event_id = e.id\n AND ea_proof.key = 'proof'\n JOIN\n localnet.blocks b ON b.id = e.block_id\n WHERE\n e.type = 'poktroll.proof.EventProofSubmitted'\n AND b.\"timestamp\" BETWEEN $__timeFrom() AND $__timeTo()\n GROUP BY\n supplier_operator_address\n)\n\n-- Combine the totals per supplier\nSELECT\n COALESCE(s.supplier_operator_address, e.supplier_operator_address) AS supplier_operator_address,\n COALESCE(s.total_serviced_relays, 0) AS total_serviced_relays,\n COALESCE(e.total_estimated_relays, 0) AS total_estimated_relays\nFROM\n serviced_relays s\nFULL OUTER JOIN\n estimated_relays e ON s.supplier_operator_address = e.supplier_operator_address\nORDER BY\n supplier_operator_address;\n", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "cumulative number of relays claims vs proofs per supplier", + "type": "barchart" + } + ], + "refresh": "", + "schemaVersion": 39, + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": {}, + "timezone": "browser", + "title": "Permissionless demand observability", + "version": 0, + "weekStart": "" +} \ No newline at end of file diff --git a/localnet/grafana-dashboards/tokenomics_relays.json b/localnet/grafana-dashboards/tokenomics_relays.json new file mode 100644 index 000000000..f6228f499 --- /dev/null +++ b/localnet/grafana-dashboards/tokenomics_relays.json @@ -0,0 +1,523 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "links": [], + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 5, + "y": 0 + }, + "id": 4, + "options": { + "code": { + "language": "plaintext", + "showLineNumbers": false, + "showMiniMap": false + }, + "content": "## What does this dashboard show?\n\nAs relays flow through the network\nAppGate -> RelayMiner and RelayMiner creates proofs and claims, we can capture the whole relay cycle.\n\n1. shows the actual amount of relays on AppGate;\n2. shows the actual amount of relays processed by RelayMiner;\n3. the amount of relays from the on-chain information using `EventClaimCreated`;\n4. relays from `EventProofSubmitted`;", + "mode": "markdown" + }, + "pluginVersion": "11.2.2+security-01", + "title": "Wht is this dashboard?", + "type": "text" + }, + { + "datasource": { + "default": true, + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "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": 8, + "w": 24, + "x": 0, + "y": 8 + }, + "id": 1, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "increase(appgateserver_relay_requests_total[$group_by])", + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A" + } + ], + "title": "Actual AppGate Requests", + "type": "timeseries" + }, + { + "datasource": { + "default": true, + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "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": 8, + "w": 24, + "x": 0, + "y": 16 + }, + "id": 2, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "increase(relayminer_requests_total[$group_by])", + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A" + } + ], + "title": "Actual RelayMIner Requests", + "type": "timeseries" + }, + { + "datasource": { + "default": false, + "type": "grafana-postgresql-datasource", + "uid": "PCC52D03280B7034C" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "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": 8, + "w": 24, + "x": 0, + "y": 24 + }, + "id": 3, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "PCC52D03280B7034C" + }, + "editorMode": "code", + "format": "time_series", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(b.\"timestamp\", '$group_by') AS time,\n SUM(trim(both '\"' from ea_num_relays.value)::bigint) AS total_num_relays,\n (ea_claim.value::json ->> 'supplier_operator_address') AS supplier_operator_address,\n (ea_claim.value::json -> 'session_header' ->> 'service_id') AS service_id\nFROM\n localnet.events e\nJOIN\n localnet.event_attributes ea_num_relays ON ea_num_relays.event_id = e.id\n AND ea_num_relays.key = 'num_relays'\nJOIN\n localnet.event_attributes ea_claim ON ea_claim.event_id = e.id\n AND ea_claim.key = 'claim'\nJOIN\n localnet.blocks b ON b.id = e.block_id\nWHERE\n e.type = 'poktroll.proof.EventClaimCreated'\n AND b.\"timestamp\" BETWEEN $__timeFrom() AND $__timeTo()\nGROUP BY\n time, supplier_operator_address, service_id\nORDER BY\n time;\n", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Relays (from on-chain claims)", + "type": "timeseries" + }, + { + "datasource": { + "default": false, + "type": "grafana-postgresql-datasource", + "uid": "PCC52D03280B7034C" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "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": 8, + "w": 24, + "x": 0, + "y": 32 + }, + "id": 5, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "PCC52D03280B7034C" + }, + "editorMode": "code", + "format": "time_series", + "rawQuery": true, + "rawSql": "SELECT\n $__timeGroup(b.\"timestamp\", '$group_by') AS time,\n SUM(trim(both '\"' from ea_num_relays.value)::bigint) AS total_num_relays,\n (ea_proof.value::json ->> 'supplier_operator_address') AS supplier_operator_address,\n (ea_proof.value::json -> 'session_header' ->> 'service_id') AS service_id\nFROM\n localnet.events e\nJOIN\n localnet.event_attributes ea_num_relays ON ea_num_relays.event_id = e.id\n AND ea_num_relays.key = 'num_relays'\nJOIN\n localnet.event_attributes ea_proof ON ea_proof.event_id = e.id\n AND ea_proof.key = 'proof'\nJOIN\n localnet.blocks b ON b.id = e.block_id\nWHERE\n e.type = 'poktroll.proof.EventProofSubmitted'\n AND b.\"timestamp\" BETWEEN $__timeFrom() AND $__timeTo()\nGROUP BY\n time, supplier_operator_address, service_id\nORDER BY\n time;\n", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Relays (from on-chain proofs)", + "type": "timeseries" + } + ], + "refresh": "10s", + "schemaVersion": 39, + "tags": [], + "templating": { + "list": [ + { + "current": { + "selected": true, + "text": "1m", + "value": "1m" + }, + "hide": 0, + "includeAll": false, + "label": "Group by time / Window", + "multi": false, + "name": "group_by", + "options": [ + { + "selected": true, + "text": "1m", + "value": "1m" + }, + { + "selected": false, + "text": "5m", + "value": "5m" + }, + { + "selected": false, + "text": "10m", + "value": "10m" + }, + { + "selected": false, + "text": "15m", + "value": "15m" + } + ], + "query": "1m,5m,10m,15m", + "queryValue": "", + "skipUrlSync": false, + "type": "custom" + } + ] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": {}, + "timezone": "browser", + "title": "Protocol / Tokenomics / Relays life-cycle", + "version": 0, + "weekStart": "" +} \ No newline at end of file diff --git a/localnet/poktrolld/config/app.toml b/localnet/poktrolld/config/app.toml index 73e52cb05..d5135735e 100644 --- a/localnet/poktrolld/config/app.toml +++ b/localnet/poktrolld/config/app.toml @@ -61,6 +61,6 @@ query-gas-limit = "0" enabled = true global-labels = [] metrics-sink = "mem" - prometheus-retention-time = "10" + prometheus-retention-time = 86400 service-name = "" statsd-addr = "" diff --git a/pkg/relayer/proxy/metrics.go b/pkg/relayer/proxy/metrics.go index 76c005583..4fdea226e 100644 --- a/pkg/relayer/proxy/metrics.go +++ b/pkg/relayer/proxy/metrics.go @@ -29,7 +29,7 @@ var ( Subsystem: relayMinerProcess, Name: requestsTotal, Help: "Total number of requests processed, labeled by service ID.", - }, []string{"service_id"}) + }, []string{"service_id", "supplier_operator_address"}) // relaysErrorsTotal is a Counter for total error events in the relay miner. // It increments with each error, labeled by 'service_id', diff --git a/pkg/relayer/proxy/synchronous.go b/pkg/relayer/proxy/synchronous.go index fe447aa0f..a159686df 100644 --- a/pkg/relayer/proxy/synchronous.go +++ b/pkg/relayer/proxy/synchronous.go @@ -174,7 +174,7 @@ func (sync *synchronousRPCServer) ServeHTTP(writer http.ResponseWriter, request } // Increment the relays counter. - relaysTotal.With("service_id", supplierServiceId).Add(1) + relaysTotal.With("service_id", supplierServiceId, "supplier_operator_address", relayRequest.Meta.SupplierOperatorAddress).Add(1) defer func() { duration := time.Since(startTime).Seconds()