Skip to content

feat: enrich monitoring with structured logs and new exporters - #538

Merged
stackptr merged 9 commits into
mainfrom
feat-monitoring-enrichment
Aug 26, 2026
Merged

stackptr merged 9 commits into
mainfrom
feat-monitoring-enrichment

Conversation

@stackptr

@stackptr stackptr commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • Structured log labels (all hosts): Alloy now extracts unit, priority, and app labels from the systemd journal on glyph, spore, and zeta, enabling scoped LogQL queries like {host="glyph", unit="navidrome.service", priority=~"[0-3]"} without full-text search
  • New Prometheus exporters (glyph): postgres_exporter (port 9187) and smartctl_exporter (port 9633) cover DB health across the five local databases and disk SMART data for the NAS
  • Navidrome metrics (glyph): Enables the built-in /metrics endpoint and adds a Prometheus scrape job for library size, play counts, and scan duration
  • nginx exporter (spore): Adds a localhost-only stub_status endpoint on port 9080 and nginx_exporter on port 9113; Prometheus on glyph scrapes it for request rate and connection stats
  • CLAUDE.md: Documents the full monitoring stack (label schema, exporter map, common LogQL/PromQL patterns) so agents use the Grafana MCP proactively instead of SSH/journalctl

Deploy order

  1. zeta — Alloy only, lowest risk
  2. glyph — new exporters + Alloy relabeling + navidrome metrics endpoint
  3. spore — nginx exporter + stub_status (scrape from glyph starts working once both are deployed)

Test plan

  • After deploying zeta/glyph/spore: check Grafana Explore (Loki) — entries for each host should have unit, priority, and app labels
  • Check glyph:9099/targetspostgres, smartctl, and navidrome jobs should show UP
  • On glyph: curl -s localhost:9187/metrics | grep pg_up → should return pg_up 1
  • On glyph: curl -s localhost:9633/metrics | grep smartctl_device → should list drives
  • On glyph: curl -s localhost:4533/metrics | grep navidrome_ → should list library stats
  • On spore: curl -s http://127.0.0.1:9080/nginx_status → should show active connections
  • On glyph: nginx job in Prometheus targets → spore.note-iwato.ts.net:9113 should show UP
  • If unit/priority/app labels are missing from Loki after deploy, check journalctl -u alloy — Alloy will log warnings for any unresolved source label names

🤖 Generated with Claude Code

stackptr and others added 5 commits August 26, 2026 15:19
Extract unit, priority, and app labels from the systemd journal on all
hosts (glyph, spore, zeta) so Loki queries can be scoped by service
unit, syslog severity, and identifier without full-text search.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Entire-Checkpoint: d908b189c88f
postgres_exporter covers query throughput, connections, and vacuum stats
for the five databases on glyph. smartctl_exporter surfaces disk health,
temperature, and reallocated sectors — important for a NAS.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Entire-Checkpoint: f616080a78e1
Enables the built-in /metrics endpoint in navidrome and adds a
Prometheus scrape job for it. Covers library size, play counts,
active streams, and scan duration.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 56d6f0a22081
Adds a localhost-only nginx stub_status endpoint on port 9080 and
the prometheus nginx_exporter on port 9113. Glyph's Prometheus scrapes
it for request rate, active connections, and error metrics.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 514b9becae1a
Adds a Monitoring Stack section covering Loki label schema, Prometheus
jobs/exporters, and common LogQL/PromQL patterns. Instructs agents to
use the grafana MCP proactively instead of journalctl or SSH.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 61096eefaeb4
@stackptr
stackptr force-pushed the feat-monitoring-enrichment branch from 35f965a to 9d5329d Compare August 26, 2026 22:19
stackptr and others added 4 commits August 26, 2026 15:46
The pipeline approach (forward_to loki.relabel) strips __journal__*
meta-labels before they reach the relabel component. relabel_rules on
loki.source.journal applies rules during the read phase while those
labels are still available; discovery.relabel provides the correct
RelabelRules export type for that argument.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 72d76598b42b
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 0cfc43778db5
Fields without a leading underscore (PRIORITY, SYSLOG_IDENTIFIER) map
to __journal_<field> with a single underscore, not double. Only fields
with a leading underscore like _SYSTEMD_UNIT produce the double
underscore form __journal__systemd_unit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Entire-Checkpoint: e1dd3242a97b
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 05efbccc8f54
@stackptr
stackptr merged commit 7ac6fe8 into main Aug 26, 2026
5 checks passed
stackptr added a commit that referenced this pull request Sep 2, 2026
Resolve conflict in navidrome.nix: keep Prometheus.Enabled (added on
main by #538) alongside the apple-music/nd-lyrics plugin config.

Entire-Checkpoint: c5af4ce18fcb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant