loki-troubleshoot

Craft efficient Grafana Loki LogQL queries for debugging logs.

1|Updated Dec 4, 2025
One-click install
npx skills add https://github.com/timbuchinger/loadout --skill loki-troubleshoot
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: loki-troubleshoot
Source: https://github.com/timbuchinger/loadout/tree/main/skills/loki-troubleshoot
Command: npx skills add https://github.com/timbuchinger/loadout --skill loki-troubleshoot

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you craft efficient LogQL queries for Grafana Loki, preventing expensive or overly broad log scans. It ensures you can quickly find relevant log entries for debugging and analysis, saving time and resources.

Core Features & Use Cases

  • Efficient LogQL Query Building: Guides in constructing precise LogQL queries using label-based filtering and narrow time windows.
  • Log Debugging: Helps you quickly find errors, specific request IDs, or other critical events within your log streams.
  • Performance Optimization: Provides best practices to avoid high-cardinality labels, regex-heavy queries, and un-pre-filtered JSON parsing.
  • Use Case: You need to find all 500 errors in your 'orders' service in production from the last 2 hours. This Skill helps you craft an efficient LogQL query using appropriate labels and time ranges to quickly retrieve the relevant logs.

Quick Start

Craft a LogQL query to find logs for request_id abc123 in the 'payments' service in staging over the past 30 minutes.

Frequently Asked Questions about loki-troubleshoot

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

FAQPage Schema
How do I write efficient LogQL queries to find logs in Grafana Loki?

Efficient LogQL queries use low-cardinality labels for filtering, narrow time windows (minutes to hours), and fast filters like |= and |!= before any JSON parsing. This approach minimizes expensive log scans and retrieves results quickly across your services.

What's the best way to debug errors in Loki logs using LogQL?

Target your error logs by combining label filters with your service name, apply a tight time window around when the error occurred, use fast text filters to locate error messages, then parse structured fields only after filtering narrows the dataset.

Why should I avoid regex and JSON parsing early in my LogQL queries?

Regex and immediate JSON parsing force Loki to scan all matching logs before filtering, creating expensive operations. Applying fast filters (|=, |!=) first dramatically reduces the dataset Loki must parse, improving query performance and resource usage.

Can I use LogQL to find specific request IDs or trace identifiers across logs?

Yes. Use label-based filtering to target your service, apply a fast filter with |= to match the request ID string, and set a narrow time window. This efficiently locates all logs for that request without scanning unrelated entries.

What labels should I use in Loki to keep queries fast and avoid high cardinality?

Use low-cardinality labels like service name, environment, and log level as your primary filters. Avoid labels with unbounded values (user IDs, request IDs, timestamps). Structure queries to filter by these stable labels first, then search within the reduced result set.

How do I structure a LogQL query to analyze logs from multiple services or environments?

Combine service and environment labels in your query using label matchers, set a specific time range, then apply fast text filters for your search term. This approach keeps scans focused and prevents accidentally querying unrelated services or stale data.