discovering-loki-schema-and-log-structure

discovering-loki-schema-and-log-structure is a skill for Claude Code, Codex from talkops-ai/talkops-mcp. It costs 172 tokens per session (1,620 once invoked), scanned A, original, Apache-2.0.

A discovery workflow for Grafana Loki, a system that stores and searches logs. It maps the labels, fields, metadata, and recurring log patterns in an unfamiliar Loki installation so queries can use the data that actually exists.

In plain words
What is it for?
Use it when onboarding a Loki cluster or tenant, learning how logs are structured, and choosing parsers for recurring log formats.
Why use it?
It avoids guessing field names or scanning large amounts of raw log text with unsuitable regular expressions. This makes it easier to build accurate LogQL searches and parsers.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when onboarding a Loki cluster or tenant, learning how logs are structured, and choosing parsers for recurring log formats.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/talkops-ai/talkops-mcp/discovering-loki-schema-and-log-structure
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add talkops-ai/talkops-mcp --skill discovering-loki-schema-and-log-structure
Clone the repo
git clone --depth 1 https://github.com/talkops-ai/talkops-mcp

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for discovering-loki-schema-and-log-structure

README.md
[![agentmods](https://agentmods.dev/badge/skills/talkops-ai/talkops-mcp/discovering-loki-schema-and-log-structure/github.svg)](https://agentmods.dev/skills/talkops-ai/talkops-mcp/discovering-loki-schema-and-log-structure)
Your own site
<a href="https://agentmods.dev/skills/talkops-ai/talkops-mcp/discovering-loki-schema-and-log-structure"><img src="https://agentmods.dev/badge/skills/talkops-ai/talkops-mcp/discovering-loki-schema-and-log-structure/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for discovering-loki-schema-and-log-structure

Your own site · 80×15
<a href="https://agentmods.dev/skills/talkops-ai/talkops-mcp/discovering-loki-schema-and-log-structure"><img src="https://agentmods.dev/badge/skills/talkops-ai/talkops-mcp/discovering-loki-schema-and-log-structure.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 172 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,620 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00172 $0.01620
Opus 5.5 $0.00069 $0.00648
Sonnet 5.5 $0.00034 $0.00324
Haiku 4.5 $0.00017 $0.00162

Measured 11d ago against content hash 824e75e99262, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

discovering-loki-schema-and-log-structure scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/infer_log_parser.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

src/loki-mcp-server/skills/discovering-loki-schema-and-log-structure/SKILL.md · 53 lines

How it starts

The opening of the file, as written. The whole thing — 53 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Discovering Loki Schema and Log Structure

Use this skill to systematically map out an unfamiliar Grafana Loki 3.x environment—from indexed TSDB labels down to chunk-header structured metadata, Promtail pack envelopes, and recurring <_> log templates—without guessing field names or running blind regex scans.

Progressive 6-Step Schema Discovery Funnel

Always narrow from macro index metadata down to micro log structure via Loki MCP resources and tools (passing explicit org_id whenever inspecting specific tenants):

  1. Cluster Capabilities & Cached Labels:
    • Read loki://server/capabilities and loki://schema/labels first to check Loki server version, allow_write, and whether Loki 3.x /detected_fields and /patterns endpoints are supported.
    • If operating against a legacy Loki 2.x backend (or if /detected_fields / /patterns are disabled), skip Steps 5–6, run Steps 2–4, sample <= 10 bounded lines via loki_query_range(..., max_log_lines=10), and pass a sample line to infer_log_parser.py.
  2. Indexed Label Names (loki_get_labels):
    • Call loki_get_labels(start="now-6h", org_id=...) to list active TSDB-indexed stream labels (service_name, service_namespace, namespace, cluster, job, app, env).
    • When comparing multiple tenants, call loki_get_labels separately per org_id.
  3. Scoped Label Values (loki_get_label_values):
    • Call loki_get_label_values(label="service_name", query='{namespace="<namespace>"}', start="now-3h") using the query parameter to scope values to the target namespace rather than scanning cluster-wide.
  4. Active Stream Combinations (loki_get_series):
    • Call loki_get_series(match='{service_name="<service>", namespace="<namespace>"}') to inspect exact indexed label sets and stream counts before querying logs.
  5. Detected Fields, Structured Metadata & Envelopes (loki_get_detected_fields):
    • Consult references/structured-metadata-and-otlp.md and call loki_get_detected_fields(query='{service_name="<service>", namespace="<namespace>"}', start="now-1h"):
      • Loki 3.x Native OTLP (/otlp/v1/logs) 3-Tier Model: service.name / service.namespace map to indexed {service_name, service_namespace}; high-cardinality attributes (k8s.pod.name / k8s_pod_name, k8s.container.name, trace_id, span_id, severity_text) land in Structured Metadata (parsers: null / ""), so {k8s_pod_name="..."} returns 0 streams—filter them after {} via | k8s.pod.name="..." | trace_id="..." without | json!
      • Promtail pack Envelope (_entry): If detected fields show _entry alongside packed labels (pod), recommend | unpack first (so _entry becomes the log line) before | logfmt or | json, and recommend migrating packed pod labels to Loki 3.x structured_metadata.
      • Duplicate Label Collisions (_extracted): When a parsed JSON/logfmt key (service_name) collides with an indexed stream label (service_name), Loki renames the parsed key to service_name_extracted; alias explicitly (| json downstream_service="service_name").
  6. Log Volume & Structural Templates (loki_get_log_patterns):
    • Consult references/pattern-parser-and-extraction-guide.md and call loki_get_log_patterns(query='{service_name="<service>", namespace="<namespace>"}', start="now-1h").
    • Convert dominant <_> templates into fast | pattern "..." extractors by naming only needed tokens (<method>, <path>, <status>, <duration_ms>) while keeping unused tokens as <_>.
    • Always prefer | pattern as the primary recommendation on fixed anchor literals, and always explain why | pattern outperforms | regexp by 5–10x on high-volume logs (single-pass byte scan with zero per-line Go RE2 state allocation). Present Go RE2 (?P<name>...) | regexp (preceded by a literal |= filter) strictly as a secondary fallback when variable multi-space padding or optional tokens occur.

Read the full file on GitHub · 53 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 53 lines · 172 tokens per session scan A 824e75e99262

Subscribe to this mod's changes

discovering-loki-schema-and-log-structure is a skill published in the GitHub repository talkops-ai/talkops-mcp (4 stars, last pushed 12d ago), licensed Apache-2.0. It adds 172 tokens to every session and 1,620 once invoked, about $0.0007 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-11-18.

Related

discovering-loki-schema-and-log-structure compared with skills from other repositories

discovering-loki-schema-and-log-structure next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
discovering-loki-schema-and-log-structuretalkops-ai/talkops-mcpSkill412d agoApache-2.0A172Claude Code, Codex
argocdalivirgo/Major-AI-SkillsSkill6yesterdayMITA42Claude Code
airdrop-hunting-guidenirholas/three.wsSkill287yesterdayApache-2.0A54Claude Code, Codex
opik-diagnosecomet-ml/opik-mcpSkill2274d agoApache-2.0A187Claude Code
ue-mcp-epic-routingdb-lyon/ue-mcpSkill526todayMITA81Claude Code, Codex
qa-knowledgegriddynamics/rosettaSkill3825d agoApache-2.0A32Claude Code, Codex
x-use-reviewihuzaifashoukat/x-useSkill1877d agoMITA56Claude Code