observability-loki

Query and analyze Grafana Loki logs using LogQL for incident investigation.

656|82|Updated Jan 20, 2026
One-click install
npx skills add https://github.com/incidentfox/incidentfox --skill observability-loki
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: observability-loki
Source: https://github.com/incidentfox/incidentfox/tree/main/sre-agent/.claude/skills/observability-loki
Command: npx skills add https://github.com/incidentfox/incidentfox --skill observability-loki

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires httpx, and includes scripts (resource) components.

What problem does it solve?

Investigating production incidents requires digging through large volumes of logs, and writing correct LogQL queries against Grafana Loki by hand is slow and error-prone. This Skill gives an AI agent a structured workflow and ready-made scripts to explore labels, measure error rates, sample logs, and run arbitrary LogQL queries during incident response.

Core Features & Use Cases

  • Label Discovery: List all available Loki labels and their values to understand what is queryable before writing selectors.
  • Log Statistics: Compute total log volume, error and warning counts, logs-per-minute, and error rate percentages for any stream selector.
  • Log Sampling & Raw LogQL: Fetch representative log entries with optional regex filters, or execute arbitrary log and metric LogQL queries with custom time ranges.
  • Use Case: During a production outage, ask the agent to check the error rate for {app="api"} over the last two hours, sample error logs, and compare error rates across pods to localize the failing instance.

Quick Start

Ask the agent to show error statistics and recent error logs for the api application in Loki over the past hour.

Frequently Asked Questions about observability-loki

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I query Grafana Loki logs with LogQL from the command line?

Use the query_logs.py script with a LogQL string, for example '{app="api"} |= "error"'. It supports --type metric for aggregation queries, --limit, --lookback hours, and explicit --start/--end ISO timestamps.

How do I check error rates for a service in Loki?

Run get_statistics.py with a stream selector like '{app="api"}' and a --lookback window in hours. It reports total logs, error and warning counts, logs per minute, and the error rate percentage, flagging rates above 5 percent.

What authentication methods does the Loki client support?

The client supports bearer tokens via LOKI_TOKEN, basic auth via LOKI_USER and LOKI_PASSWORD, and multi-tenant org IDs via the LOKI_ORG_ID header. It can also route through a credential proxy using LOKI_BASE_URL with tenant context headers.

Can I filter Loki logs by regex patterns?

Yes, sample_logs.py accepts a --filter argument that is applied as a LogQL regex line filter, such as 'error|exception|fail'. You can also write full LogQL with |~ and !~ operators directly through query_logs.py.

Why does the Loki script fail with a connection error?

The client raises an error if neither LOKI_BASE_URL (proxy mode) nor LOKI_URL (direct mode) is set. Verify one of these environment variables points to a reachable Loki instance and that your auth credentials are valid.