optimizing-loki-cardinality-and-finops

optimizing-loki-cardinality-and-finops is a skill for Claude Code, Codex from talkops-ai/talkops-mcp. It costs 186 tokens per session (1,606 once invoked), scanned A, original, Apache-2.0.

A cost and capacity review workflow for Grafana Loki logs. It examines ingestion volume, stream cardinality—the number of distinct label combinations—small storage chunks, tenant limits, TSDB storage versions, and Bloom filters used to skip irrelevant data.

In plain words
What is it for?
Use it to audit Loki costs, find noisy services, reduce stream growth and object-storage requests, and plan label, metadata, and storage changes.
Why use it?
It helps identify why log storage or object-storage bills grow, including excessive label combinations that create many small files or chunks. It also supports rules for keeping labels bounded and moving detailed fields into metadata.

Skill for Claude CodeCodex

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

Good fit Use it to audit Loki costs, find noisy services, reduce stream growth and object-storage requests, and plan label, metadata, and storage changes.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/talkops-ai/talkops-mcp/optimizing-loki-cardinality-and-finops
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 optimizing-loki-cardinality-and-finops
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 optimizing-loki-cardinality-and-finops

README.md
[![agentmods](https://agentmods.dev/badge/skills/talkops-ai/talkops-mcp/optimizing-loki-cardinality-and-finops/github.svg)](https://agentmods.dev/skills/talkops-ai/talkops-mcp/optimizing-loki-cardinality-and-finops)
Your own site
<a href="https://agentmods.dev/skills/talkops-ai/talkops-mcp/optimizing-loki-cardinality-and-finops"><img src="https://agentmods.dev/badge/skills/talkops-ai/talkops-mcp/optimizing-loki-cardinality-and-finops/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 optimizing-loki-cardinality-and-finops

Your own site · 80×15
<a href="https://agentmods.dev/skills/talkops-ai/talkops-mcp/optimizing-loki-cardinality-and-finops"><img src="https://agentmods.dev/badge/skills/talkops-ai/talkops-mcp/optimizing-loki-cardinality-and-finops.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 186 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,606 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.00186 $0.01606
Opus 5.5 $0.00074 $0.00642
Sonnet 5.5 $0.00037 $0.00321
Haiku 4.5 $0.00019 $0.00161

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

Security

Grade A, and why

optimizing-loki-cardinality-and-finops 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/audit_label_cardinality.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/optimizing-loki-cardinality-and-finops/SKILL.md · 57 lines

How it starts

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

Optimizing Loki Cardinality and FinOps

Use this skill to perform a rigorous Grafana Loki 3.x FinOps and stream-cardinality audit—identifying noisy workloads, diagnosing tiny-chunk S3 API spikes, enforcing strict label governance, and designing TSDB v13 + structured_metadata + Bloom filter architectures.

Golden Rules of Loki 3.x Label & Storage FinOps

Consult references/label-governance-and-cardinality.md and references/bloom-filters-and-tsdb-finops.md:

  1. Stream Labels Index Streams, Never Log Fields:
    • Keep <= 10 bounded labels in {} (cluster, namespace, service_name, env) and < 100,000 active streams per tenant.
    • Unconditionally Forbidden in {} (even if staging count < 500!): pod, k8s_pod_name, container_id, trace_id, span_id, request_id, order_id, session_id, user_id, client_ip, pod_ip, uuid—demote them to Loki 3.x structured_metadata!
  2. Tiny-Chunk Syndrome (< 256 KB vs 1.5 MB chunk_target_size):
    • High stream churn causes ingesters to flush thousands of tiny < 6 KB chunks, spiking S3 PUT/GET API costs 10x–50x even when daily GB stays flat. Fix by demoting ephemeral labels to structured_metadata.
  3. TSDB v13 Migrations & Bloom Filters:
    • Migrate from legacy boltdb-shipper (v11) by appending a future-dated from: entry (store: tsdb, schema: v13, period: 24h)—never modify historical schema_config entries (which makes older logs unreadable). TSDB v13 cuts index-gateway RAM by ~70%.
    • For needle-in-a-haystack queries (order_id, trace_id, request_id, or SKU/entity IDs) scanning > 10 GB, keep IDs in structured_metadata and enable Loki 3.x Bloom filters (bloom_build.enabled: true, bloom_gateway.enabled: true, limits_config.bloom_gateway_enable_filtering: true, bloom_creation_enabled: true) to skip 95%+ of chunks without indexing unbounded labels.
  4. Collection-Edge Noise Dropping:
    • Drop HTTP 200 kube-probe / /healthz checks and DEBUG logs at the collector edge (stage.drop in Grafana Alloy / filter in OTel Collector), always preserving >= 400 probe failures so failed readiness/liveness probes remain visible!
  5. Dashboard & Ruler Migration Impact:
    • Before dropping pod from {} via stage.label_drop, audit loki://rules/groups and Grafana variables so {service_name="x", pod="y"} selectors (which would return 0 streams) are migrated atomically to {service_name="x"} | pod="y".

Read the full file on GitHub · 57 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 · 57 lines · 186 tokens per session scan A 7807ac26e768

Subscribe to this mod's changes

optimizing-loki-cardinality-and-finops is a skill published in the GitHub repository talkops-ai/talkops-mcp (4 stars, last pushed 12d ago), licensed Apache-2.0. It adds 186 tokens to every session and 1,606 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

optimizing-loki-cardinality-and-finops compared with skills from other repositories

optimizing-loki-cardinality-and-finops next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
optimizing-loki-cardinality-and-finopstalkops-ai/talkops-mcpSkill412d agoApache-2.0A186Claude 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