feature/loki-log-queries #7
Reference in New Issue
Block a user
Delete Branch "feature/loki-log-queries"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add Loki log query support to the lab-monitoring MCP server. Three new tools are registered when
LOKI_URLis configured (opt-in):query_logs— Execute LogQL range queries against Loki with configurable time range, limit (capped at 5000), and directionlist_labels— List available label names from Lokilist_label_values— List values for a specific labelChanges
internal/monitoring/loki.go) —LokiClientwithQueryRange,Labels, andLabelValuesmethods, following the same pattern asPrometheusClientinternal/monitoring/handlers.go) —RegisterHandlersnow accepts an optional*LokiClient; tools are conditionally registered when non-nil. IncludesparseTimeArghelper supporting relative durations, RFC3339, and Unix epochinternal/monitoring/format.go) —formatLogStreams,formatLabels,formatLabelValuesfor markdown outputcmd/lab-monitoring/main.go) —logsandlabelssubcommands,--loki-urlglobal flag /LOKI_URLenv varnix/lab-monitoring-module.nix) —lokiUrloption (nullOr str, default null), conditionally setsLOKI_URLenv var0.1.0→0.2.0Security hardening
limitparameter capped at 5000 to prevent unbounded memory usagedirectionparameter validated server-side against allowed valuesTests
loki_test.go)Verification
go test ./... -short— all passgolangci-lint run ./...— 0 issuesgo vet ./...— cleannix build .#lab-monitoring— builds successfully