grafana: extract MESSAGE field in log panels
All checks were successful
Run nix flake check / flake-check (push) Successful in 2m5s

Use LogQL json parser and line_format to show only the MESSAGE
field instead of the full JSON blob in log panels.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-08 21:50:47 +01:00
parent ef026d9bfc
commit c64d299daf

View File

@@ -208,7 +208,7 @@
"datasource": {"type": "loki", "uid": "loki"},
"targets": [
{
"expr": "{systemd_unit=\"nixos-upgrade.service\", host=~\"$host\"} |= \"Done. The new configuration is\"",
"expr": "{systemd_unit=\"nixos-upgrade.service\", host=~\"$host\"} |= \"Done. The new configuration is\" | json | line_format \"{{.MESSAGE}}\"",
"refId": "A"
}
],
@@ -231,7 +231,7 @@
"datasource": {"type": "loki", "uid": "loki"},
"targets": [
{
"expr": "{systemd_unit=\"nixos-upgrade.service\", host=~\"$host\"} |= \"building\"",
"expr": "{systemd_unit=\"nixos-upgrade.service\", host=~\"$host\"} |= \"building\" | json | line_format \"{{.MESSAGE}}\"",
"refId": "A"
}
],
@@ -254,7 +254,7 @@
"datasource": {"type": "loki", "uid": "loki"},
"targets": [
{
"expr": "{job=\"bootstrap\", host=~\"$host\"}",
"expr": "{job=\"bootstrap\", host=~\"$host\"} | json | line_format \"{{.MESSAGE}}\"",
"refId": "A"
}
],
@@ -277,7 +277,7 @@
"datasource": {"type": "loki", "uid": "loki"},
"targets": [
{
"expr": "{systemd_unit=\"nixos-upgrade.service\", host=~\"$host\"} |~ \"(?i)error|failed\"",
"expr": "{systemd_unit=\"nixos-upgrade.service\", host=~\"$host\"} |~ \"(?i)error|failed\" | json | line_format \"{{.MESSAGE}}\"",
"refId": "A"
}
],