logql-generator
БесплатноЗапускает вложенные скриптыНе проверенGenerate LogQL queries, log stream selectors, metric queries, and alerting rules for Grafana Loki.
от akin-ozer★ 346 звёзд на GitHubОб этом скилле
LogQL Query Generator
Overview
Interactive workflow for generating production-ready LogQL queries. LogQL is Grafana Loki's query language with indexed label selection, line filtering, parsing, and metric aggregation.
Trigger Hints
- "Write a LogQL query for error rate by service."
- "Help me build a Loki alert query."
- "Convert this troubleshooting requirement into LogQL."
- "I need step-by-step LogQL query construction."
Use this skill for query generation, dashboard queries, alerting expressions, and troubleshooting with Loki logs.
Execution Flow (Deterministic)
Always run stages in order. Do not skip required stages.
Stage 1 (Required): Capture Intent
Use AskUserQuestion to collect goal and use case.
Template:
- "What is your primary goal: debugging, alerting, dashboard metric, or investigation?"
- "Do you need a log query (raw lines) or a metric query (numeric output)?"
- "What time window should this cover (example: last 15m, 1h, 24h)?"
Fallback if AskUserQuestion is unavailable:
- Ask the same questions in plain text and continue.
Stage 2 (Required): Capture Log Source Details
Collect:
- Labels for stream selectors (
job,namespace,app,service_name,cluster) - Log format (JSON, logfmt, plain text, mixed)
- Known fields to filter/aggregate (
status,level,duration,path,trace_id)
Ambiguity and partial-answer handling:
- If a required field is missing, ask one focused follow-up question.
- If still missing, proceed with explicit assumptions.
- Prefix assumptions with
Assumptions:in the output so the user can correct them quickly.
Stage 3 (Required): Discover Loki and Grafana Versions
Collect or infer:
- Loki version (example:
2.9.x,3.0+, unknown) - Grafana version (example:
10.x,11.x, unknown) - Deployment context (self-hosted Loki, Grafana Cloud, unknown)
Version compatibility policy:
- If versions are known, use the newest compatible syntax only.
- If versions are unknown, use compatibility-first syntax and avoid 3.x-only features by default.
- For unknown versions, provide an optional "3.x optimized variant" separately.
Avoid by default when version is unknown:
- Pattern match operators
|>and!> approx_topk- Structured metadata specific behavior (
detected_level, accelerated metadata filtering assumptions)
Stage 4 (Required): Plan Confirmation and Output Mode
Present a plain-English plan, then ask the user to choose output mode.
Plan template:
LogQL Query Plan
Goal: <goal>
Query type: <log or metric>
Streams: <selector>
Filters/parsing: <filters + parser>
Aggregation window: <function and [range]>
Compatibility mode: <version-aware or compatibility-first>
Mode selection template:
- "Do you want
final query only(default) orincremental build(step-by-step)?"
If user does not choose, default to final query only.
Stage 5 (Conditional, Blocking): Reference Checkpoint for Complex Queries
Complex query triggers:
- Nested aggregations (
topk(sum by(...)), multiplesum by, percentiles) - Performance-sensitive queries (high volume streams, long ranges)
- Alerting expressions
- Template functions (
line_format,label_format) - Regex-heavy extraction, IP matching, pattern parsing
- Loki 3.x feature usage
Blocking checkpoint rule:
- Read relevant files before generation using explicit file-open/read actions.
- Minimum file set:
examples/common_queries.logqlfor syntax and query patternsreferences/best_practices.mdfor performance and alerting guidance
- Do not generate the final query until this checkpoint is complete.
Fallback when file-read tools are unavailable:
- State that reference files could not be read in this environment.
- Generate a conservative query (compatibility-first, simpler operators).
- Mark result as
Unverified against local references.
Stage 6 (Conditional): External Docs Lookup Policy (Context7 Before WebSearch)
Use external lookup only for version-specific behavior, unclear syntax, or advanced features not covered in local references.
Decision order:
- Context7 first:
mcp__context7__resolve-library-idwithlibraryName="grafana loki"mcp__context7__query-docsfor the exact topic
- WebSearch second (fallback only) when:
- Context7 is unavailable
- Context7 does not provide required version-specific detail
- You need latest release/deprecation confirmation
WebSearch fallback constraints:
- Prefer official Grafana/Loki docs and release notes.
- Note which statement came from fallback search.
Stage 7 (Required): Generate Query
Stage 7A (Default): Final Query Only
Return one production-ready query plus short explanation.
Stage 7B (Optional): Incremental Build Mode
Use this when requested or when debugging complex pipelines.
Step-by-step template:
- Stream selector
- Line filter
- Parser
- Parsed-field filter
- Aggregation/window
Stage 8 (Required): Deliver Usage and C
Установить logql-generator в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл logql-generator?
Generate LogQL queries, log stream selectors, metric queries, and alerting rules for Grafana Loki.
Как установить скилл logql-generator?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл logql-generator запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
ci-review
The scan that the plugin's GitHub Action runs.
от Anthropicazure-static-web-apps
Helps create, configure, and deploy Azure Static Web Apps using the SWA CLI. Use when deploying static sites to Azure, setting up SWA local development…
от GitHubai-ready
Make any repo AI-ready — analyzes your codebase and generates AGENTS.md, copilot-instructions.md, CI workflows, issue templates, and more. Mines your PR…
от GitHubaws-cdk-python-setup
Setup and initialization guide for developing AWS CDK (Cloud Development Kit) applications in Python. This skill enables users to configure environment…
от GitHub