Loki labels and cardinality

Choosing the labels that make Loki fast and affordable, and handling high-cardinality data with structured metadata and stream sharding.

Loki label best practices

Picking static, bounded labels such as cluster, namespace and environment, using dynamic labels sparingly, and filtering on content instead of labelling it, so streams and chunks stay healthy.

Diagnosing high cardinality in Loki

Finding labels that explode the number of streams, such as pod names, user IDs or trace IDs, the default limit of 15 index labels, and moving those values to structured metadata or line filters.

Using structured metadata in Loki

Attaching high-cardinality fields such as trace IDs and pod names to log lines without indexing them: schema v13 and TSDB requirements, querying structured metadata and its role in bloom acceleration.

Changing Loki's default OpenTelemetry labels

Adjusting which OTLP resource attributes Loki promotes to index labels: why Grafana no longer recommends k8s.pod.name and service.instance.id as labels, and moving them to structured metadata per tenant.

The Loki service_name label

Understanding the service_name label Loki 3.0 added for every stream: where its value comes from, how Grafana uses it for exploration, and configuring it for logs that do not carry a service name.

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.