lgtm
Skill0 starsChanged 5 months agoMITView on GitHub
Query observability backends (Loki logs, Prometheus/Mimir metrics, Tempo traces) to investigate production issues, debug errors, check service health, and analyze system behavior. Use this skill whenever the user asks about logs, metrics, traces, error rates, latency, or debugging anything in production — even if they don't say "lgtm" or "observability" explicitly.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- alexandrosandre/agentic-engineeringtheir own version, first seen Nov 8, 2026
- alexandrosandre/alice-issue-agenttheir own version, first seen Nov 8, 2026
- tgolsen/claude-skillstheir own version, first seen Aug 27, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- alexandrosandre/agentic-engineering★ 0same name
- alexandrosandre/alice-issue-agent★ 0same name
- tgolsen/claude-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository4 other files it gives its agents.
- cloudsql-query-insightsSkill
- k8s-controllerSkill
- linearSkill
- n8nSkill
The file
We split this skill into the rules it gives an agent
8 rules. 0 are common, 5 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Haiku subagent: All query execution — discovery, investigation, aggregation, analysis.
- Distinctive: line 21
Run independent queries in parallel — spawn multiple Task calls in one message when queries don't depend on each other (e.g., check logs …
- Distinctive: line 27
Before querying blindly, discover what's available.
- Very specific: line 58
Before querying, check if the config file exists at ~/.config/lgtm/config.yaml.
- Distinctive: line 62
If the user is on Grafana Cloud, they can auto-generate the config:
- Very specific: line 196
All commands output JSON. Subagents should use jq to extract what's relevant rather than returning raw output:
- Very specific: line 301
When the user asks for metrics with visual charts (or you determine a chart would be more useful than raw numbers), use lgtm chart to …
- Distinctive: line 327
Use subagents to run the queries and save results to a file, then render the chart yourself:
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
LGTM Skill - Query Observability Backends
Why subagents matter here
lgtm commands return raw JSON — sometimes thousands of lines. If you run queries directly in the main conversation, you'll flood the context window and make it harder to reason about what actually matters. Haiku subagents are the right tool: they run the queries, distill the results, and hand you back just the signal you need.
The pattern is: you orchestrate, haiku executes.
Orchestrator Pattern
- You (orchestrator): Coordinate the discovery → investigation flow. Evaluate summaries returned by subagents, decide what to query next, synthesize findings for the user. Don't run
lgtmcommands yourself. - Haiku subagent: All query execution — discovery, investigation, aggregation, analysis. Fast and sufficient for the vast majority of tasks.
Run independent queries in parallel — spawn multiple Task calls in one message when queries don't depend on each other (e.g., check logs AND metrics AND traces simultaneously).
Two-Phase Approach
Phase 1: Discovery
Before querying blindly, discover what's available. This avoids wasted queries against wrong label names or nonexistent services.
Task tool call:
subagent_type: "Bash"
model: "haiku"
prompt: "Using lgtm CLI, discover available labels and services.
Run: lgtm loki labels
Run: lgtm loki label-values app
Run: lgtm loki label-values namespace
Run: lgtm tempo tag-values service.name
Return a concise list of available apps, namespaces, and trace services."Phase 2: Investigation
With concrete label values in hand, query precisely:
Task tool call:
subagent_type: "Bash"
model: "haiku"
prompt: "Using lgtm CLI, investigate errors in the checkout app in prod namespace.
<specific queries based on discovery results>
Return ONLY a concise summary, not raw JSON."Setup: Config File Required
Before querying, check if the config file exists at ~/.config/lgtm/config.yaml. If it doesn't, stop and tell the user to run lgtm discover (for Grafana Cloud) or create the config manually.
Grafana Cloud Auto-Discovery
If the user is on Grafana Cloud, they can auto-generate the config:
# Requires a Grafana Cloud Access Policy token with stacks:read scope
# Create at: Grafana Cloud → Administration → Cloud Access Policies
GRAFANA_CLOUD_API_TOKEN=glc_xxx lgtm discover
# Preview without writing
lgtm discover --dry-run
# Discover for a specific org
lgtm discover --org myorg --token glc_xxx
# Overwrite existing entries
lgtm discover --overwriteThis generates config entries for all active stacks with Loki, Prometheus, and Tempo endpoints.
Error Messages
v1.2.0+ shows clean, actionable errors instead of tracebacks:
- Nonexistent instance (
-i nonexistent): lists available instances - Empty config: suggests running
lgtm discover - Unset env vars: warns when
${VAR_NAME}references are not set
CLI Reference
lgtm is installed globally. Install with:
uv tool install lgtm-cliConfig file: ~/.config/lgtm/config.yaml
Loki (Logs)
# Discovery
lgtm loki labels
lgtm loki label-values app
lgtm loki label-values namespace
# Basic query (defaults: last 15 min, limit 50)
lgtm loki query '{app="myapp"}'
# Filter for errors
lgtm loki query '{app="myapp"} |= "error"'
# Custom time range and limit
lgtm loki query '{app="myapp"}' --start 2024-01-15T10:00:00Z --end 2024-01-15T11:00:00Z --limit 100
# Aggregations (prefer these over raw log fetches for initial overviews)
lgtm loki instant 'count_over_time({app="myapp"} |= "error" [5m])'
lgtm loki instant 'sum by (level) (count_over_time({app="myapp"} | json [5m]))'Prometheus/Mimir (Metrics)
# Discovery
lgtm prom labels
lgtm prom label-values __name__
lgtm prom metadata --metric http_requests_total
# Instant query
lgtm prom query 'up{job="prometheus"}'
lgtm prom query 'rate(http_requests_total[5m])'
# Range query (defaults: last 15 min, 60s step)
lgtm prom range 'rate(http_requests_total[5m])'
lgtm prom range 'up' --start 2024-01-15T10:00:00Z --end 2024-01-15T11:00:00Z --step 5mTempo (Traces)
# Discovery
lgtm tempo tags
lgtm tempo tag-values service.name
# Search (defaults: last 15 min, limit 20)
lgtm tempo search -q '{resource.service.name="api"}'
lgtm tempo search -q '{status=error}'
lgtm tempo search --min-duration 1s
lgtm tempo search -q '{resource.service.name="api" && status=error}' --min-duration 500ms
# Get specific trace by ID
lgtm tempo trace abc123def456Instance Selection & Discovery
lgtm instances # list configured instances
lgtm -i production loki query '{app="api"}' # use specific instance
lgtm discover # auto-discover Grafana Cloud stacks
lgtm discover --dry-run # preview without writing configKubernetes Port-Forward Instances
Some instances require kubectl port-forwarding to reach services inside a cluster.
lgtm port-forward # show port-forward commands for all instances that need them
lgtm -i sandbox port-forward # show for specific instanceSubagent prompt for port-forward instances:
Task tool call:
subagent_type: "Bash"
model: "haiku"
prompt: "Query sandbox cluster metrics using lgtm CLI.
1. Check the port-forward command needed:
lgtm -i sandbox port-forward
2. Start the tunnel in the background:
kubectl port-forward -n monitoring svc/victoria-metrics-server 8428:8428 --context sandbox &
sleep 2 # wait for tunnel to establish
3. Run the query:
lgtm -i sandbox prom query 'sandbox_running_count'
4. Return a summary of the results."Output Formatting
All commands output JSON. Subagents should use jq to extract what's relevant rather than returning raw output:
# Extract just log lines
lgtm loki query '{app="api"}' | jq -r '.data.result[].values[][] | select(type == "string")'
# Extract metric values
lgtm prom query 'up' | jq -r '.data.result[] | "\(.metric.instance): \(.value[1])"'
# Trace summary
lgtm tempo search -q '{status=error}' | jq -r '.traces[] | "\(.traceID) | \(.rootServiceName) | \(.durationMs)ms"'Subagent Prompt Examples
Discovery
Discover available observability data using lgtm CLI.
1. lgtm loki labels
2. lgtm loki label-values app
3. lgtm loki label-values namespace
4. lgtm tempo tag-values service.name
Return a concise list:
- Available apps: [list]
- Available namespaces: [list]
- Available trace services: [list]
- Any other relevant labelsInvestigate Error Spike
Investigate errors in the checkout service over the last hour using lgtm CLI.
1. Get error counts: lgtm loki instant 'sum by (level) (count_over_time({app="checkout"} | json [1h]))'
2. If errors found, sample logs: lgtm loki query '{app="checkout"} |= "error"' --limit 30
3. Check traces: lgtm tempo search -q '{resource.service.name="checkout" && status=error}'
Summarize:
- Total error count and trend
- Top 3 most frequent error messages
- When errors started
- Affected components/pods
- Any correlated trace IDs
Return only the summary, not raw JSON.Service Health Check
Check health of the payment-service using lgtm CLI.
1. Error rate: lgtm loki instant 'sum(count_over_time({app="payment-service"} |= "error" [15m]))'
2. P95 latency: lgtm prom query 'histogram_quantile(0.95, rate(http_request_duration_seconds_bucket{service="payment"}[5m]))'
3. Recent errors: lgtm loki query '{app="payment-service"} |= "error"' --limit 10
Return:
- Status: healthy/degraded/unhealthy
- Error rate (errors per minute)
- P95 latency
- Any critical issuesTrace Investigation
Investigate slow requests in the API gateway using lgtm CLI.
1. Find slow traces: lgtm tempo search -q '{resource.service.name="api-gateway"}' --min-duration 2s --limit 10
2. For the slowest trace: lgtm tempo trace <traceID>
3. Check downstream: lgtm tempo search -q '{resource.service.name="api-gateway"} >> {duration > 1s}'
Summarize:
- How many slow requests in the last 15 min
- Which downstream service is causing delays
- Common patterns in slow requestsBest Practices
Aggregations over raw data — count before you fetch. Pulling all error logs is slow and wasteful; getting a count first tells you whether it's worth digging deeper.
Use specific identifiers when you have them — if the user gives you a trace ID, request ID, or pod name, filter on it directly rather than scanning broadly.
Prefer aggregations for the initial overview:
# Get the lay of the land first
lgtm loki instant 'sum by (app) (count_over_time({namespace="prod"} |= "error" [15m]))'
# Then drill into the specific app
lgtm loki query '{namespace="prod", app="checkout"} |= "error"' --limit 20Charts
When the user asks for metrics with visual charts (or you determine a chart would be more useful than raw numbers), use lgtm chart to render terminal charts. This is built into lgtm-cli (v1.4.0+).
Chart Types
timeseries (default) — Line chart for trends over time
lgtm prom range 'rate(http_requests_total[5m])' > /tmp/data.json
lgtm chart /tmp/data.json -t "Request Rate"bar — Horizontal bars for comparing current values across series
lgtm prom range 'topk(10, sum by (job)(rate(http_requests_total[5m])))' > /tmp/data.json
lgtm chart /tmp/data.json --type bar -t "Top 10 Jobs"heatmap — Intensity grid for histogram bucket distributions over time
lgtm prom range 'rate(http_request_duration_seconds_bucket[5m])' > /tmp/data.json
lgtm chart /tmp/data.json --type heatmap -t "Latency Distribution"Chart Rendering Pattern
Charts are for human consumption — always render them directly with the Bash tool so the output goes to the user's terminal, never inside a subagent.
Use subagents to run the queries and save results to a file, then render the chart yourself:
Step 1 — Subagent fetches data:
Task tool call:
subagent_type: "Bash"
model: "haiku"
prompt: "Run this range query and save the result:
lgtm prom range 'rate(http_requests_total[5m])' --step 1m > /tmp/lgtm-chart-data.json
Report the file size and number of series in the result."
Step 2 — You render the chart directly (Bash tool, not subagent):
lgtm chart /tmp/lgtm-chart-data.json -t 'HTTP Request Rate' --type timeseriesCLI Options
Options:
--type Chart type: timeseries, bar, heatmap (default: timeseries)
--title, -t Chart title
--width, -w Chart width in columns (default: terminal width or 80)
--height Chart height in rows (default: 20)When to Use Which Type
- timeseries: Range queries over time, trend analysis, multi-series comparison
- bar: Top-K comparisons, current value rankings, instant query results
- heatmap: Histogram bucket distributions (le-labeled series), latency analysis
- Tables/text: Single values, label discovery, instant queries with few results
Reference
For query syntax, see:
reference/logql.md- LogQL syntax for Lokireference/promql.md- PromQL syntax for Prometheusreference/traceql.md- TraceQL syntax for Tempo
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

