Files
errors.bitreport.pt/deploy/grafana/loki-logs-dashboard.json
T
David SantosandClaude Sonnet 4.6 8bb49ce32b feat(observability): integrate Loki for centralised log aggregation (BIT-14248)
Adds Grafana Loki + Promtail to the Docker Compose observability profile,
enabling structured-log collection from all errors.bitreport.pt services.

- deploy/loki/loki.yaml: Loki server (filesystem storage, TSDB v13, 30-day retention)
- deploy/loki/promtail.yaml: Docker SD auto-discovery, JSON parse, Pino level normalisation
- deploy/grafana/loki-logs-dashboard.json: Grafana log dashboard (uid er-loki-logs)
- docs/OBSERVABILITY_LOKI.md: setup, key LogQL queries, troubleshooting runbook
- docker-compose.yml: loki + promtail services under --profile observability; LOG_LEVEL env
- .env.example / ingest-api/.env.example: LOG_LEVEL + ER_PUBLISH_LOKI_PORT documented

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
2026-04-27 08:03:20 +00:00

568 lines
17 KiB
JSON

{
"__inputs": [
{
"name": "DS_LOKI",
"label": "Loki",
"description": "Loki log aggregation datasource",
"type": "datasource",
"pluginId": "loki",
"pluginName": "Loki"
}
],
"__requires": [
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "10.0.0"
},
{
"type": "datasource",
"id": "loki",
"name": "Loki",
"version": "1.0.0"
},
{
"type": "panel",
"id": "logs",
"name": "Logs",
"version": ""
},
{
"type": "panel",
"id": "timeseries",
"name": "Time series",
"version": ""
},
{
"type": "panel",
"id": "stat",
"name": "Stat",
"version": ""
},
{
"type": "panel",
"id": "piechart",
"name": "Pie chart",
"version": ""
}
],
"annotations": {
"list": []
},
"description": "Centralised log view for all errors.bitreport.pt services via Loki. Docs: docs/OBSERVABILITY_LOKI.md",
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 1,
"id": null,
"links": [
{
"icon": "external link",
"title": "Error Monitoring SLO",
"tooltip": "Prometheus operational dashboard",
"type": "link",
"url": "/d/er-ops-slo"
}
],
"panels": [
{
"collapsed": false,
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 },
"id": 100,
"title": "Overview",
"type": "row"
},
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"fieldConfig": {
"defaults": {
"color": { "mode": "thresholds" },
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 1 },
{ "color": "red", "value": 10 }
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": { "h": 4, "w": 4, "x": 0, "y": 1 },
"id": 1,
"options": {
"colorMode": "background",
"graphMode": "none",
"justifyMode": "center",
"orientation": "auto",
"reduceOptions": { "calcs": ["sum"], "fields": "", "values": false },
"textMode": "auto"
},
"title": "Errors (window)",
"type": "stat",
"targets": [
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"expr": "sum(count_over_time({app=\"errors-hub\", level=\"error\"}[$__range]))",
"legendFormat": "errors",
"refId": "A"
}
]
},
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"fieldConfig": {
"defaults": {
"color": { "mode": "thresholds" },
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "red", "value": 1 }
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": { "h": 4, "w": 4, "x": 4, "y": 1 },
"id": 2,
"options": {
"colorMode": "background",
"graphMode": "none",
"justifyMode": "center",
"orientation": "auto",
"reduceOptions": { "calcs": ["sum"], "fields": "", "values": false },
"textMode": "auto"
},
"title": "Fatals (window)",
"type": "stat",
"targets": [
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"expr": "sum(count_over_time({app=\"errors-hub\", level=\"fatal\"}[$__range]))",
"legendFormat": "fatals",
"refId": "A"
}
]
},
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"fieldConfig": {
"defaults": {
"color": { "mode": "thresholds" },
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "green", "value": null },
{ "color": "yellow", "value": 50 },
{ "color": "red", "value": 200 }
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": { "h": 4, "w": 4, "x": 8, "y": 1 },
"id": 3,
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "center",
"orientation": "auto",
"reduceOptions": { "calcs": ["sum"], "fields": "", "values": false },
"textMode": "auto"
},
"title": "Warnings (window)",
"type": "stat",
"targets": [
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"expr": "sum(count_over_time({app=\"errors-hub\", level=\"warn\"}[$__range]))",
"legendFormat": "warnings",
"refId": "A"
}
]
},
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"custom": {
"hideFrom": { "legend": false, "tooltip": false, "viz": false }
}
},
"overrides": []
},
"gridPos": { "h": 4, "w": 12, "x": 12, "y": 1 },
"id": 4,
"options": {
"displayLabels": ["name", "percent"],
"legend": { "displayMode": "table", "placement": "right", "values": ["value"] },
"pieType": "donut",
"tooltip": { "mode": "single", "sort": "none" }
},
"title": "Log volume by level (window)",
"type": "piechart",
"targets": [
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"expr": "sum by (level) (count_over_time({app=\"errors-hub\"}[$__range]))",
"legendFormat": "{{level}}",
"refId": "A"
}
]
},
{
"collapsed": false,
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 5 },
"id": 101,
"title": "Log Rate",
"type": "row"
},
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "lines/s",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "bars",
"fillOpacity": 70,
"gradientMode": "none",
"hideFrom": { "legend": false, "tooltip": false, "viz": false },
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": { "type": "linear" },
"showPoints": "never",
"spanNulls": false,
"stacking": { "group": "A", "mode": "normal" },
"thresholdsStyle": { "mode": "off" }
},
"mappings": [],
"thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }] },
"unit": "short"
},
"overrides": [
{ "matcher": { "id": "byName", "options": "error" }, "properties": [{ "id": "color", "value": { "fixedColor": "red", "mode": "fixed" } }] },
{ "matcher": { "id": "byName", "options": "fatal" }, "properties": [{ "id": "color", "value": { "fixedColor": "dark-red", "mode": "fixed" } }] },
{ "matcher": { "id": "byName", "options": "warn" }, "properties": [{ "id": "color", "value": { "fixedColor": "orange", "mode": "fixed" } }] },
{ "matcher": { "id": "byName", "options": "info" }, "properties": [{ "id": "color", "value": { "fixedColor": "blue", "mode": "fixed" } }] }
]
},
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 6 },
"id": 10,
"options": {
"legend": { "calcs": ["sum"], "displayMode": "table", "placement": "bottom", "showLegend": true },
"tooltip": { "mode": "multi", "sort": "desc" }
},
"title": "Log rate by level",
"type": "timeseries",
"targets": [
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"expr": "sum by (level) (rate({app=\"errors-hub\"}[2m]))",
"legendFormat": "{{level}}",
"refId": "A"
}
]
},
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "lines/s",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "bars",
"fillOpacity": 70,
"gradientMode": "none",
"hideFrom": { "legend": false, "tooltip": false, "viz": false },
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": { "type": "linear" },
"showPoints": "never",
"spanNulls": false,
"stacking": { "group": "A", "mode": "normal" },
"thresholdsStyle": { "mode": "off" }
},
"mappings": [],
"thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }] },
"unit": "short"
},
"overrides": []
},
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 6 },
"id": 11,
"options": {
"legend": { "calcs": ["sum"], "displayMode": "table", "placement": "bottom", "showLegend": true },
"tooltip": { "mode": "multi", "sort": "desc" }
},
"title": "Log rate by service",
"type": "timeseries",
"targets": [
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"expr": "sum by (service) (rate({app=\"errors-hub\"}[2m]))",
"legendFormat": "{{service}}",
"refId": "A"
}
]
},
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"fieldConfig": {
"defaults": {
"color": { "mode": "palette-classic" },
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "errors/s",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "bars",
"fillOpacity": 70,
"gradientMode": "none",
"hideFrom": { "legend": false, "tooltip": false, "viz": false },
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": { "type": "linear" },
"showPoints": "never",
"spanNulls": false,
"stacking": { "group": "A", "mode": "normal" },
"thresholdsStyle": { "mode": "off" }
},
"mappings": [],
"thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }, { "color": "red", "value": 0.01 }] },
"unit": "short"
},
"overrides": []
},
"gridPos": { "h": 8, "w": 24, "x": 0, "y": 14 },
"id": 12,
"options": {
"legend": { "calcs": ["max", "sum"], "displayMode": "table", "placement": "bottom", "showLegend": true },
"tooltip": { "mode": "multi", "sort": "desc" }
},
"title": "Error + Fatal rate by service",
"type": "timeseries",
"targets": [
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"expr": "sum by (service) (rate({app=\"errors-hub\", level=~\"error|fatal\"}[2m]))",
"legendFormat": "{{service}}",
"refId": "A"
}
]
},
{
"collapsed": false,
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 22 },
"id": 102,
"title": "Error & Fatal Logs",
"type": "row"
},
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"gridPos": { "h": 14, "w": 24, "x": 0, "y": 23 },
"id": 20,
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": false,
"showTime": true,
"sortOrder": "Descending",
"wrapLogMessage": true
},
"title": "Errors & Fatals — all services",
"type": "logs",
"targets": [
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"expr": "{app=\"errors-hub\", level=~\"error|fatal\"} | json",
"legendFormat": "",
"refId": "A"
}
]
},
{
"collapsed": false,
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 37 },
"id": 103,
"title": "Service Logs",
"type": "row"
},
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"gridPos": { "h": 10, "w": 12, "x": 0, "y": 38 },
"id": 30,
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": false,
"showTime": true,
"sortOrder": "Descending",
"wrapLogMessage": false
},
"title": "ingest-api logs",
"type": "logs",
"targets": [
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"expr": "{app=\"errors-hub\", service=\"ingest-api\"} | json | line_format \"[{{.level}}] {{.msg}}{{if .err}} err={{.err}}{{end}}\"",
"legendFormat": "",
"refId": "A"
}
]
},
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"gridPos": { "h": 10, "w": 12, "x": 12, "y": 38 },
"id": 31,
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": false,
"showTime": true,
"sortOrder": "Descending",
"wrapLogMessage": false
},
"title": "collector-worker logs",
"type": "logs",
"targets": [
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"expr": "{app=\"errors-hub\", service=\"collector-worker\"} | json | line_format \"[{{.level}}] {{.msg}}{{if .err}} err={{.err}}{{end}}\"",
"legendFormat": "",
"refId": "A"
}
]
},
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"gridPos": { "h": 10, "w": 12, "x": 0, "y": 48 },
"id": 32,
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": false,
"showTime": true,
"sortOrder": "Descending",
"wrapLogMessage": false
},
"title": "admin-ui logs",
"type": "logs",
"targets": [
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"expr": "{app=\"errors-hub\", service=\"admin-ui\"} | json",
"legendFormat": "",
"refId": "A"
}
]
},
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"gridPos": { "h": 10, "w": 12, "x": 12, "y": 48 },
"id": 33,
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": false,
"showTime": true,
"sortOrder": "Descending",
"wrapLogMessage": false
},
"title": "api logs",
"type": "logs",
"targets": [
{
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"expr": "{app=\"errors-hub\", service=\"api\"} | json | line_format \"[{{.level}}] {{.msg}}{{if .err}} err={{.err}}{{end}}\"",
"legendFormat": "",
"refId": "A"
}
]
}
],
"refresh": "30s",
"schemaVersion": 38,
"tags": ["bitreport", "loki", "logs"],
"templating": {
"list": [
{
"current": {},
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"definition": "label_values({app=\"errors-hub\"}, service)",
"hide": 0,
"includeAll": true,
"multi": true,
"name": "service",
"options": [],
"query": {
"label": "service",
"refId": "LokiVariableQueryEditor-VariableQuery",
"stream": "{app=\"errors-hub\"}",
"type": 1
},
"refresh": 2,
"sort": 1,
"type": "query",
"label": "Service"
},
{
"current": { "selected": false, "text": "All", "value": "$__all" },
"datasource": { "type": "loki", "uid": "${DS_LOKI}" },
"definition": "label_values({app=\"errors-hub\"}, level)",
"hide": 0,
"includeAll": true,
"multi": true,
"name": "level",
"options": [],
"query": {
"label": "level",
"refId": "LokiVariableQueryEditor-VariableQuery",
"stream": "{app=\"errors-hub\"}",
"type": 1
},
"refresh": 2,
"sort": 1,
"type": "query",
"label": "Level"
}
]
},
"time": { "from": "now-1h", "to": "now" },
"timepicker": {},
"timezone": "browser",
"title": "BitReport — Loki Logs",
"uid": "er-loki-logs",
"version": 1
}