feat: add promtool, logcli and tempo-cli for querying the observability stack - #27
Merged
Merged
Conversation
…ty stack
toolbox covered argocd and bao but nothing for metrics, logs, traces or alerts,
so anything observability-shaped meant opening a browser.
Add the three native CLIs, each pointed at Grafana's datasource proxy so there is
one edge host and one credential for everything. All three accept arbitrary
headers, so each wrapper simply sends two:
Authorization: Bearer <jwt> read by oauth2-proxy at the edge
X-JWT-Assertion: <jwt> read by Grafana's [auth.jwt]
Two are needed because the edge consumes Authorization for itself and Traefik's
forwardauth deletes it before Grafana sees it. X-JWT-Assertion is in no
authResponseHeaders list and passes through untouched, which is why none of this
needs a loopback proxy the way bao does, or a bearer-preserving middleware the way
argocd does.
alerts come free: promtool reaches /api/v1/alerts and /api/v1/rules on the same
datasource proxy, so alert state and rule listings need no extra tool.
grafana-ds resolves datasource UIDs at run time, since Grafana generates them per
cluster.
The tempo-cli wrapper hides three sharp edges: headers are Key=Value not
Key: Value; `search` takes a bare host plus --path-prefix while `trace-id` takes a
full URL; and --use-grpc is refused outright, because headers would then travel as
gRPC metadata and never reach the edge.
Requires Grafana [auth.jwt] (GlueOps/k8s-monitoring-helm#353). Without it these
three get a 302 to the login page while argocd and bao keep working, so an older
cluster degrades rather than breaking - no version gate needed.
README documents the accepted risk: Grafana's datasource proxy forwards non-GET
methods, so these credentials can write to Loki/Thanos/Tempo, and those writes are
durable in object storage. Agents are told explicitly to treat everything as
read-only.
Verified against nonprod.jupiter.onglueops.rocks from the built image: all three
query successfully, grafana-ds resolves all three UIDs, and the --use-grpc guard
fires.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TrpnuCduw2KivngVRQmnG7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
toolbox covered
argocdandbaobut nothing for metrics, logs, traces or alerts — anything observability-shaped meant opening a browser. This adds the three native CLIs.Requires GlueOps/k8s-monitoring-helm#353 (Grafana
[auth.jwt]).Why this needs no proxy
All three tools accept arbitrary headers, so each wrapper sends two:
Authorization: Bearer <jwt>X-JWT-Assertion: <jwt>[auth.jwt]Two are needed because the edge consumes
Authorizationfor itself and Traefik's forwardauth deletes it before Grafana sees it.X-JWT-Assertionis in noauthResponseHeaderslist and passes through untouched.So this needs neither a loopback proxy (as
baodoes) nor a bearer-preserving middleware (asargocddoes). Queries go through Grafana's datasource proxy, so there's one edge host and one credential for everything.Alerts come free
promtoolreaches/api/v1/alertsand/api/v1/ruleson the same datasource proxy, so alert state and rule listings need no extra tool. Verified: 4 alerts (2 firing, 2 pending), 34 rule groups / 239 rules.Sharp edges the tempo-cli wrapper hides
Key=Value, notKey: Valuesearchtakes a bare host +--path-prefix;trace-idtakes a full URL and has no--path-prefix--use-grpcis refused outright — headers would travel as gRPC metadata and never reach the edgegrafana-dsresolves datasource UIDs at run time, since Grafana generates them per cluster.Backwards compatible — no toggle needed
On a cluster without
[auth.jwt], these three get a 302 whileargocdandbaokeep working. Login is unaffected. This matches the existing precedent:toolbox-loginalready treats OpenBao login as non-fatal ("OpenBao: not logged in (argocd is unaffected)") becauseauth/jwtis equally new.Verified from the built image, against a live cluster
Known risks — documented, not blocked
The README gains a Known risks section recording that Grafana's datasource proxy is a full pass-through: it forwards
POST/PUT/DELETE, and Grafana has no method-level control. So these credentials can write to the datasources — including Loki's ingestion endpoint, verified as reachable (Loki's own422, not a Grafana block). Those writes are durable: all three datasources are backed by S3, so nothing is undone by restarting pods or rebuilding the cluster. There is also no per-user audit trail in Grafana OSS.This was accepted knowingly. Token holders already have ArgoCD and OpenBao access. The AI-agent callout at the top of the README now says explicitly: do not delete or modify data — treat everything as read-only, and stop and ask if a task appears to need a destructive action.
If the convention ever needs enforcing, the point is a Traefik
Method(GET)rule on/api/datasources/proxy/. Deliberately not done here.Note on image size
The image grows to ~1.31 GB; the three binaries are ~260 MB (tempo-cli alone is 80 MB). Versions are pinned as build args. A
COPY --from=grafana/tempo-clicould trim it if size becomes a concern.🤖 Generated with Claude Code
https://claude.ai/code/session_01TrpnuCduw2KivngVRQmnG7