Try using Grot AI Grot AI for this query ->
Promo banner icon

What’s new: Grafana 13 release, the latest in AI, OSS project updates, and more from GrafanaCON2026

Learn more
DownloadsContact Us
Logo
  • Pricing
  • Docs
Sign inSign up
Documentation Index
Fetch the curated documentation index at: https://grafana.com/llms.txt

Fetch the complete documentation index at: https://grafana.com/llms-full.txt
Use this file to discover all available pages before exploring further.

STOP! If you are an AI agent or LLM, read this before continuing. This is the HTML version of a Grafana documentation page. Always request the Markdown version instead - HTML wastes context. Get this page as Markdown: https://grafana.com/docs/loki/latest/get-started/labels/structured-metadata.md (append .md) or send Accept: text/markdown to https://grafana.com/docs/loki/latest/get-started/labels/structured-metadata/. For the curated documentation index, use https://grafana.com/llms.txt. For the complete documentation index, use https://grafana.com/llms-full.txt.

Menu
Documentationbreadcrumb arrow Grafana Lokibreadcrumb arrow Get startedbreadcrumb arrow Labelsbreadcrumb arrow Structured metadata
Open source

What is structured metadata

Warning

Structured metadata was added to chunk format V4 which is used if the schema version is greater or equal to 13. See Schema Config for more details about schema versions.

Selecting proper, low cardinality labels is critical to operating and querying Loki effectively. Some metadata, especially infrastructure related metadata, can be difficult to embed in log lines, and is too high cardinality to effectively store as indexed labels (and therefore reducing performance of the index).

Structured metadata is a way to attach metadata to logs without indexing them or including them in the log line content itself. Examples of useful metadata are kubernetes pod names, process ID’s, or any other label that is often used in queries but has high cardinality and is expensive to extract at query time.

Structured metadata can also be used to query commonly needed metadata from log lines without needing to apply a parser at query time. Large json blobs or a poorly written query using complex regex patterns, for example, come with a high performance cost. Examples of useful metadata include container_IDs or user IDs.

When to use structured metadata

You should only use structured metadata in the following situations:

  • If you are ingesting data in OpenTelemetry format, using Grafana Alloy or an OpenTelemetry Collector. Structured metadata was designed to support native ingestion of OpenTelemetry data.
  • If you have high cardinality metadata that should not be used as a label and does not exist in the log line. Some examples might include process_id or thread_id or Kubernetes pod names.
  • If you are using Logs Drilldown to visualize and explore your Loki logs. You must set discover_log_levels and allow_structured_metadata to true in your Loki configuration.
  • If you are a large-scale customer, who is ingesting more than 75TB of logs a month and are using Bloom filters (Experimental), starting in Loki 3.3 Bloom filters now utilize structured metadata.

Enable or disable structured metadata

You enable structured metadata in the Loki config.yaml file.

YAML
limits_config:
    allow_structured_metadata: true
    volume_enabled: true
    retention_period: 672h # 28 days retention

You can disable Structured Metadata by setting allow_structured_metadata: false in the limits_config section or set the command line argument -validation.allow-structured-metadata=false. Note structured metadata is required to support ingesting OTLP data.

Attaching structured metadata to log lines

You have the option to attach structured metadata to log lines in the push payload along with each log line and the timestamp. For more information on how to push logs to Loki via the HTTP endpoint, refer to the HTTP API documentation.

Alternatively, you can use Grafana Alloy to extract and attach structured metadata to your log lines. See the Alloy stage.structured_metadata block for more information.

With Loki version 1.2.0, support for structured metadata has been added to the Logstash output plugin. For more information, see logstash.

Warning

Structured metadata size is taken into account while asserting ingestion rate limiting. Along with that, there are separate limits on how much structured metadata can be attached per log line.

YAML
# Maximum size accepted for structured metadata per log line.
# CLI flag: -limits.max-structured-metadata-size
[max_structured_metadata_size: <int> | default = 64KB]

# Maximum number of structured metadata entries per log line.
# CLI flag: -limits.max-structured-metadata-entries-count
[max_structured_metadata_entries_count: <int> | default = 128]

Querying structured metadata

Structured metadata is extracted automatically for each returned log line and added to the labels returned for the query. You can use labels of structured metadata to filter log line using a label filter expression.

For example, if you have a label pod attached to some of your log lines as structured metadata, you can filter log lines using:

logql
{job="example"} | pod="myservice-abc1234-56789"

Of course, you can filter by multiple labels of structured metadata at the same time:

logql
{job="example"} | pod="myservice-abc1234-56789" | trace_id="0242ac120002"

Note that since structured metadata is extracted automatically to the results labels, some metric queries might return an error like maximum of series (50000) reached for a single query. You can use the Keep and Drop stages to filter out labels that you don’t need. For example:

logql
count_over_time({job="example"} | trace_id="0242ac120002" | keep job  [5m])

Was this page helpful?

Suggest an edit in GitHub
Create a GitHub issue
Email docs@grafana.com
Help and support
Community

Related resources from Grafana Labs

Additional helpful documentation, links, and articles:
webinar icon
Video
Getting started with logging and Grafana Loki
Getting started with logging and Grafana Loki
See a demo of the updated features in Loki, and how to create metrics from logs and alert on your logs with powerful Prometheus-style alerting rules.
video icon
Video
Essential Grafana Loki configuration settings
Essential Grafana Loki configuration settings
This webinar focuses on Grafana Loki configuration including agents Promtail and Docker; the Loki server; and Loki storage for popular backends.
video icon
Video
Scaling and securing your logs with Grafana Loki
Scaling and securing your logs with Grafana Loki
This webinar covers the challenges of scaling and securing logs, and how Grafana Cloud Logs powered by Grafana Loki can help, cost-effectively.
Technical documentation Plugin catalog
Choose a product
Viewing: v3.7.x (latest) Find another version
  • Grafana Loki
  • Release notes
    • Release cadence
    • v3.7
    • v3.6
    • v3.5
    • v3.4
    • v3.3
    • v3.2
    • v3.1
    • v3.0
    • V2.9
    • V2.8
    • V2.7
    • V2.6
    • V2.5
    • V2.4
    • V2.3
  • Get started
    • Loki overview
    • Quick Start
      • Loki quickstart
      • Loki Tutorial
    • Architecture
    • Components
    • Deployment modes
    • Labels
      • Label best practices
      • Cardinality
      • Structured metadata
      • Modify default labels
    • Hash rings
  • Set up
    • Size the cluster
    • Install
      • Install using Helm
        • Helm chart components
        • Install monolithic Loki
        • Install microservice Loki
        • Install scalable Loki
        • Cloud Deployment Guides
          • Deploy on AWS
          • Deploy on Azure
          • Deploy on GCP
        • Configure storage
        • Helm chart values
        • Monitoring
      • Install using Tanka
      • Install using Docker
      • Install locally
      • Install on Istio
      • Install from source
    • Migrate
      • Migrate to Alloy
      • Migrate from SSD to distributed
      • Migrate to TSDB
      • Migrate from `loki-distributed`
      • Migrate to three targets
      • Migrate to Thanos storage clients
    • Upgrade
      • Upgrade the Helm chart to 3.0
      • Upgrade the Helm chart to 6.0
      • Upgrade to Community Helm chart
  • Configure
    • Best practices
    • Storage
    • Usage statistics
    • Examples
      • Configuration
      • Thanos storage examples
      • Query frontend example
  • Send data
    • Grafana Alloy
      • Sending Logs to Loki via Kafka using Alloy
      • Sending OpenTelemetry logs to Loki using Alloy
    • OpenTelemetry
      • Native OTLP endpoint vs Loki Exporter
      • OTel Collector tutorial
    • Kubernetes Monitoring Helm
    • Promtail
    • Docker driver
      • Configure Docker driver
    • Fluent Bit
      • Fluent Bit tutorial
      • Fluent Bit Community Plugin
      • Fluent Bit
    • Fluentd
    • Lambda Promtail
    • Logstash plugin
    • k6 load testing
      • Log generation
      • Write path testing
      • Query testing
  • Query
    • Query best practices
    • LogQL simulator
    • Log queries
    • Metric queries
    • Template functions
    • LogCLI
      • Getting started
      • LogCLI tutorial
    • Matching IP addresses
    • Query examples
    • Query acceleration
    • Query Reference
    • Troubleshoot queries
  • Visualize
  • Alert
  • Manage
    • Loki Canary
    • Block unwanted queries
    • Caching
    • Rate limits
    • Query fairness
    • Shuffle sharding
    • Monitor Loki
      • Deploy Loki Meta Monitoring
      • Install Mixins
      • Single Binary Meta Monitoring
      • Key Metrics
    • Troubleshooting
      • Troubleshoot operations
      • Troubleshoot ingestion
      • Troubleshoot drilldown
      • Troubleshoot queries
    • Authentication
    • Bloom filters
    • Automatic stream sharding
    • Scale Loki
    • Recording rules
    • Storage
      • TSDB
      • BoltDB Shipper
      • Filesystem object store
      • Storage schema
      • Write Ahead Log
      • Log retention
      • Log entry deletion
      • Horizontal scaling of Compactor
      • Legacy storage
      • Table manager
    • Multi-tenancy
    • Autoscaling queriers
    • Upgrade
    • Overrides Exporter
    • Zone aware ingesters
  • Reference
    • Loki configuration reference
    • Loki HTTP API
    • Python examples
  • Community
    • Contacting the Loki Team
    • Contributing to Loki
    • Governance
    • Maintaining
      • Releasing Grafana Loki
        • Backport commits
        • Create Release Branch
        • Document metrics and configurations changes
        • Merge Release PR
        • Patch Go version
        • Patch vulnerabilities
        • Prepare Major Release
        • Prepare Release
        • Prepare Upgrade guide
        • Update version numbers
        • Version
      • Releasing Loki Build Image
    • Loki Improvement Documents (LIDs)
      • 0001: Introducing LIDs
      • 0002: Remote Rule Evaluation
      • 0003: Query fairness across users within tenants
      • 0004: Index Gateway Sharding
      • 0005: Loki mixin configuration improvements
      • 0006: Expose Split Logic in API
    • Design documents
      • Labels
      • Promtail Push API
      • Write-Ahead Logs
      • Ordering Constraint Removal
  • Copyright notice
Scroll for more
Read this in Grafana Cloud

Is this page helpful?

On this page
  • When to use structured metadata
  • Enable or disable structured metadata
  • Attaching structured metadata to log lines
  • Querying structured metadata
Scroll for more

Still have questions?

Ask your questions. Let AI do the heavy lifting.

Ask AI icon
Newsletter icon

Get every update

Subscribe to our newsletter

By submitting, you agree to our Privacy policy

Grafana Cloud

  • Overview
  • Pricing
  • What's in the free tier?
  • AI Assistant
  • Application Observability
  • Kubernetes Monitoring
  • Dashboards & Visualization
  • Database Observability
  • Frontend Observability
  • Synthetic Monitoring
  • Performance & Load Testing
  • Incident Response & Management
  • What’s New
  • Grafana Cloud Status

Solutions

  • AI Observability
  • Full-Stack Observability
  • Infrastructure & Cloud Observability
  • Digital Experience Monitoring
  • Scaled Prometheus
  • Cost Management & Optimization
  • Site Reliability
  • Log Management
  • Migrate to OpenTelemetry

Integrations

  • All Integrations
  • All Plugins
  • AWS
  • Google Cloud
  • Microsoft Azure
  • Kubernetes
  • Datadog
  • New Relic

Open Source

  • Our Projects
  • GitHub
  • Downloads
  • Dashboard Templates

Learn

  • Documentation
  • Blog
  • Community
  • Events
  • Observability Survey & Reports

Company

  • About Grafana Labs
  • Careers
  • Partnerships
  • Newsroom
  • Success Stories
  • Contact Us
  • Getting Help
  • Professional Services
  • Hey AI

Compare

  • Datadog vs. Grafana Cloud
  • Dynatrace vs. Grafana Cloud
  • Elasticsearch vs. Grafana Cloud
  • New Relic vs. Grafana Cloud
  • PagerDuty vs. Grafana Cloud
  • Splunk vs. Grafana Cloud
Grafana Labs x unique logomark

Donut take our word for it. Try Grafana Cloud today.

Grafana Cloud StatusLegal & SecurityTerms of ServicePrivacy PolicyTrademark Policy

Copyright 2026 © Grafana Labs

FacebookXLinkedinGithubYoutubeReddit
Grafana Labs uses cookies for the normal operation of this website. Learn more.