Skip to content

Add /loki-query slash command for VCell log access#1680

Open
jcschaff wants to merge 1 commit intomasterfrom
loki-query-skill
Open

Add /loki-query slash command for VCell log access#1680
jcschaff wants to merge 1 commit intomasterfrom
loki-query-skill

Conversation

@jcschaff
Copy link
Copy Markdown
Member

@jcschaff jcschaff commented May 5, 2026

Summary

  • New /loki-query slash command (.claude/commands/loki-query.md) for querying the in-cluster Loki instance covering all three VCell environments (prod, stage, dev)
  • Three helper scripts under tools/loki/: setup.sh (idempotent install + port-forward), loki-query.sh (auto-setup + logcli passthrough wrapper), teardown.sh (stop port-forward)
  • macOS-specific install (auto brew install logcli); kubeconfig path overridable via LOKI_KUBECONFIG

Why

During an incident investigation we found the prod data pod had been silently disconnected from ActiveMQ for ~18 hours, causing periodic Better Stack alerts. Surfacing that required kubectl exec-ing into the pod and reading logs by hand. This tooling lets a developer go from "Better Stack just paged me" to a focused LogQL query in one slash-command, with no per-incident setup.

Implementation notes

  • setup.sh bypasses the loki-gateway whose ED25519 TLS cert can't handshake against macOS LibreSSL curl, by port-forwarding svc/loki-read directly on plain HTTP. Tenant uchc is set automatically via X-Scope-OrgID.
  • Idempotent: subsequent invocations reuse the port-forward via pidfile + listening-port check.
  • The slash command documents the per-namespace container layout (notably prod-only rest/mongodb, stage-only sif-prepull).

Test plan

  • bash tools/loki/setup.sh succeeds on a fresh macOS dev box (installs logcli on first run, no-op afterwards)
  • bash tools/loki/loki-query.sh --since=5m '{namespace="prod", container="data"}' | head returns log lines
  • Same against namespace="stage" and namespace="dev" — confirmed during development that all three respond
  • bash tools/loki/teardown.sh stops the port-forward and cleans up /tmp/vcell-loki-pf.pid
  • /loki-query show errors in prod data container last 15m invokes the slash command and translates intent into a working LogQL query

🤖 Generated with Claude Code

Wraps logcli with a kubectl port-forward to the in-cluster Loki
instance so prod/stage/dev logs can be queried during incident
investigation without leaving the dev machine. The slash command is
namespace-aware and documents the VCell container layout per
environment.

tools/loki/setup.sh is idempotent: installs logcli on macOS via brew,
starts a port-forward to svc/loki-read in the logging namespace, and
verifies tenant access. Bypasses the loki-gateway whose ED25519 TLS
cert LibreSSL/macOS curl can't handshake.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jcschaff jcschaff requested a review from Ezequiel-Valencia May 5, 2026 15:11
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