Federation dashboard (phase 1, step 7)
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 10s
CI / test (push) Successful in 1m5s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 10s
CI / test (push) Successful in 1m5s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s
A fifth provisioned Grafana dashboard: fediverse lookups by kind and result, sharing switched on/off, federation endpoint rates and p95 latency, and inbox deliveries. Dashboard tests now know federation's own metrics, and a new test rejects PromQL string escapes Prometheus can't parse (the endpoint filter first used \. and failed live). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
1 parent
f21ce173b8
commit
913ef67aca
2 files changed
+347
-3
No files matched your search
@@ -0,0 +1,327 @@
|
|||||||
|
{
|
||||||
|
"uid": "scrobbler-federation",
|
||||||
|
"title": "Scrobbler: Federation",
|
||||||
|
"description": "ActivityPub: how the fediverse finds and talks to users sharing their listening. Empty unless FEDERATION_ENABLED is on.",
|
||||||
|
"tags": [
|
||||||
|
"scrobbler"
|
||||||
|
],
|
||||||
|
"timezone": "browser",
|
||||||
|
"editable": true,
|
||||||
|
"graphTooltip": 1,
|
||||||
|
"refresh": "30s",
|
||||||
|
"time": {
|
||||||
|
"from": "now-6h",
|
||||||
|
"to": "now"
|
||||||
|
},
|
||||||
|
"schemaVersion": 41,
|
||||||
|
"version": 1,
|
||||||
|
"templating": {
|
||||||
|
"list": []
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"list": []
|
||||||
|
},
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"type": "dashboards",
|
||||||
|
"tags": [
|
||||||
|
"scrobbler"
|
||||||
|
],
|
||||||
|
"asDropdown": true,
|
||||||
|
"title": "Scrobbler",
|
||||||
|
"includeVars": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"panels": [
|
||||||
|
{
|
||||||
|
"type": "row",
|
||||||
|
"title": "Discovery",
|
||||||
|
"id": 1,
|
||||||
|
"collapsed": false,
|
||||||
|
"gridPos": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"w": 24,
|
||||||
|
"h": 1
|
||||||
|
},
|
||||||
|
"panels": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "Lookups / min by kind",
|
||||||
|
"description": "WebFinger, actor, NodeInfo and profile-page lookups. 'not_found' covers both unknown users and users not sharing.",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"expr": "sum by (kind, result) (rate(scrobbler_federation_lookups_total[$__rate_interval])) * 60",
|
||||||
|
"legendFormat": "{{kind}} {{result}}",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "short",
|
||||||
|
"custom": {
|
||||||
|
"lineWidth": 2,
|
||||||
|
"fillOpacity": 40,
|
||||||
|
"showPoints": "never",
|
||||||
|
"spanNulls": true,
|
||||||
|
"stacking": {
|
||||||
|
"mode": "normal",
|
||||||
|
"group": "A"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"min": 0
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"legend": {
|
||||||
|
"displayMode": "list",
|
||||||
|
"placement": "bottom",
|
||||||
|
"showLegend": true
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"mode": "multi",
|
||||||
|
"sort": "desc"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": 2,
|
||||||
|
"gridPos": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 1,
|
||||||
|
"w": 12,
|
||||||
|
"h": 8
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "Sharing switched on / off",
|
||||||
|
"description": "",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"expr": "sum by (change) (increase(scrobbler_federation_sharing_changes_total[$__rate_interval]))",
|
||||||
|
"legendFormat": "{{change}}",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "short",
|
||||||
|
"custom": {
|
||||||
|
"lineWidth": 1,
|
||||||
|
"fillOpacity": 70,
|
||||||
|
"showPoints": "never",
|
||||||
|
"spanNulls": true,
|
||||||
|
"drawStyle": "bars"
|
||||||
|
},
|
||||||
|
"min": 0
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"legend": {
|
||||||
|
"displayMode": "list",
|
||||||
|
"placement": "bottom",
|
||||||
|
"showLegend": true
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"mode": "multi",
|
||||||
|
"sort": "desc"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": 3,
|
||||||
|
"gridPos": {
|
||||||
|
"x": 12,
|
||||||
|
"y": 1,
|
||||||
|
"w": 12,
|
||||||
|
"h": 8
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "row",
|
||||||
|
"title": "Traffic",
|
||||||
|
"id": 4,
|
||||||
|
"collapsed": false,
|
||||||
|
"gridPos": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 9,
|
||||||
|
"w": 24,
|
||||||
|
"h": 1
|
||||||
|
},
|
||||||
|
"panels": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "Federation requests / s by endpoint",
|
||||||
|
"description": "",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"expr": "sum by (endpoint) (rate(scrobbler_http_requests_total{endpoint=~\"(federation|Federation)[.].*\"}[$__rate_interval]))",
|
||||||
|
"legendFormat": "{{endpoint}}",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "reqps",
|
||||||
|
"custom": {
|
||||||
|
"lineWidth": 2,
|
||||||
|
"fillOpacity": 40,
|
||||||
|
"showPoints": "never",
|
||||||
|
"spanNulls": true,
|
||||||
|
"stacking": {
|
||||||
|
"mode": "normal",
|
||||||
|
"group": "A"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"min": 0
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"legend": {
|
||||||
|
"displayMode": "list",
|
||||||
|
"placement": "bottom",
|
||||||
|
"showLegend": true
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"mode": "multi",
|
||||||
|
"sort": "desc"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": 5,
|
||||||
|
"gridPos": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 10,
|
||||||
|
"w": 12,
|
||||||
|
"h": 8
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "p95 latency by endpoint",
|
||||||
|
"description": "",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"expr": "histogram_quantile(0.95, sum by (le, endpoint) (rate(scrobbler_http_request_duration_seconds_bucket{endpoint=~\"(federation|Federation)[.].*\"}[$__rate_interval])))",
|
||||||
|
"legendFormat": "{{endpoint}}",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "s",
|
||||||
|
"custom": {
|
||||||
|
"lineWidth": 2,
|
||||||
|
"fillOpacity": 10,
|
||||||
|
"showPoints": "never",
|
||||||
|
"spanNulls": true
|
||||||
|
},
|
||||||
|
"min": 0
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"legend": {
|
||||||
|
"displayMode": "list",
|
||||||
|
"placement": "bottom",
|
||||||
|
"showLegend": true
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"mode": "multi",
|
||||||
|
"sort": "desc"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": 6,
|
||||||
|
"gridPos": {
|
||||||
|
"x": 12,
|
||||||
|
"y": 10,
|
||||||
|
"w": 12,
|
||||||
|
"h": 8
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "Inbox deliveries / min",
|
||||||
|
"description": "Activities other servers send us (follows, likes, ...). Accepted but not yet processed until following is implemented.",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"expr": "sum by (inbox) (rate(scrobbler_federation_inbox_requests_total[$__rate_interval])) * 60",
|
||||||
|
"legendFormat": "{{inbox}}",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "short",
|
||||||
|
"custom": {
|
||||||
|
"lineWidth": 2,
|
||||||
|
"fillOpacity": 10,
|
||||||
|
"showPoints": "never",
|
||||||
|
"spanNulls": true
|
||||||
|
},
|
||||||
|
"min": 0
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"legend": {
|
||||||
|
"displayMode": "list",
|
||||||
|
"placement": "bottom",
|
||||||
|
"showLegend": true
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"mode": "multi",
|
||||||
|
"sort": "desc"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": 7,
|
||||||
|
"gridPos": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 18,
|
||||||
|
"w": 24,
|
||||||
|
"h": 7
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import yaml
|
|||||||
from prometheus_client.metrics import MetricWrapperBase
|
from prometheus_client.metrics import MetricWrapperBase
|
||||||
|
|
||||||
from scrobbler import metrics
|
from scrobbler import metrics
|
||||||
|
from scrobbler.federation import metrics as federation_metrics
|
||||||
|
|
||||||
DEPLOY = Path(__file__).resolve().parents[1] / "deploy"
|
DEPLOY = Path(__file__).resolve().parents[1] / "deploy"
|
||||||
DASHBOARDS = sorted((DEPLOY / "grafana" / "dashboards").glob("*.json"))
|
DASHBOARDS = sorted((DEPLOY / "grafana" / "dashboards").glob("*.json"))
|
||||||
@@ -16,7 +17,8 @@ METRIC_NAME = re.compile(r"\bscrobbler_[a-z0-9_]+")
|
|||||||
def defined_series() -> set[str]:
|
def defined_series() -> set[str]:
|
||||||
"""Every series name the service can export."""
|
"""Every series name the service can export."""
|
||||||
names = set(metrics.COLLECTED.values())
|
names = set(metrics.COLLECTED.values())
|
||||||
for value in vars(metrics).values():
|
modules = (metrics, federation_metrics)
|
||||||
|
for value in (v for module in modules for v in vars(module).values()):
|
||||||
if not isinstance(value, MetricWrapperBase):
|
if not isinstance(value, MetricWrapperBase):
|
||||||
continue
|
continue
|
||||||
name, kind = value._name, value._type
|
name, kind = value._name, value._type
|
||||||
@@ -41,8 +43,14 @@ def exprs(node):
|
|||||||
yield from exprs(item)
|
yield from exprs(item)
|
||||||
|
|
||||||
|
|
||||||
def test_there_are_four_dashboards():
|
def test_the_expected_dashboards_exist():
|
||||||
assert {p.stem for p in DASHBOARDS} == {"api-overview", "lastfm-api", "usage", "database"}
|
assert {p.stem for p in DASHBOARDS} == {
|
||||||
|
"api-overview",
|
||||||
|
"lastfm-api",
|
||||||
|
"usage",
|
||||||
|
"database",
|
||||||
|
"federation",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_dashboard_uids_are_unique():
|
def test_dashboard_uids_are_unique():
|
||||||
@@ -75,3 +83,12 @@ def test_alert_rules_only_use_defined_metrics():
|
|||||||
for name in METRIC_NAME.findall(rule["expr"])
|
for name in METRIC_NAME.findall(rule["expr"])
|
||||||
}
|
}
|
||||||
assert used <= defined_series(), f"undefined metrics: {sorted(used - defined_series())}"
|
assert used <= defined_series(), f"undefined metrics: {sorted(used - defined_series())}"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("path", DASHBOARDS, ids=lambda p: p.stem)
|
||||||
|
def test_queries_have_no_invalid_string_escapes(path):
|
||||||
|
"""PromQL rejects escapes like \\. inside double-quoted strings (Grafana would show a
|
||||||
|
query error); use a character class such as [.] instead."""
|
||||||
|
invalid = re.compile(r'(?<!\\)\\[^\\"nrtabfvxuU0-7]')
|
||||||
|
for expr in exprs(json.loads(path.read_text())):
|
||||||
|
assert not invalid.search(expr), f"invalid escape in {path.name}: {expr}"
|
||||||
Reference in new issue
Block a user