<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Apply labeling strategy to logs on Grafana Labs</title><link>https://grafana.com/docs/learning-hub/labeling-strategy/04-logs-labeling/</link><description>Recent content in Apply labeling strategy to logs on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/learning-hub/labeling-strategy/04-logs-labeling/index.xml" rel="self" type="application/rss+xml"/><item><title>Labels tell you where</title><link>https://grafana.com/docs/learning-hub/labeling-strategy/04-logs-labeling/16-labels-tell-you-where/</link><pubDate>Thu, 06 Aug 2026 10:05:27 -0400</pubDate><guid>https://grafana.com/docs/learning-hub/labeling-strategy/04-logs-labeling/16-labels-tell-you-where/</guid><content><![CDATA[&lt;h2 id=&#34;labels-tell-you-where&#34;&gt;Labels tell you where&lt;/h2&gt;
&lt;p&gt;Loki, which powers Grafana Cloud Logs, takes the idea of a fewest labels principle further than metrics by indexing only your labels, not the log content, so every label combination splits your logs into another stream to index and store.&lt;/p&gt;
&lt;p&gt;Good log labels describe the origin or context of the log; for example, application, namespace, environment, cluster, or region. These are static, bounded, and what you actually filter by when you start a search. Loki performs best with few labels, and the fewer streams you create, the smaller the index and the faster your queries.&lt;/p&gt;

&lt;div class=&#34;learning-hub-image&#34;&gt;
  &lt;a href=&#34;log-stream-splitting.svg&#34; title=&#34;One application splitting into four log streams because two labels with two values each create four unique label combinations&#34;&gt;
    &lt;img
      class=&#34;lazyload d-inline-block&#34;
      data-src=&#34;log-stream-splitting.svg&#34;
      alt=&#34;One application splitting into four log streams because two labels with two values each create four unique label combinations&#34; width=&#34;800&#34; height=&#34;470&#34;/&gt;
    &lt;div class=&#34;learning-hub-image__zoom&#34;&gt;
      &lt;svg width=&#34;24&#34; height=&#34;24&#34; viewBox=&#34;0 0 24 24&#34; fill=&#34;none&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;
        &lt;path d=&#34;M21 21L15 15M17 10C17 13.866 13.866 17 10 17C6.13401 17 3 13.866 3 10C3 6.13401 6.13401 3 10 3C13.866 3 17 6.13401 17 10Z&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;
        &lt;path d=&#34;M10 7V13M7 10H13&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; stroke-linecap=&#34;round&#34;/&gt;
      &lt;/svg&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;

]]></content><description>&lt;h2 id="labels-tell-you-where">Labels tell you where&lt;/h2>
&lt;p>Loki, which powers Grafana Cloud Logs, takes the idea of a fewest labels principle further than metrics by indexing only your labels, not the log content, so every label combination splits your logs into another stream to index and store.&lt;/p></description></item><item><title>Use dynamic labels sparingly</title><link>https://grafana.com/docs/learning-hub/labeling-strategy/04-logs-labeling/17-use-dynamic-labels-sparingly/</link><pubDate>Thu, 06 Aug 2026 10:05:27 -0400</pubDate><guid>https://grafana.com/docs/learning-hub/labeling-strategy/04-logs-labeling/17-use-dynamic-labels-sparingly/</guid><content><![CDATA[&lt;h2 id=&#34;use-dynamic-labels-sparingly&#34;&gt;Use dynamic labels sparingly&lt;/h2&gt;
&lt;p&gt;A &lt;strong&gt;dynamic label&lt;/strong&gt; is a label whose value is extracted from a log line&amp;rsquo;s content at ingestion or query time, which means the label values can vary. This variance can cause a single stream to split into many streams instead of being fixed, or static. For example, if your app writes &lt;code&gt;level=error&lt;/code&gt; into each log line, promoting that value to a &lt;code&gt;level&lt;/code&gt; label makes it dynamic. Turning an HTTP status class like &lt;code&gt;2xx&lt;/code&gt; or &lt;code&gt;5xx&lt;/code&gt; from access logs into a label is another common case. Use dynamic labels rarely, and only when all of the following are true:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The value set is low-cardinality, ideally tens of values.&lt;/li&gt;
&lt;li&gt;The values are long lived, such as the first segment of an HTTP path, not ephemeral IDs.&lt;/li&gt;
&lt;li&gt;Users actually query by the label frequently.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Otherwise, don&amp;rsquo;t index it. Loki&amp;rsquo;s &lt;strong&gt;filter expressions&lt;/strong&gt;, which search log content at query time, are fast. &lt;code&gt;{app=&amp;quot;api&amp;quot;} |= &amp;quot;level=error&amp;quot;&lt;/code&gt; performs comparably to a &lt;code&gt;level&lt;/code&gt; label for many workloads, without splitting your streams. Don&amp;rsquo;t add a label until you know you need it.&lt;/p&gt;
]]></content><description>&lt;h2 id="use-dynamic-labels-sparingly">Use dynamic labels sparingly&lt;/h2>
&lt;p>A &lt;strong>dynamic label&lt;/strong> is a label whose value is extracted from a log line&amp;rsquo;s content at ingestion or query time, which means the label values can vary. This variance can cause a single stream to split into many streams instead of being fixed, or static. For example, if your app writes &lt;code>level=error&lt;/code> into each log line, promoting that value to a &lt;code>level&lt;/code> label makes it dynamic. Turning an HTTP status class like &lt;code>2xx&lt;/code> or &lt;code>5xx&lt;/code> from access logs into a label is another common case. Use dynamic labels rarely, and only when all of the following are true:&lt;/p></description></item><item><title>The decision framework</title><link>https://grafana.com/docs/learning-hub/labeling-strategy/04-logs-labeling/18-the-decision-framework/</link><pubDate>Thu, 06 Aug 2026 10:05:27 -0400</pubDate><guid>https://grafana.com/docs/learning-hub/labeling-strategy/04-logs-labeling/18-the-decision-framework/</guid><content><![CDATA[&lt;h2 id=&#34;the-decision-framework&#34;&gt;The decision framework&lt;/h2&gt;
&lt;p&gt;For any piece of log data, ask where it belongs.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;If you filter by it in almost every query, and it&amp;rsquo;s bounded,&lt;/strong&gt; make it a label. Example: &lt;code&gt;env&lt;/code&gt;, &lt;code&gt;app&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;It&amp;rsquo;s high-cardinality but you query it often,&lt;/strong&gt; attach it as &lt;a href=&#34;/docs/loki/latest/get-started/labels/structured-metadata/&#34;&gt;&lt;strong&gt;structured metadata&lt;/strong&gt;&lt;/a&gt;. It&amp;rsquo;s queryable with a label filter expression, such as &lt;code&gt;{job=&amp;quot;example&amp;quot;} | pod=&amp;quot;myservice-abc1234-56789&amp;quot;&lt;/code&gt;, without being indexed or creating streams. Examples: pod names, process IDs, trace IDs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Everything else,&lt;/strong&gt; leave it in the log line and extract it at query time with parsers like &lt;code&gt;json&lt;/code&gt; or &lt;code&gt;logfmt&lt;/code&gt;, or search it with filter expressions.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;learning-hub-image&#34;&gt;
  &lt;a href=&#34;label-decision-framework.svg&#34; title=&#34;Decision tree routing a piece of log data to a label, structured metadata, or the log line, based on how often it&amp;#39;s queried and whether it&amp;#39;s bounded&#34;&gt;
    &lt;img
      class=&#34;lazyload d-inline-block&#34;
      data-src=&#34;label-decision-framework.svg&#34;
      alt=&#34;Decision tree routing a piece of log data to a label, structured metadata, or the log line, based on how often it&amp;#39;s queried and whether it&amp;#39;s bounded&#34; width=&#34;800&#34; height=&#34;440&#34;/&gt;
    &lt;div class=&#34;learning-hub-image__zoom&#34;&gt;
      &lt;svg width=&#34;24&#34; height=&#34;24&#34; viewBox=&#34;0 0 24 24&#34; fill=&#34;none&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;
        &lt;path d=&#34;M21 21L15 15M17 10C17 13.866 13.866 17 10 17C6.13401 17 3 13.866 3 10C3 6.13401 6.13401 3 10 3C13.866 3 17 6.13401 17 10Z&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;
        &lt;path d=&#34;M10 7V13M7 10H13&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; stroke-linecap=&#34;round&#34;/&gt;
      &lt;/svg&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;

]]></content><description>&lt;h2 id="the-decision-framework">The decision framework&lt;/h2>
&lt;p>For any piece of log data, ask where it belongs.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>If you filter by it in almost every query, and it&amp;rsquo;s bounded,&lt;/strong> make it a label. Example: &lt;code>env&lt;/code>, &lt;code>app&lt;/code>.&lt;/li>
&lt;li>&lt;strong>It&amp;rsquo;s high-cardinality but you query it often,&lt;/strong> attach it as &lt;a href="/docs/loki/latest/get-started/labels/structured-metadata/">&lt;strong>structured metadata&lt;/strong>&lt;/a>. It&amp;rsquo;s queryable with a label filter expression, such as &lt;code>{job=&amp;quot;example&amp;quot;} | pod=&amp;quot;myservice-abc1234-56789&amp;quot;&lt;/code>, without being indexed or creating streams. Examples: pod names, process IDs, trace IDs.&lt;/li>
&lt;li>&lt;strong>Everything else,&lt;/strong> leave it in the log line and extract it at query time with parsers like &lt;code>json&lt;/code> or &lt;code>logfmt&lt;/code>, or search it with filter expressions.&lt;/li>
&lt;/ul>
&lt;div class="learning-hub-image">
&lt;a href="label-decision-framework.svg" title="Decision tree routing a piece of log data to a label, structured metadata, or the log line, based on how often it&amp;#39;s queried and whether it&amp;#39;s bounded">
&lt;img
class="lazyload d-inline-block"
data-src="label-decision-framework.svg"
alt="Decision tree routing a piece of log data to a label, structured metadata, or the log line, based on how often it&amp;#39;s queried and whether it&amp;#39;s bounded" width="800" height="440"/>
&lt;div class="learning-hub-image__zoom">
&lt;svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
&lt;path d="M21 21L15 15M17 10C17 13.866 13.866 17 10 17C6.13401 17 3 13.866 3 10C3 6.13401 6.13401 3 10 3C13.866 3 17 6.13401 17 10Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
&lt;path d="M10 7V13M7 10H13" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
&lt;/svg>
&lt;/div>
&lt;/a>
&lt;/div></description></item><item><title>Audit what your clients send</title><link>https://grafana.com/docs/learning-hub/labeling-strategy/04-logs-labeling/19-audit-what-your-clients-send/</link><pubDate>Thu, 06 Aug 2026 10:05:27 -0400</pubDate><guid>https://grafana.com/docs/learning-hub/labeling-strategy/04-logs-labeling/19-audit-what-your-clients-send/</guid><content><![CDATA[&lt;h2 id=&#34;audit-what-your-clients-send&#34;&gt;Audit what your clients send&lt;/h2&gt;
&lt;p&gt;Collectors and agents can attach dynamic labels you didn&amp;rsquo;t choose. Use the fewest labels test on whatever Alloy, Fluentd, or your Docker driver is applying. To see your streams and find high-cardinality labels, run:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;logcli series &amp;#39;{}&amp;#39; --since=1h --analyze-labels&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;A label with thousands of unique values found in nearly every stream, such as a &lt;code&gt;requestId&lt;/code&gt;, should be removed from labels and queried with a filter expression instead.&lt;/p&gt;
&lt;p&gt;If many teams send logs and you can&amp;rsquo;t audit or change every client, apply the same approach you learned for metrics: route logs through gateway collectors your admin team owns, enforce label policy at that layer, and manage those gateway configurations centrally with &lt;a href=&#34;/docs/grafana-cloud/send-data/fleet-management/&#34;&gt;Fleet Management&lt;/a&gt;.&lt;/p&gt;
]]></content><description>&lt;h2 id="audit-what-your-clients-send">Audit what your clients send&lt;/h2>
&lt;p>Collectors and agents can attach dynamic labels you didn&amp;rsquo;t choose. Use the fewest labels test on whatever Alloy, Fluentd, or your Docker driver is applying. To see your streams and find high-cardinality labels, run:&lt;/p></description></item><item><title>Resources</title><link>https://grafana.com/docs/learning-hub/labeling-strategy/04-logs-labeling/20-resources/</link><pubDate>Thu, 06 Aug 2026 10:05:27 -0400</pubDate><guid>https://grafana.com/docs/learning-hub/labeling-strategy/04-logs-labeling/20-resources/</guid><content><![CDATA[&lt;h2 id=&#34;documentation&#34;&gt;Documentation&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;/docs/loki/latest/get-started/labels/bp-labels/&#34;&gt;Label best practices&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;/docs/loki/latest/get-started/labels/structured-metadata/&#34;&gt;What is structured metadata&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;community&#34;&gt;Community&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://community.grafana.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Grafana Community Forums&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://slack.grafana.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Grafana Slack&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h2 id="documentation">Documentation&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="/docs/loki/latest/get-started/labels/bp-labels/">Label best practices&lt;/a>&lt;/li>
&lt;li>&lt;a href="/docs/loki/latest/get-started/labels/structured-metadata/">What is structured metadata&lt;/a>&lt;/li>
&lt;/ul>
&lt;h2 id="community">Community&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://community.grafana.com/" target="_blank" rel="noopener noreferrer">Grafana Community Forums&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://slack.grafana.com/" target="_blank" rel="noopener noreferrer">Grafana Slack&lt;/a>&lt;/li>
&lt;/ul></description></item></channel></rss>