Monitoring stack, containers and dashboards
CI / lint (push) Successful in 9s
CI / test (push) Successful in 36s
CI / notify (push) Successful in 5s

- API image (uv multi-stage, non-root, gunicorn, migrations on start,
  health check) and UI image (nginx, CSP, config.js rendered from
  API_BASE_URL); /healthz documented in OpenAPI
- docker compose runs db, api and ui; the "monitoring" profile adds
  Prometheus, postgres-exporter and Grafana, all provisioned from files
- Grafana dashboards: API overview (RED), Last.fm API, Usage, Database
- Prometheus alert rules: API down, error rate, latency, auth failure
  spike, ignored scrobbles, DB pool saturation, Postgres down
- Pool checkout gauge counts events (the pool's own counters lag the
  checkin event); error ratios show 0 instead of "No data"
- Tests check dashboards and alerts only use metrics that exist
- scripts/generate_traffic.py drives realistic traffic for demos

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
mattandClaude Opus 5.5 committed 2026-09-25 14:26:19 +01:00
1 parent faa74871a5
commit ea705589f1
28 files changed
+3508 -14

No files matched your search

+843
View File
@@ -0,0 +1,843 @@
{
"uid": "scrobbler-api-overview",
"title": "Scrobbler: API overview",
"description": "Rate, errors and duration for every endpoint of the Scrobbler API.",
"tags": [
"scrobbler"
],
"timezone": "browser",
"editable": true,
"graphTooltip": 1,
"refresh": "30s",
"time": {
"from": "now-6h",
"to": "now"
},
"schemaVersion": 41,
"version": 1,
"templating": {
"list": [
{
"name": "endpoint",
"label": "Endpoint",
"type": "query",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"query": {
"query": "label_values(scrobbler_http_requests_total, endpoint)",
"refId": "var"
},
"definition": "label_values(scrobbler_http_requests_total, endpoint)",
"includeAll": true,
"multi": true,
"allValue": ".*",
"current": {
"selected": true,
"text": [
"All"
],
"value": [
"$__all"
]
},
"refresh": 2,
"sort": 1
}
]
},
"annotations": {
"list": []
},
"links": [
{
"type": "dashboards",
"tags": [
"scrobbler"
],
"asDropdown": true,
"title": "Scrobbler",
"includeVars": false
}
],
"panels": [
{
"type": "row",
"title": "Health",
"id": 1,
"collapsed": false,
"gridPos": {
"x": 0,
"y": 0,
"w": 24,
"h": 1
},
"panels": []
},
{
"type": "stat",
"title": "API",
"description": "Is Prometheus able to scrape the API's metrics?",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "up{job=\"scrobbler-api\"}",
"legendFormat": "__auto",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "text",
"value": null
}
]
},
"mappings": [
{
"type": "value",
"options": {
"0": {
"text": "Down",
"color": "red"
},
"1": {
"text": "Up",
"color": "green"
}
}
}
]
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto",
"justifyMode": "auto"
},
"id": 2,
"gridPos": {
"x": 0,
"y": 1,
"w": 4,
"h": 4
}
},
{
"type": "stat",
"title": "Requests / s",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(rate(scrobbler_http_requests_total[$__rate_interval]))",
"legendFormat": "__auto",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"unit": "reqps",
"decimals": 2,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "text",
"value": null
}
]
}
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto",
"justifyMode": "auto"
},
"id": 3,
"gridPos": {
"x": 4,
"y": 1,
"w": 5,
"h": 4
}
},
{
"type": "stat",
"title": "Server errors",
"description": "Share of requests answered with a 5xx status.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "(sum(rate(scrobbler_http_requests_total{status=~\"5..\"}[$__rate_interval])) or vector(0)) / sum(rate(scrobbler_http_requests_total[$__rate_interval]))",
"legendFormat": "__auto",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"unit": "percentunit",
"decimals": 2,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "orange",
"value": 0.01
},
{
"color": "red",
"value": 0.05
}
]
}
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto",
"justifyMode": "auto"
},
"id": 4,
"gridPos": {
"x": 9,
"y": 1,
"w": 5,
"h": 4
}
},
{
"type": "stat",
"title": "p95 latency",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "histogram_quantile(0.95, sum by (le) (rate(scrobbler_http_request_duration_seconds_bucket[$__rate_interval])))",
"legendFormat": "__auto",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"unit": "s",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "orange",
"value": 0.5
},
{
"color": "red",
"value": 1
}
]
}
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto",
"justifyMode": "auto"
},
"id": 5,
"gridPos": {
"x": 14,
"y": 1,
"w": 5,
"h": 4
}
},
{
"type": "stat",
"title": "Version",
"description": "Version reported by the running API.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "max by (version) (scrobbler_build_info)",
"legendFormat": "{{version}}",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "text",
"value": null
}
]
}
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "name",
"justifyMode": "auto"
},
"id": 6,
"gridPos": {
"x": 19,
"y": 1,
"w": 5,
"h": 4
}
},
{
"type": "row",
"title": "Traffic",
"id": 7,
"collapsed": false,
"gridPos": {
"x": 0,
"y": 5,
"w": 24,
"h": 1
},
"panels": []
},
{
"type": "timeseries",
"title": "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=~\"$endpoint\"}[$__rate_interval]))",
"legendFormat": "{{endpoint}}",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"unit": "reqps",
"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": 8,
"gridPos": {
"x": 0,
"y": 6,
"w": 12,
"h": 8
}
},
{
"type": "timeseries",
"title": "Error ratio",
"description": "4xx is mostly clients (bad params, expired tokens); 5xx is us.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "(sum(rate(scrobbler_http_requests_total{endpoint=~\"$endpoint\",status=~\"5..\"}[$__rate_interval])) or vector(0)) / sum(rate(scrobbler_http_requests_total{endpoint=~\"$endpoint\"}[$__rate_interval]))",
"legendFormat": "5xx",
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "(sum(rate(scrobbler_http_requests_total{endpoint=~\"$endpoint\",status=~\"4..\"}[$__rate_interval])) or vector(0)) / sum(rate(scrobbler_http_requests_total{endpoint=~\"$endpoint\"}[$__rate_interval]))",
"legendFormat": "4xx",
"refId": "B"
}
],
"fieldConfig": {
"defaults": {
"unit": "percentunit",
"custom": {
"lineWidth": 2,
"fillOpacity": 10,
"showPoints": "never",
"spanNulls": true
},
"min": 0
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "5xx"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "red"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "4xx"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "orange"
}
}
]
}
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"id": 9,
"gridPos": {
"x": 12,
"y": 6,
"w": 12,
"h": 8
}
},
{
"type": "timeseries",
"title": "Requests / s by status",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (status) (rate(scrobbler_http_requests_total{endpoint=~\"$endpoint\"}[$__rate_interval]))",
"legendFormat": "{{status}}",
"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": 10,
"gridPos": {
"x": 0,
"y": 14,
"w": 12,
"h": 8
}
},
{
"type": "timeseries",
"title": "In-flight requests",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (endpoint) (scrobbler_http_requests_in_progress{endpoint=~\"$endpoint\"})",
"legendFormat": "{{endpoint}}",
"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": 11,
"gridPos": {
"x": 12,
"y": 14,
"w": 12,
"h": 8
}
},
{
"type": "row",
"title": "Latency",
"id": 12,
"collapsed": false,
"gridPos": {
"x": 0,
"y": 22,
"w": 24,
"h": 1
},
"panels": []
},
{
"type": "timeseries",
"title": "Latency percentiles",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "histogram_quantile(0.50, sum by (le) (rate(scrobbler_http_request_duration_seconds_bucket{endpoint=~\"$endpoint\"}[$__rate_interval])))",
"legendFormat": "p50",
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "histogram_quantile(0.95, sum by (le) (rate(scrobbler_http_request_duration_seconds_bucket{endpoint=~\"$endpoint\"}[$__rate_interval])))",
"legendFormat": "p95",
"refId": "B"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "histogram_quantile(0.99, sum by (le) (rate(scrobbler_http_request_duration_seconds_bucket{endpoint=~\"$endpoint\"}[$__rate_interval])))",
"legendFormat": "p99",
"refId": "C"
}
],
"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": 13,
"gridPos": {
"x": 0,
"y": 23,
"w": 12,
"h": 9
}
},
{
"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=~\"$endpoint\"}[$__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": 14,
"gridPos": {
"x": 12,
"y": 23,
"w": 12,
"h": 9
}
},
{
"type": "table",
"title": "Slowest endpoints (p95 over the selected range)",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "topk(10, histogram_quantile(0.95, sum by (le, endpoint) (rate(scrobbler_http_request_duration_seconds_bucket[$__range]))))",
"legendFormat": "{{endpoint}}",
"refId": "A",
"instant": true,
"range": false,
"format": "table"
}
],
"fieldConfig": {
"defaults": {
"unit": "s"
},
"overrides": []
},
"options": {
"showHeader": true,
"sortBy": [
{
"displayName": "Value",
"desc": true
}
]
},
"transformations": [
{
"id": "organize",
"options": {
"excludeByName": {
"Time": true
},
"renameByName": {
"Value": "p95"
}
}
}
],
"id": 15,
"gridPos": {
"x": 0,
"y": 32,
"w": 24,
"h": 8
}
}
]
}
+790
View File
@@ -0,0 +1,790 @@
{
"uid": "scrobbler-database",
"title": "Scrobbler: Database",
"description": "Query latency and pool use from the app's side; Postgres health from postgres-exporter.",
"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": "From the API",
"id": 1,
"collapsed": false,
"gridPos": {
"x": 0,
"y": 0,
"w": 24,
"h": 1
},
"panels": []
},
{
"type": "timeseries",
"title": "Query latency by operation (p95)",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "histogram_quantile(0.95, sum by (le, operation) (rate(scrobbler_db_query_duration_seconds_bucket[$__rate_interval])))",
"legendFormat": "{{operation}}",
"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": 2,
"gridPos": {
"x": 0,
"y": 1,
"w": 12,
"h": 8
}
},
{
"type": "timeseries",
"title": "Queries / s by operation",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (operation) (rate(scrobbler_db_query_duration_seconds_count[$__rate_interval]))",
"legendFormat": "{{operation}}",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"unit": "ops",
"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": 3,
"gridPos": {
"x": 12,
"y": 1,
"w": 12,
"h": 8
}
},
{
"type": "timeseries",
"title": "Connection pool",
"description": "Summed across gunicorn workers. In use at or above pool size means requests are running on overflow connections.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(scrobbler_db_pool_connections{state=\"checked_out\"})",
"legendFormat": "in use",
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(scrobbler_db_pool_connections{state=\"overflow\"})",
"legendFormat": "overflow",
"refId": "B"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(scrobbler_db_pool_connections{state=\"size\"})",
"legendFormat": "pool size",
"refId": "C"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"custom": {
"lineWidth": 2,
"fillOpacity": 10,
"showPoints": "never",
"spanNulls": true
},
"min": 0
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "pool size"
},
"properties": [
{
"id": "custom.lineStyle",
"value": {
"fill": "dash",
"dash": [
10,
10
]
}
},
{
"id": "custom.fillOpacity",
"value": 0
}
]
}
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"id": 4,
"gridPos": {
"x": 0,
"y": 9,
"w": 12,
"h": 8
}
},
{
"type": "timeseries",
"title": "Query latency percentiles (all operations)",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "histogram_quantile(0.50, sum by (le) (rate(scrobbler_db_query_duration_seconds_bucket[$__rate_interval])))",
"legendFormat": "p50",
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "histogram_quantile(0.99, sum by (le) (rate(scrobbler_db_query_duration_seconds_bucket[$__rate_interval])))",
"legendFormat": "p99",
"refId": "B"
}
],
"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": 5,
"gridPos": {
"x": 12,
"y": 9,
"w": 12,
"h": 8
}
},
{
"type": "row",
"title": "Postgres",
"id": 6,
"collapsed": false,
"gridPos": {
"x": 0,
"y": 17,
"w": 24,
"h": 1
},
"panels": []
},
{
"type": "stat",
"title": "Postgres",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "pg_up",
"legendFormat": "__auto",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "text",
"value": null
}
]
},
"mappings": [
{
"type": "value",
"options": {
"0": {
"text": "Down",
"color": "red"
},
"1": {
"text": "Up",
"color": "green"
}
}
}
]
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto",
"justifyMode": "auto"
},
"id": 7,
"gridPos": {
"x": 0,
"y": 18,
"w": 4,
"h": 5
}
},
{
"type": "stat",
"title": "Database size",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "pg_database_size_bytes{datname=\"scrobbler\"}",
"legendFormat": "__auto",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"unit": "bytes",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "text",
"value": null
}
]
}
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto",
"justifyMode": "auto"
},
"id": 8,
"gridPos": {
"x": 4,
"y": 18,
"w": 5,
"h": 5
}
},
{
"type": "stat",
"title": "Connections",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(pg_stat_database_numbackends{datname=\"scrobbler\"})",
"legendFormat": "__auto",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "text",
"value": null
}
]
}
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto",
"justifyMode": "auto"
},
"id": 9,
"gridPos": {
"x": 9,
"y": 18,
"w": 5,
"h": 5
}
},
{
"type": "stat",
"title": "Cache hit ratio",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(rate(pg_stat_database_blks_hit{datname=\"scrobbler\"}[$__rate_interval])) / (sum(rate(pg_stat_database_blks_hit{datname=\"scrobbler\"}[$__rate_interval])) + sum(rate(pg_stat_database_blks_read{datname=\"scrobbler\"}[$__rate_interval])))",
"legendFormat": "__auto",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"unit": "percentunit",
"decimals": 1,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "orange",
"value": 0.9
},
{
"color": "green",
"value": 0.99
}
]
}
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto",
"justifyMode": "auto"
},
"id": 10,
"gridPos": {
"x": 14,
"y": 18,
"w": 5,
"h": 5
}
},
{
"type": "stat",
"title": "Deadlocks (range)",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(pg_stat_database_deadlocks{datname=\"scrobbler\"}[$__range]))",
"legendFormat": "__auto",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"decimals": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 1
}
]
}
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto",
"justifyMode": "auto"
},
"id": 11,
"gridPos": {
"x": 19,
"y": 18,
"w": 5,
"h": 5
}
},
{
"type": "timeseries",
"title": "Transactions / s",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(rate(pg_stat_database_xact_commit{datname=\"scrobbler\"}[$__rate_interval]))",
"legendFormat": "commits",
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(rate(pg_stat_database_xact_rollback{datname=\"scrobbler\"}[$__rate_interval]))",
"legendFormat": "rollbacks",
"refId": "B"
}
],
"fieldConfig": {
"defaults": {
"unit": "ops",
"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": 12,
"gridPos": {
"x": 0,
"y": 23,
"w": 12,
"h": 8
}
},
{
"type": "timeseries",
"title": "Locks by mode",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (mode) (pg_locks_count{datname=\"scrobbler\"})",
"legendFormat": "{{mode}}",
"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": 13,
"gridPos": {
"x": 12,
"y": 23,
"w": 12,
"h": 8
}
},
{
"type": "timeseries",
"title": "Database size",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "pg_database_size_bytes{datname=\"scrobbler\"}",
"legendFormat": "scrobbler",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"unit": "bytes",
"custom": {
"lineWidth": 2,
"fillOpacity": 10,
"showPoints": "never",
"spanNulls": true
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"id": 14,
"gridPos": {
"x": 0,
"y": 31,
"w": 24,
"h": 7
}
}
]
}
+656
View File
@@ -0,0 +1,656 @@
{
"uid": "scrobbler-lastfm",
"title": "Scrobbler: Last.fm API",
"description": "The Last.fm-compatible /2.0/ API: which methods clients call, what fails, and what happens to scrobbles.",
"tags": [
"scrobbler"
],
"timezone": "browser",
"editable": true,
"graphTooltip": 1,
"refresh": "30s",
"time": {
"from": "now-6h",
"to": "now"
},
"schemaVersion": 41,
"version": 1,
"templating": {
"list": [
{
"name": "method",
"label": "Method",
"type": "query",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"query": {
"query": "label_values(scrobbler_lastfm_requests_total, lastfm_method)",
"refId": "var"
},
"definition": "label_values(scrobbler_lastfm_requests_total, lastfm_method)",
"includeAll": true,
"multi": true,
"allValue": ".*",
"current": {
"selected": true,
"text": [
"All"
],
"value": [
"$__all"
]
},
"refresh": 2,
"sort": 1
}
]
},
"annotations": {
"list": []
},
"links": [
{
"type": "dashboards",
"tags": [
"scrobbler"
],
"asDropdown": true,
"title": "Scrobbler",
"includeVars": false
}
],
"panels": [
{
"type": "row",
"title": "Calls",
"id": 1,
"collapsed": false,
"gridPos": {
"x": 0,
"y": 0,
"w": 24,
"h": 1
},
"panels": []
},
{
"type": "timeseries",
"title": "Calls / s by method",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (lastfm_method) (rate(scrobbler_lastfm_requests_total{lastfm_method=~\"$method\"}[$__rate_interval]))",
"legendFormat": "{{lastfm_method}}",
"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": 2,
"gridPos": {
"x": 0,
"y": 1,
"w": 12,
"h": 8
}
},
{
"type": "timeseries",
"title": "p95 latency by method",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "histogram_quantile(0.95, sum by (le, lastfm_method) (rate(scrobbler_lastfm_request_duration_seconds_bucket{lastfm_method=~\"$method\"}[$__rate_interval])))",
"legendFormat": "{{lastfm_method}}",
"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": 3,
"gridPos": {
"x": 12,
"y": 1,
"w": 12,
"h": 8
}
},
{
"type": "timeseries",
"title": "Errors by Last.fm code",
"description": "3 unknown method, 4 bad password/token, 6 bad parameters, 9 bad session key, 10 bad API key, 13 bad signature, 14 unapproved token, 15 expired token.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (code) (rate(scrobbler_lastfm_errors_total{lastfm_method=~\"$method\"}[$__rate_interval]))",
"legendFormat": "error {{code}}",
"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": 4,
"gridPos": {
"x": 0,
"y": 9,
"w": 12,
"h": 8
}
},
{
"type": "timeseries",
"title": "Authentication failures by reason",
"description": "Includes both Last.fm and signature failures. A spike from one reason usually means one misconfigured client.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (reason) (rate(scrobbler_auth_failures_total[$__rate_interval]))",
"legendFormat": "{{reason}}",
"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": 12,
"y": 9,
"w": 12,
"h": 8
}
},
{
"type": "row",
"title": "Scrobbles",
"id": 6,
"collapsed": false,
"gridPos": {
"x": 0,
"y": 17,
"w": 24,
"h": 1
},
"panels": []
},
{
"type": "timeseries",
"title": "Scrobbles / min by result",
"description": "Duplicates are resubmissions of scrobbles already stored (normal for clients that retry).",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (result) (rate(scrobbler_scrobbles_total[$__rate_interval])) * 60",
"legendFormat": "{{result}}",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"custom": {
"lineWidth": 2,
"fillOpacity": 40,
"showPoints": "never",
"spanNulls": true,
"stacking": {
"mode": "normal",
"group": "A"
}
},
"min": 0
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "accepted"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "green"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "duplicate"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "blue"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "ignored"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "orange"
}
}
]
}
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"id": 7,
"gridPos": {
"x": 0,
"y": 18,
"w": 12,
"h": 8
}
},
{
"type": "timeseries",
"title": "Ignored scrobbles by reason",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(scrobbler_scrobbles_ignored_total{reason=\"1\"}[$__rate_interval]))",
"legendFormat": "Empty artist",
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(scrobbler_scrobbles_ignored_total{reason=\"2\"}[$__rate_interval]))",
"legendFormat": "Empty track",
"refId": "B"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(scrobbler_scrobbles_ignored_total{reason=\"3\"}[$__rate_interval]))",
"legendFormat": "Too old (>14 days)",
"refId": "C"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(scrobbler_scrobbles_ignored_total{reason=\"4\"}[$__rate_interval]))",
"legendFormat": "In the future",
"refId": "D"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"custom": {
"lineWidth": 1,
"fillOpacity": 70,
"showPoints": "never",
"spanNulls": true,
"stacking": {
"mode": "normal",
"group": "A"
},
"drawStyle": "bars"
},
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"id": 8,
"gridPos": {
"x": 12,
"y": 18,
"w": 12,
"h": 8
}
},
{
"type": "heatmap",
"title": "Tracks per scrobble request",
"description": "Large batches are clients flushing an offline cache.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (le) (increase(scrobbler_scrobble_batch_size_bucket[$__rate_interval]))",
"legendFormat": "{{le}}",
"refId": "A",
"format": "heatmap"
}
],
"options": {
"calculate": false,
"yAxis": {
"unit": "short"
},
"color": {
"mode": "scheme",
"scheme": "Oranges",
"steps": 64
},
"cellGap": 1,
"tooltip": {
"mode": "single",
"yHistogram": true
}
},
"id": 9,
"gridPos": {
"x": 0,
"y": 26,
"w": 8,
"h": 8
}
},
{
"type": "timeseries",
"title": "Scrobble lag",
"description": "Time between a track being played and its scrobble arriving.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "histogram_quantile(0.50, sum by (le) (rate(scrobbler_scrobble_lag_seconds_bucket[$__rate_interval])))",
"legendFormat": "p50",
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "histogram_quantile(0.95, sum by (le) (rate(scrobbler_scrobble_lag_seconds_bucket[$__rate_interval])))",
"legendFormat": "p95",
"refId": "B"
}
],
"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": 10,
"gridPos": {
"x": 8,
"y": 26,
"w": 8,
"h": 8
}
},
{
"type": "timeseries",
"title": "Now playing & sign-ins",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(rate(scrobbler_now_playing_updates_total[$__rate_interval])) * 60",
"legendFormat": "now-playing updates / min",
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (flow) (increase(scrobbler_auth_sessions_created_total[$__rate_interval]))",
"legendFormat": "sessions created ({{flow}})",
"refId": "B"
}
],
"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": 11,
"gridPos": {
"x": 16,
"y": 26,
"w": 8,
"h": 8
}
}
]
}
+574
View File
@@ -0,0 +1,574 @@
{
"uid": "scrobbler-usage",
"title": "Scrobbler: Usage",
"description": "Who is using the service and how much they're listening.",
"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": "Now",
"id": 1,
"collapsed": false,
"gridPos": {
"x": 0,
"y": 0,
"w": 24,
"h": 1
},
"panels": []
},
{
"type": "stat",
"title": "Scrobbles in the last 24h",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(scrobbler_scrobbles_total{result=\"accepted\"}[24h]))",
"legendFormat": "__auto",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"decimals": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "text",
"value": null
}
]
}
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto",
"justifyMode": "auto"
},
"id": 2,
"gridPos": {
"x": 0,
"y": 1,
"w": 6,
"h": 5
}
},
{
"type": "stat",
"title": "Users",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "max(scrobbler_users)",
"legendFormat": "__auto",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "text",
"value": null
}
]
}
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto",
"justifyMode": "auto"
},
"id": 3,
"gridPos": {
"x": 6,
"y": 1,
"w": 6,
"h": 5
}
},
{
"type": "stat",
"title": "Active in the last 24h",
"description": "Users with at least one scrobble in the last 24 hours.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "max(scrobbler_active_users{window=\"24h\"})",
"legendFormat": "__auto",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "text",
"value": null
}
]
}
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto",
"justifyMode": "auto"
},
"id": 4,
"gridPos": {
"x": 12,
"y": 1,
"w": 6,
"h": 5
}
},
{
"type": "stat",
"title": "Listening now",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "max(scrobbler_now_playing_active)",
"legendFormat": "__auto",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "text",
"value": null
}
]
}
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto",
"justifyMode": "auto"
},
"id": 5,
"gridPos": {
"x": 18,
"y": 1,
"w": 6,
"h": 5
}
},
{
"type": "row",
"title": "Listening",
"id": 6,
"collapsed": false,
"gridPos": {
"x": 0,
"y": 6,
"w": 24,
"h": 1
},
"panels": []
},
{
"type": "timeseries",
"title": "Scrobbles / min",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(rate(scrobbler_scrobbles_total{result=\"accepted\"}[$__rate_interval])) * 60",
"legendFormat": "accepted",
"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": 7,
"w": 12,
"h": 8
}
},
{
"type": "timeseries",
"title": "Listening now",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "max(scrobbler_now_playing_active)",
"legendFormat": "users playing a track",
"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": 8,
"gridPos": {
"x": 12,
"y": 7,
"w": 12,
"h": 8
}
},
{
"type": "timeseries",
"title": "Scrobbles per day",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(scrobbler_scrobbles_total{result=\"accepted\"}[1d]))",
"legendFormat": "scrobbles",
"refId": "A",
"interval": "1d"
}
],
"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"
}
},
"timeFrom": "30d",
"id": 9,
"gridPos": {
"x": 0,
"y": 15,
"w": 24,
"h": 8
}
},
{
"type": "row",
"title": "People",
"id": 10,
"collapsed": false,
"gridPos": {
"x": 0,
"y": 23,
"w": 24,
"h": 1
},
"panels": []
},
{
"type": "timeseries",
"title": "Active users",
"description": "Distinct users scrobbling within each window.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "max by (window) (scrobbler_active_users)",
"legendFormat": "{{window}}",
"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": 11,
"gridPos": {
"x": 0,
"y": 24,
"w": 12,
"h": 8
}
},
{
"type": "timeseries",
"title": "Sign-ups and web logins",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(scrobbler_registrations_total[$__rate_interval]))",
"legendFormat": "registrations",
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(scrobbler_ui_logins_total{result=\"success\"}[$__rate_interval]))",
"legendFormat": "logins",
"refId": "B"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(increase(scrobbler_ui_logins_total{result=\"failure\"}[$__rate_interval]))",
"legendFormat": "failed logins",
"refId": "C"
}
],
"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": 12,
"gridPos": {
"x": 12,
"y": 24,
"w": 12,
"h": 8
}
}
]
}
@@ -0,0 +1,8 @@
apiVersion: 1
providers:
- name: scrobbler
folder: Scrobbler
type: file
allowUiUpdates: true
options:
path: /var/lib/grafana/dashboards
@@ -0,0 +1,10 @@
apiVersion: 1
datasources:
- name: Prometheus
uid: prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
jsonData:
timeInterval: 15s
+23
View File
@@ -0,0 +1,23 @@
# Rendered by the nginx image's envsubst step (API_BASE_URL comes from the environment).
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
server_tokens off;
# add_header isn't inherited by locations that set their own, so the security
# headers live in the location that serves pages.
location / {
try_files $uri $uri/ =404;
# Files aren't fingerprinted, so always revalidate.
add_header Cache-Control "no-cache";
add_header Content-Security-Policy "default-src 'self'; connect-src 'self' ${API_BASE_URL}; img-src 'self' data:; style-src 'self'; font-src 'self'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'" always;
add_header X-Content-Type-Options nosniff always;
add_header Referrer-Policy same-origin always;
}
location /fonts/ {
add_header Cache-Control "public, max-age=2592000, immutable";
}
}
+65
View File
@@ -0,0 +1,65 @@
groups:
- name: scrobbler
rules:
- alert: ScrobblerDown
expr: up{job="scrobbler-api"} == 0
for: 2m
labels: {severity: critical}
annotations:
summary: Scrobbler API metrics endpoint is down
description: Prometheus hasn't been able to scrape {{ $labels.instance }} for 2 minutes.
- alert: HighErrorRate
expr: |
sum(rate(scrobbler_http_requests_total{status=~"5.."}[5m]))
/ sum(rate(scrobbler_http_requests_total[5m])) > 0.05
for: 5m
labels: {severity: critical}
annotations:
summary: More than 5% of API requests are failing
description: 5xx ratio is {{ $value | humanizePercentage }}.
- alert: HighLatency
expr: |
histogram_quantile(0.95,
sum by (le) (rate(scrobbler_http_request_duration_seconds_bucket[5m]))) > 1
for: 10m
labels: {severity: warning}
annotations:
summary: API p95 latency is above 1s
description: p95 latency is {{ $value | humanizeDuration }}.
- alert: AuthFailureSpike
expr: sum(rate(scrobbler_auth_failures_total[5m])) > 10
for: 5m
labels: {severity: warning}
annotations:
summary: Unusually many authentication failures
description: "{{ $value | humanize }} failures/s: check for a misconfigured client or credential stuffing."
- alert: ScrobbleIgnoreRateHigh
expr: |
sum(rate(scrobbler_scrobbles_total{result="ignored"}[15m]))
/ sum(rate(scrobbler_scrobbles_total[15m])) > 0.2
for: 15m
labels: {severity: warning}
annotations:
summary: More than 20% of scrobbles are being ignored
description: A client may be sending bad timestamps or empty metadata.
- alert: DBPoolExhausted
expr: |
sum(scrobbler_db_pool_connections{state="checked_out"})
>= sum(scrobbler_db_pool_connections{state="size"})
for: 5m
labels: {severity: warning}
annotations:
summary: Every pooled database connection is in use
description: Workers are running on overflow connections; requests may queue.
- alert: PostgresDown
expr: pg_up == 0
for: 2m
labels: {severity: critical}
annotations:
summary: Postgres is unreachable from postgres-exporter
+19
View File
@@ -0,0 +1,19 @@
global:
scrape_interval: 15s
evaluation_interval: 15s
rule_files:
- alerts.yml
scrape_configs:
- job_name: scrobbler-api
static_configs:
- targets: ["api:9100"]
- job_name: postgres
static_configs:
- targets: ["postgres-exporter:9187"]
- job_name: prometheus
static_configs:
- targets: ["localhost:9090"]