feat: SQL-Views und Grafana-Provisionierung

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-17 19:18:20 +02:00
parent df6615c8f7
commit 43e8e8e8f9
5 changed files with 233 additions and 1 deletions

View File

@@ -0,0 +1,171 @@
{
"uid": "finanzen",
"title": "Finanzen",
"schemaVersion": 39,
"version": 1,
"editable": true,
"timezone": "browser",
"tags": ["finanzen"],
"time": {
"from": "now-1y",
"to": "now"
},
"refresh": "",
"panels": [
{
"id": 1,
"type": "timeseries",
"title": "Kontostand-Verlauf",
"datasource": {
"type": "postgres",
"uid": "FinanzDB"
},
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 0 },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineWidth": 1,
"fillOpacity": 0
},
"unit": "currencyEUR"
},
"overrides": []
},
"options": {
"legend": { "displayMode": "list", "placement": "bottom" },
"tooltip": { "mode": "multi" }
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "postgres",
"uid": "FinanzDB"
},
"format": "time_series",
"rawSql": "SELECT day AS time, account AS metric, balance AS value FROM v_balance_history ORDER BY day",
"rawQuery": true
}
]
},
{
"id": 2,
"type": "timeseries",
"title": "Gesamt-Saldo",
"datasource": {
"type": "postgres",
"uid": "FinanzDB"
},
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 0 },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineWidth": 2,
"fillOpacity": 10
},
"unit": "currencyEUR"
},
"overrides": []
},
"options": {
"legend": { "displayMode": "list", "placement": "bottom" },
"tooltip": { "mode": "single" }
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "postgres",
"uid": "FinanzDB"
},
"format": "time_series",
"rawSql": "SELECT day AS time, balance AS value FROM v_balance_total ORDER BY day",
"rawQuery": true
}
]
},
{
"id": 3,
"type": "barchart",
"title": "Monat nach Kategorie",
"datasource": {
"type": "postgres",
"uid": "FinanzDB"
},
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 8 },
"fieldConfig": {
"defaults": {
"custom": {
"stacking": { "mode": "normal", "group": "A" }
},
"unit": "currencyEUR"
},
"overrides": []
},
"options": {
"legend": { "displayMode": "list", "placement": "bottom" },
"stacking": "normal",
"xTickLabelRotation": 0
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "postgres",
"uid": "FinanzDB"
},
"format": "time_series",
"rawSql": "SELECT month AS time, category AS metric, total AS value FROM v_monthly_by_category ORDER BY month",
"rawQuery": true
}
]
},
{
"id": 4,
"type": "timeseries",
"title": "Szenario-Vergleich",
"datasource": {
"type": "postgres",
"uid": "FinanzDB"
},
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 8 },
"fieldConfig": {
"defaults": {
"custom": {
"drawStyle": "line",
"lineWidth": 1,
"fillOpacity": 0,
"thresholdsStyle": { "mode": "line" }
},
"unit": "currencyEUR",
"thresholds": {
"mode": "absolute",
"steps": [
{ "color": "red", "value": 0 },
{ "color": "orange", "value": 500 }
]
}
},
"overrides": []
},
"options": {
"legend": { "displayMode": "list", "placement": "bottom" },
"tooltip": { "mode": "multi" }
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "postgres",
"uid": "FinanzDB"
},
"format": "time_series",
"rawSql": "SELECT day AS time, scenario AS metric, balance AS value FROM v_projection ORDER BY day",
"rawQuery": true
}
]
}
]
}

View File

@@ -0,0 +1,6 @@
apiVersion: 1
providers:
- name: finanzen
type: file
options:
path: /var/lib/grafana/dashboards

View File

@@ -0,0 +1,12 @@
apiVersion: 1
datasources:
- name: FinanzDB
type: postgres
access: proxy
url: localhost:5432
user: finance_read
jsonData:
database: finance
sslmode: disable
secureJsonData:
password: ${FINANCE_READ_PASSWORD}