<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Send log data to Grafana Enterprise Logs on Grafana Labs</title><link>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/</link><description>Recent content in Send log data to Grafana Enterprise Logs on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/enterprise-logs/v3.6.x/send-data/index.xml" rel="self" type="application/rss+xml"/><item><title>Configure Promtail for Grafana Enterprise Logs</title><link>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/promtail/</link><pubDate>Sat, 11 Apr 2026 00:53:11 +0000</pubDate><guid>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/promtail/</guid><content><![CDATA[&lt;h1 id=&#34;configure-promtail-for-grafana-enterprise-logs&#34;&gt;Configure Promtail for Grafana Enterprise Logs&lt;/h1&gt;
&lt;p&gt;&lt;a href=&#34;/docs/loki/latest/clients/promtail/&#34;&gt;Promtail&lt;/a&gt; is an agent that ships the contents of
local logs to Grafana Enterprise Logs (GEL).&lt;/p&gt;
&lt;h2 id=&#34;verify-that-promtail-is-running&#34;&gt;Verify that Promtail is running&lt;/h2&gt;
&lt;p&gt;Because there are several ways to &lt;a href=&#34;/docs/loki/latest/clients/promtail/installation/&#34;&gt;Install Promtail&lt;/a&gt;, there are also several ways to verify that it is running. If you need help at all, submit a &lt;a href=&#34;/contact?about=support&amp;amp;topic=Verify%20Promtail%20is%20running&#34;&gt;Support Request&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For the following common installation methods, check that Promtail is running:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;binary: To check that the executable is running, use &lt;code&gt;ps -ef | grep promtail&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Docker: To check if a Promtail container is running, run &lt;code&gt;docker ps&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Kubernetes: To check that Promtail pods are running, use the &lt;code&gt;kubectl get pods | grep promtail&lt;/code&gt; command when you are in the correct namespace.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;configure-promtail-to-write-to-gel&#34;&gt;Configure Promtail to write to GEL&lt;/h2&gt;
&lt;p&gt;To configure Promtail to send logs to the &lt;strong&gt;demo&lt;/strong&gt; tenant, add a clients block to its configuration.&lt;/p&gt;
&lt;p&gt;Example of a minimal configuration:&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;YAML&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-yaml&#34;&gt;server:
  http_listen_port: 9080
  grpc_listen_port: 0

positions:
  filename: /tmp/positions.yaml

clients:
  - url: http://enterprise-logs:3100/loki/api/v1/push
    basic_auth:
      username: demo
      password: &amp;lt;token&amp;gt;

scrape_configs:
- job_name: system
  static_configs:
  - targets:
      - localhost
    labels:
      job: varlogs
      __path__: /var/log/*log&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;For more information, refer to &lt;a href=&#34;/docs/loki/latest/clients/promtail/configuration/&#34;&gt;Configuring Promtail&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;run-this-promtail-configuration-using-docker&#34;&gt;Run this Promtail configuration using Docker&lt;/h2&gt;
&lt;p&gt;To run this configuration, store the preceding configuration locally in the file &lt;code&gt;promtail.yaml&lt;/code&gt;, and run the following code:&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;console&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-console&#34;&gt;$ docker run \
   -d \
   --name=demo-promtail \
   --network=enterprise-logs \
   -v $(pwd)/promtail.yaml:/etc/promtail/config.yml:z \
   grafana/promtail:2.1.0&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;verify-that-promtail-is-writing-to-gel&#34;&gt;Verify that Promtail is writing to GEL&lt;/h2&gt;
&lt;p&gt;From Grafana &lt;strong&gt;Explore&lt;/strong&gt;, you can query the data from your GEL cluster via the &lt;strong&gt;Enterprise Logs&lt;/strong&gt; data source.&lt;/p&gt;
]]></content><description>&lt;h1 id="configure-promtail-for-grafana-enterprise-logs">Configure Promtail for Grafana Enterprise Logs&lt;/h1>
&lt;p>&lt;a href="/docs/loki/latest/clients/promtail/">Promtail&lt;/a> is an agent that ships the contents of
local logs to Grafana Enterprise Logs (GEL).&lt;/p>
&lt;h2 id="verify-that-promtail-is-running">Verify that Promtail is running&lt;/h2>
&lt;p>Because there are several ways to &lt;a href="/docs/loki/latest/clients/promtail/installation/">Install Promtail&lt;/a>, there are also several ways to verify that it is running. If you need help at all, submit a &lt;a href="/contact?about=support&amp;amp;topic=Verify%20Promtail%20is%20running">Support Request&lt;/a>.&lt;/p></description></item><item><title>Ingesting logs to Loki using Alloy</title><link>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/alloy/</link><pubDate>Sat, 11 Apr 2026 00:53:11 +0000</pubDate><guid>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/alloy/</guid><content><![CDATA[&lt;h1 id=&#34;ingesting-logs-to-loki-using-alloy&#34;&gt;Ingesting logs to Loki using Alloy&lt;/h1&gt;
&lt;p&gt;Grafana Alloy is a versatile observability collector that can ingest logs in various formats and send them to Loki. We recommend Alloy as the primary method for sending logs to Loki, as it provides a more robust and feature-rich solution for building a highly scalable and reliable observability pipeline.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 1277px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/media/docs/alloy/flow-diagram-small-alloy.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/media/docs/alloy/flow-diagram-small-alloy.png&#34;data-srcset=&#34;/media/docs/alloy/flow-diagram-small-alloy.png?w=320 320w, /media/docs/alloy/flow-diagram-small-alloy.png?w=550 550w, /media/docs/alloy/flow-diagram-small-alloy.png?w=750 750w, /media/docs/alloy/flow-diagram-small-alloy.png?w=900 900w, /media/docs/alloy/flow-diagram-small-alloy.png?w=1040 1040w, /media/docs/alloy/flow-diagram-small-alloy.png?w=1240 1240w, /media/docs/alloy/flow-diagram-small-alloy.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Alloy flow diagram&#34;width=&#34;1277&#34;height=&#34;454&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/alloy/flow-diagram-small-alloy.png&#34;
            alt=&#34;Alloy flow diagram&#34;width=&#34;1277&#34;height=&#34;454&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h2 id=&#34;installing-alloy&#34;&gt;Installing Alloy&lt;/h2&gt;
&lt;p&gt;To get started with Grafana Alloy and send logs to Loki, you need to install and configure Alloy. You can follow the &lt;a href=&#34;/docs/alloy/latest/get-started/install/&#34;&gt;Alloy documentation&lt;/a&gt; to install Alloy on your preferred platform.&lt;/p&gt;
&lt;h2 id=&#34;components-of-alloy-for-logs&#34;&gt;Components of Alloy for logs&lt;/h2&gt;
&lt;p&gt;Alloy pipelines are built using components that perform specific functions. For logs these can be broken down into three categories:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Collector:&lt;/strong&gt; These components collect/receive logs from various sources. This can be scraping logs from a file, receiving logs over HTTP, gRPC or ingesting logs from a message queue.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Transformer:&lt;/strong&gt; These components can be used to manipulate logs before they are sent to a writer. This can be used to add additional metadata, filter logs, or batch logs before sending them to a writer.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Writer:&lt;/strong&gt; These components send logs to the desired destination. Our documentation will focus on sending logs to Loki, but Alloy supports sending logs to various destinations.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;log-components-in-alloy&#34;&gt;Log components in Alloy&lt;/h3&gt;
&lt;p&gt;Here is a non-exhaustive list of components that can be used to build a log pipeline in Alloy. For a complete list of components, refer to the &lt;a href=&#34;/docs/alloy/latest/reference/components/&#34;&gt;components list&lt;/a&gt;.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Component&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Collector&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/loki.source.api/&#34;&gt;loki.source.api&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Collector&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/loki.source.awsfirehose/&#34;&gt;loki.source.awsfirehose&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Collector&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/loki.source.azure_event_hubs/&#34;&gt;loki.source.azure_event_hubs&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Collector&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/loki.source.cloudflare/&#34;&gt;loki.source.cloudflare&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Collector&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/loki.source.docker/&#34;&gt;loki.source.docker&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Collector&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/loki.source.file/&#34;&gt;loki.source.file&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Collector&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/loki.source.gcplog/&#34;&gt;loki.source.gcplog&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Collector&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/loki.source.gelf/&#34;&gt;loki.source.gelf&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Collector&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/loki.source.heroku/&#34;&gt;loki.source.heroku&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Collector&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/loki.source.journal/&#34;&gt;loki.source.journal&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Collector&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/loki.source.kafka/&#34;&gt;loki.source.kafka&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Collector&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/loki.source.kubernetes/&#34;&gt;loki.source.kubernetes&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Collector&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/loki.source.kubernetes_events/&#34;&gt;loki.source.kubernetes_events&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Collector&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/loki.source.podlogs/&#34;&gt;loki.source.podlogs&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Collector&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/loki.source.syslog/&#34;&gt;loki.source.syslog&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Collector&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/loki.source.windowsevent/&#34;&gt;loki.source.windowsevent&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Collector&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/otelcol.receiver.loki/&#34;&gt;otelcol.receiver.loki&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Transformer&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/loki.relabel/&#34;&gt;loki.relabel&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Transformer&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/loki.process/&#34;&gt;loki.process&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Writer&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/loki.write/&#34;&gt;loki.write&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Writer&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/otelcol.exporter.loki/&#34;&gt;otelcol.exporter.loki&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;learning-path&#34;&gt;Learning path&lt;/h2&gt;




&lt;div class=&#34;d-sm-flex flex-direction-row-reverse bg-gray-1 br-12 p-2 my-1&#34;&gt;
  &lt;img class=&#34;maxw-240 w-100p mb-1 lazyload&#34; data-src=&#34;/media/docs/learning-journey/map.svg&#34; width=&#34;237&#34; height=&#34;154&#34; alt=&#34;Grafana Learning Journeys&#34;&gt;
  &lt;div&gt;
    &lt;div class=&#34;h4 pt-0 pb-half fw-500&#34;&gt;Start your learning experience with Grafana Learning Paths&lt;/div&gt;
    &lt;p class=&#34;pr-1 pb-half&#34;&gt;Grafana Learning Paths provide a clear, structured path that leads you from beginner concepts to advanced use cases. Learn about this Grafana feature on &lt;a href=&#34;/docs/learning-paths/send-logs-alloy-loki/&#34;&gt;Send logs to Grafana Cloud using Alloy&lt;/a&gt;.&lt;/p&gt;
    &lt;div class=&#34;mx-auto&#34;&gt;
      &lt;a class=&#34;btn btn--primary btn--large arrow fw-600 br-8 w-175&#34; href=&#34;https://grafana.com/docs/learning-paths/send-logs-alloy-loki/&#34;&gt;Start learning&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;h2 id=&#34;interactive-tutorials&#34;&gt;Interactive Tutorials&lt;/h2&gt;
&lt;p&gt;To learn more about how to configure Alloy to send logs to Loki within different scenarios, follow these interactive tutorials:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;examples/alloy-otel-logs/&#34;&gt;Sending OpenTelemetry logs to Loki using Alloy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;examples/alloy-kafka-logs/&#34;&gt;Sending logs over Kafka to Loki using Alloy&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="ingesting-logs-to-loki-using-alloy">Ingesting logs to Loki using Alloy&lt;/h1>
&lt;p>Grafana Alloy is a versatile observability collector that can ingest logs in various formats and send them to Loki. We recommend Alloy as the primary method for sending logs to Loki, as it provides a more robust and feature-rich solution for building a highly scalable and reliable observability pipeline.&lt;/p></description></item><item><title>Install Promtail</title><link>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/promtail/installation/</link><pubDate>Sat, 11 Apr 2026 00:53:11 +0000</pubDate><guid>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/promtail/installation/</guid><content><![CDATA[&lt;h1 id=&#34;install-promtail&#34;&gt;Install Promtail&lt;/h1&gt;


&lt;div data-shared=&#34;promtail-deprecation.md&#34;&gt;
            

&lt;div class=&#34;admonition admonition-caution&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Caution&lt;/p&gt;&lt;p&gt;Promtail has been deprecated and is in Long-Term Support (LTS) through February 28, 2026. Promtail will reach an End-of-Life (EOL) on March 2, 2026. You can find migration resources &lt;a href=&#34;/docs/alloy/latest/set-up/migrate/from-promtail/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;/div&gt;

        
&lt;p&gt;Promtail is distributed as a binary, in a Docker container,
or there is a Helm chart to install it in a Kubernetes cluster.&lt;/p&gt;
&lt;h2 id=&#34;install-the-binary&#34;&gt;Install the binary&lt;/h2&gt;
&lt;p&gt;Every Grafana Loki release includes binaries for Promtail which can be found on the
&lt;a href=&#34;https://github.com/grafana/loki/releases&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Releases page&lt;/a&gt; as part of the release assets.&lt;/p&gt;
&lt;h2 id=&#34;install-using-apt-or-rpm-package-manager&#34;&gt;Install using APT or RPM package manager&lt;/h2&gt;
&lt;p&gt;See the instructions 
    &lt;a href=&#34;/docs/loki/v3.6.x/setup/install/local/#install-using-apt-or-rpm-package-manager&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;install-using-docker&#34;&gt;Install using Docker&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Make sure to modify the tag to the most recent version.&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;docker pull grafana/promtail:3.6.0&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create your Promtail configuration file in a file called &lt;code&gt;promtail-config.yaml&lt;/code&gt;. Refer to the 
    &lt;a href=&#34;/docs/loki/v3.6.x/send-data/promtail/configuration/&#34;&gt;Promtail configuration reference&lt;/a&gt; for more details.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Note that you will need to replace &lt;code&gt;&amp;lt;local-path&amp;gt;&lt;/code&gt; in the commands with your local path and may need to update the release version to match the current release.&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;docker run -v &amp;lt;local-path&amp;gt;:/mnt/config -v /var/log:/var/log --link loki grafana/promtail:3.6.0 --config.file=/mnt/config/promtail-config.yaml&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;install-on-macos-with-homebrew&#34;&gt;Install on MacOS with Homebrew&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;If necessary, install &lt;a href=&#34;https://brew.sh/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Homebrew&lt;/a&gt;.&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;/bin/bash -c &amp;#34;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Update Homebrew.&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;brew update&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Navigate to the &lt;a href=&#34;https://formulae.brew.sh/formula/promtail&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;homebrew page for Promtail&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To install Promtail, run the following command:&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;brew install promtail&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Check that installation was successful.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Check that promtail exists in its install directory.&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;which promtail&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run promtail&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;promtail&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;install-using-helm&#34;&gt;Install using Helm&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Make sure that Helm is installed. See &lt;a href=&#34;https://helm.sh/docs/intro/install/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Installing Helm&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Then you can add Grafana&amp;rsquo;s chart repository to Helm:&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;helm repo add grafana https://grafana.github.io/helm-charts&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Update the chart repository:&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;helm repo update&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create the configuration file &lt;code&gt;values.yaml&lt;/code&gt;. The example below illustrates a connection to the locally deployed loki server:&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;YAML&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-yaml&#34;&gt;config:
# publish data to loki
  clients:
    - url: http://loki-gateway/loki/api/v1/push
      tenant_id: 1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Finally, Promtail can be deployed with:&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;# The default helm configuration deploys promtail as a daemonSet (recommended)
helm upgrade --values values.yaml --install promtail grafana/promtail&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;install-as-kubernetes-daemonset-recommended&#34;&gt;Install as Kubernetes daemonSet (recommended)&lt;/h2&gt;
&lt;p&gt;A &lt;code&gt;DaemonSet&lt;/code&gt; will deploy Promtail on every node within a Kubernetes cluster.&lt;/p&gt;
&lt;p&gt;The DaemonSet deployment works well at collecting the logs of all containers within a
cluster. It&amp;rsquo;s the best solution for a single-tenant model. Replace &lt;code&gt;{YOUR_LOKI_ENDPOINT}&lt;/code&gt; with your Loki endpoint.&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;YAML&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-yaml&#34;&gt;--- # Daemonset.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: promtail-daemonset
spec:
  selector:
    matchLabels:
      name: promtail
  template:
    metadata:
      labels:
        name: promtail
    spec:
      serviceAccount: promtail-serviceaccount
      containers:
      - name: promtail-container
        image: grafana/promtail
        args:
        - -config.file=/etc/promtail/promtail.yaml
        env: 
        - name: &amp;#39;HOSTNAME&amp;#39; # needed when using kubernetes_sd_configs
          valueFrom:
            fieldRef:
              fieldPath: &amp;#39;spec.nodeName&amp;#39;
        volumeMounts:
        - name: logs
          mountPath: /var/log
        - name: promtail-config
          mountPath: /etc/promtail
        - mountPath: /var/lib/docker/containers
          name: varlibdockercontainers
          readOnly: true
      volumes:
      - name: logs
        hostPath:
          path: /var/log
      - name: varlibdockercontainers
        hostPath:
          path: /var/lib/docker/containers
      - name: promtail-config
        configMap:
          name: promtail-config
--- # configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: promtail-config
data:
  promtail.yaml: |
    server:
      http_listen_port: 9080
      grpc_listen_port: 0

    clients:
    - url: https://&amp;lt;YOUR_LOKI_ENDPOINT&amp;gt;/loki/api/v1/push

    positions:
      filename: /tmp/positions.yaml
    target_config:
      sync_period: 10s
    scrape_configs:
    - job_name: pod-logs
      kubernetes_sd_configs:
        - role: pod
      pipeline_stages:
        - docker: {}
      relabel_configs:
        - source_labels:
            - __meta_kubernetes_pod_node_name
          target_label: __host__
        - action: labelmap
          regex: __meta_kubernetes_pod_label_(.&amp;#43;)
        - action: replace
          replacement: $1
          separator: /
          source_labels:
            - __meta_kubernetes_namespace
            - __meta_kubernetes_pod_name
          target_label: job
        - action: replace
          source_labels:
            - __meta_kubernetes_namespace
          target_label: namespace
        - action: replace
          source_labels:
            - __meta_kubernetes_pod_name
          target_label: pod
        - action: replace
          source_labels:
            - __meta_kubernetes_pod_container_name
          target_label: container
        - replacement: /var/log/pods/*$1/*.log
          separator: /
          source_labels:
            - __meta_kubernetes_pod_uid
            - __meta_kubernetes_pod_container_name
          target_label: __path__

--- # Clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: promtail-clusterrole
rules:
  - apiGroups: [&amp;#34;&amp;#34;]
    resources:
    - nodes
    - services
    - pods
    verbs:
    - get
    - watch
    - list

--- # ServiceAccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: promtail-serviceaccount

--- # Rolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: promtail-clusterrolebinding
subjects:
    - kind: ServiceAccount
      name: promtail-serviceaccount
      namespace: default
roleRef:
    kind: ClusterRole
    name: promtail-clusterrole
    apiGroup: rbac.authorization.k8s.io&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="install-promtail">Install Promtail&lt;/h1>
&lt;div data-shared="promtail-deprecation.md">
&lt;div class="admonition admonition-caution">&lt;blockquote>&lt;p class="title text-uppercase">Caution&lt;/p>&lt;p>Promtail has been deprecated and is in Long-Term Support (LTS) through February 28, 2026. Promtail will reach an End-of-Life (EOL) on March 2, 2026. You can find migration resources &lt;a href="/docs/alloy/latest/set-up/migrate/from-promtail/">here&lt;/a>.&lt;/p></description></item><item><title>Configure Promtail</title><link>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/promtail/configuration/</link><pubDate>Sat, 11 Apr 2026 00:53:11 +0000</pubDate><guid>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/promtail/configuration/</guid><content><![CDATA[&lt;h1 id=&#34;configure-promtail&#34;&gt;Configure Promtail&lt;/h1&gt;


&lt;div data-shared=&#34;promtail-deprecation.md&#34;&gt;
            

&lt;div class=&#34;admonition admonition-caution&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Caution&lt;/p&gt;&lt;p&gt;Promtail has been deprecated and is in Long-Term Support (LTS) through February 28, 2026. Promtail will reach an End-of-Life (EOL) on March 2, 2026. You can find migration resources &lt;a href=&#34;/docs/alloy/latest/set-up/migrate/from-promtail/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;/div&gt;

        
&lt;p&gt;Promtail is configured in a YAML file (usually referred to as &lt;code&gt;config.yaml&lt;/code&gt;)
which contains information on the Promtail server, where positions are stored,
and how to scrape logs from files.&lt;/p&gt;
&lt;h2 id=&#34;printing-promtail-config-at-runtime&#34;&gt;Printing Promtail Config At Runtime&lt;/h2&gt;
&lt;p&gt;If you pass Promtail the flag &lt;code&gt;-print-config-stderr&lt;/code&gt; or &lt;code&gt;-log-config-reverse-order&lt;/code&gt;, (or &lt;code&gt;-print-config-stderr=true&lt;/code&gt;)
Promtail will dump the entire config object it has created from the built in defaults combined first with
overrides from config file, and second by overrides from flags.&lt;/p&gt;
&lt;p&gt;The result is the value for every config object in the Promtail config struct.&lt;/p&gt;
&lt;p&gt;Some values may not be relevant to your install, this is expected as every option has a default value if it is being used or not.&lt;/p&gt;
&lt;p&gt;This config is what Promtail will use to run, it can be invaluable for debugging issues related to configuration and
is especially useful in making sure your config files and flags are being read and loaded properly.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;-print-config-stderr&lt;/code&gt; is nice when running Promtail directly e.g. &lt;code&gt;./promtail &lt;/code&gt; as you can get a quick output of the entire Promtail config.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;-log-config-reverse-order&lt;/code&gt; is the flag we run Promtail with in all our environments, the config entries are reversed so
that the order of configs reads correctly top to bottom when viewed in Grafana&amp;rsquo;s Explore.&lt;/p&gt;
&lt;h2 id=&#34;configuration-file-reference&#34;&gt;Configuration File Reference&lt;/h2&gt;
&lt;p&gt;To specify which configuration file to load, pass the &lt;code&gt;-config.file&lt;/code&gt; flag at the
command line. The file is written in &lt;a href=&#34;https://en.wikipedia.org/wiki/YAML&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;YAML format&lt;/a&gt;,
defined by the schema below. Brackets indicate that a parameter is optional. For
non-list parameters the value is set to the specified default.&lt;/p&gt;
&lt;p&gt;For more detailed information on configuring how to discover and scrape logs from
targets, see &lt;a href=&#34;../scraping/&#34;&gt;Scraping&lt;/a&gt;. For more information on transforming logs
from scraped targets, see &lt;a href=&#34;../pipelines/&#34;&gt;Pipelines&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;reload-at-runtime&#34;&gt;Reload at runtime&lt;/h2&gt;
&lt;p&gt;Promtail can reload its configuration at runtime. If the new configuration
is not well-formed, the changes will not be applied.
A configuration reload is triggered by sending a &lt;code&gt;SIGHUP&lt;/code&gt; to the Promtail process or
sending a HTTP POST request to the &lt;code&gt;/reload&lt;/code&gt; endpoint (when the &lt;code&gt;--server.enable-runtime-reload&lt;/code&gt; flag is enabled).&lt;/p&gt;
&lt;h3 id=&#34;use-environment-variables-in-the-configuration&#34;&gt;Use environment variables in the configuration&lt;/h3&gt;
&lt;p&gt;You can use environment variable references in the configuration file to set values that need to be configurable during deployment.
To do this, pass &lt;code&gt;-config.expand-env=true&lt;/code&gt; and use:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&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&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;${VAR}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Where VAR is the name of the environment variable.&lt;/p&gt;
&lt;p&gt;Each variable reference is replaced at startup by the value of the environment variable.
The replacement is case-sensitive and occurs before the YAML file is parsed.
References to undefined variables are replaced by empty strings unless you specify a default value or custom error text.&lt;/p&gt;
&lt;p&gt;To specify a default value, use:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&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&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;${VAR:-default_value}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Where default_value is the value to use if the environment variable is undefined.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;With &lt;code&gt;expand-env=true&lt;/code&gt; the configuration will first run through
&lt;a href=&#34;https://pkg.go.dev/github.com/drone/envsubst&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;envsubst&lt;/a&gt; which will replace double
backslashes with single backslashes. Because of this every use of a backslash &lt;code&gt;\&lt;/code&gt; needs to
be replaced with a double backslash &lt;code&gt;\\&lt;/code&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;generic-placeholders&#34;&gt;Generic placeholders&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;boolean&amp;gt;&lt;/code&gt;: a boolean that can take the values &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;int&amp;gt;&lt;/code&gt;: any integer matching the regular expression &lt;code&gt;[1-9]&#43;[0-9]*&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;duration&amp;gt;&lt;/code&gt;: a duration matching the regular expression &lt;code&gt;[0-9]&#43;(ms|[smhdwy])&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;labelname&amp;gt;&lt;/code&gt;: a string matching the regular expression &lt;code&gt;[a-zA-Z_][a-zA-Z0-9_]*&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;labelvalue&amp;gt;&lt;/code&gt;: a string of Unicode characters&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;filename&amp;gt;&lt;/code&gt;: a valid path relative to current working directory or an
absolute path.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;host&amp;gt;&lt;/code&gt;: a valid string consisting of a hostname or IP followed by an optional port number&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;string&amp;gt;&lt;/code&gt;: a string&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;secret&amp;gt;&lt;/code&gt;: a string that represents a secret, such as a password&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;supported-contents-and-default-values-of-configyaml&#34;&gt;Supported contents and default values of &lt;code&gt;config.yaml&lt;/code&gt;:&lt;/h3&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;YAML&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-yaml&#34;&gt;# Configures global settings which impact all targets.
[global: &amp;lt;global_config&amp;gt;]

# Configures the server for Promtail.
[server: &amp;lt;server_config&amp;gt;]

# Describes how Promtail connects to multiple instances
# of Grafana Loki, sending logs to each.
# WARNING: If one of the remote Loki servers fails to respond or responds
# with any error which is retryable, this will impact sending logs to any
# other configured remote Loki servers.  Sending is done on a single thread!
# It is generally recommended to run multiple Promtail clients in parallel
# if you want to send to multiple remote Loki instances.
clients:
  - [&amp;lt;client_config&amp;gt;]

# Describes how to save read file offsets to disk
[positions: &amp;lt;position_config&amp;gt;]

scrape_configs:
  - [&amp;lt;scrape_config&amp;gt;]

# Configures global limits for this instance of Promtail
[limits_config: &amp;lt;limits_config&amp;gt;]

# Configures how tailed targets will be watched.
[target_config: &amp;lt;target_config&amp;gt;]

# Configures additional promtail configurations.
[options: &amp;lt;options_config&amp;gt;]

# Configures tracing support
[tracing: &amp;lt;tracing_config&amp;gt;]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;global&#34;&gt;global&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;global&lt;/code&gt; block configures global settings which impact all scrape targets:&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;YAML&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-yaml&#34;&gt;# Configure how frequently log files from disk get polled for changes.
[file_watch_config: &amp;lt;file_watch_config&amp;gt;]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;file_watch_config&#34;&gt;file_watch_config&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;file_watch_config&lt;/code&gt; block configures how often to poll log files from disk
for changes:&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;YAML&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-yaml&#34;&gt;# Minimum frequency to poll for files. Any time file changes are detected, the
# poll frequency gets reset to this duration.
[min_poll_frequency: &amp;lt;duration&amp;gt; | default = &amp;#34;250ms&amp;#34;]

# Maximum frequency to poll for files. Any time no file changes are detected,
# the poll frequency doubles in value up to the maximum duration specified by
# this value.
#
# The default is set to the same as min_poll_frequency.
[max_poll_frequency: &amp;lt;duration&amp;gt; | default = &amp;#34;250ms&amp;#34;]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;server&#34;&gt;server&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;server&lt;/code&gt; block configures Promtail&amp;rsquo;s behavior as an HTTP server:&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;YAML&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-yaml&#34;&gt;# Disable the HTTP and GRPC server.
[disable: &amp;lt;boolean&amp;gt; | default = false]

# Enable the /debug/fgprof and /debug/pprof endpoints for profiling.
[profiling_enabled: &amp;lt;boolean&amp;gt; | default = false]

# HTTP server listen host
[http_listen_address: &amp;lt;string&amp;gt;]

# HTTP server listen port (0 means random port)
[http_listen_port: &amp;lt;int&amp;gt; | default = 80]

# gRPC server listen host
[grpc_listen_address: &amp;lt;string&amp;gt;]

# gRPC server listen port (0 means random port)
[grpc_listen_port: &amp;lt;int&amp;gt; | default = 9095]

# Register instrumentation handlers (/metrics, etc.)
[register_instrumentation: &amp;lt;boolean&amp;gt; | default = true]

# Timeout for graceful shutdowns
[graceful_shutdown_timeout: &amp;lt;duration&amp;gt; | default = 30s]

# Read timeout for HTTP server
[http_server_read_timeout: &amp;lt;duration&amp;gt; | default = 30s]

# Write timeout for HTTP server
[http_server_write_timeout: &amp;lt;duration&amp;gt; | default = 30s]

# Idle timeout for HTTP server
[http_server_idle_timeout: &amp;lt;duration&amp;gt; | default = 120s]

# Max gRPC message size that can be received
[grpc_server_max_recv_msg_size: &amp;lt;int&amp;gt; | default = 4194304]

# Max gRPC message size that can be sent
[grpc_server_max_send_msg_size: &amp;lt;int&amp;gt; | default = 4194304]

# Limit on the number of concurrent streams for gRPC calls (0 = unlimited)
[grpc_server_max_concurrent_streams: &amp;lt;int&amp;gt; | default = 100]

# Log only messages with the given severity or above. Supported values [debug,
# info, warn, error]
[log_level: &amp;lt;string&amp;gt; | default = &amp;#34;info&amp;#34;]

# Base path to server all API routes from (e.g., /v1/).
[http_path_prefix: &amp;lt;string&amp;gt;]

# Target managers check flag for Promtail readiness, if set to false the check is ignored
[health_check_target: &amp;lt;bool&amp;gt; | default = true]

# Enable reload via HTTP request.
[enable_runtime_reload: &amp;lt;bool&amp;gt; | default = false]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;clients&#34;&gt;clients&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;clients&lt;/code&gt; block configures how Promtail connects to instances of
Loki:&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;YAML&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-yaml&#34;&gt;# The URL where Loki is listening, denoted in Loki as http_listen_address and
# http_listen_port. If Loki is running in microservices mode, this is the HTTP
# URL for the Distributor. Path to the push API needs to be included.
# Example: http://example.com:3100/loki/api/v1/push
url: &amp;lt;string&amp;gt;

# Custom HTTP headers to be sent along with each push request.
# Be aware that headers that are set by Promtail itself (e.g. X-Scope-OrgID) can&amp;#39;t be overwritten.
headers:
  # Example: CF-Access-Client-Id: xxx
  [ &amp;lt;labelname&amp;gt;: &amp;lt;labelvalue&amp;gt; ... ]

# The tenant ID used by default to push logs to Loki. If omitted or empty
# it assumes Loki is running in single-tenant mode and no X-Scope-OrgID header
# is sent.
[tenant_id: &amp;lt;string&amp;gt;]

# Maximum amount of time to wait before sending a batch, even if that
# batch isn&amp;#39;t full.
[batchwait: &amp;lt;duration&amp;gt; | default = 1s]

# Maximum batch size (in bytes) of logs to accumulate before sending
# the batch to Loki.
[batchsize: &amp;lt;int&amp;gt; | default = 1048576]

# If using basic auth, configures the username and password
# sent.
basic_auth:
  # The username to use for basic auth
  [username: &amp;lt;string&amp;gt;]

  # The password to use for basic auth
  [password: &amp;lt;string&amp;gt;]

  # The file containing the password for basic auth
  [password_file: &amp;lt;filename&amp;gt;]

# Optional OAuth 2.0 configuration
# Cannot be used at the same time as basic_auth or authorization
oauth2:
  # Client id and secret for oauth2
  [client_id: &amp;lt;string&amp;gt;]
  [client_secret: &amp;lt;secret&amp;gt;]

  # Read the client secret from a file
  # It is mutually exclusive with `client_secret`
  [client_secret_file: &amp;lt;filename&amp;gt;]

  # Optional scopes for the token request
  scopes:
    [ - &amp;lt;string&amp;gt; ... ]

  # The URL to fetch the token from
  token_url: &amp;lt;string&amp;gt;

  # Optional parameters to append to the token URL
  endpoint_params:
    [ &amp;lt;string&amp;gt;: &amp;lt;string&amp;gt; ... ]

# Bearer token to send to the server.
[bearer_token: &amp;lt;secret&amp;gt;]

# File containing bearer token to send to the server.
[bearer_token_file: &amp;lt;filename&amp;gt;]

# HTTP proxy server to use to connect to the server.
[proxy_url: &amp;lt;string&amp;gt;]

# If connecting to a TLS server, configures how the TLS
# authentication handshake will operate.
tls_config:
  # The CA file to use to verify the server
  [ca_file: &amp;lt;string&amp;gt;]

  # The cert file to send to the server for client auth
  [cert_file: &amp;lt;filename&amp;gt;]

  # The key file to send to the server for client auth
  [key_file: &amp;lt;filename&amp;gt;]

  # Validates that the server name in the server&amp;#39;s certificate
  # is this value.
  [server_name: &amp;lt;string&amp;gt;]

  # If true, ignores the server certificate being signed by an
  # unknown CA.
  [insecure_skip_verify: &amp;lt;boolean&amp;gt; | default = false]

# Configures how to retry requests to Loki when a request
# fails.
# Default backoff schedule:
# 0.5s, 1s, 2s, 4s, 8s, 16s, 32s, 64s, 128s, 256s(4.267m)
# For a total time of 511.5s(8.5m) before logs are lost
backoff_config:
  # Initial backoff time between retries
  [min_period: &amp;lt;duration&amp;gt; | default = 500ms]

  # Maximum backoff time between retries
  [max_period: &amp;lt;duration&amp;gt; | default = 5m]

  # Maximum number of retries to do
  [max_retries: &amp;lt;int&amp;gt; | default = 10]

# Disable retries of batches that Loki responds to with a 429 status code (TooManyRequests). This reduces
# impacts on batches from other tenants, which could end up being delayed or dropped due to exponential backoff.
[drop_rate_limited_batches: &amp;lt;boolean&amp;gt; | default = false]

# Static labels to add to all logs being sent to Loki.
# Use map like {&amp;#34;foo&amp;#34;: &amp;#34;bar&amp;#34;} to add a label foo with
# value bar.
# These can also be specified from command line:
# -client.external-labels=k1=v1,k2=v2
# (or --client.external-labels depending on your OS)
# labels supplied by the command line are applied
# to all clients configured in the `clients` section.
# NOTE: values defined in the config file will replace values
# defined on the command line for a given client if the
# label keys are the same.
external_labels:
  [ &amp;lt;labelname&amp;gt;: &amp;lt;labelvalue&amp;gt; ... ]

# Maximum time to wait for a server to respond to a request
[timeout: &amp;lt;duration&amp;gt; | default = 10s]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;positions&#34;&gt;positions&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;positions&lt;/code&gt; block configures where Promtail will save a file
indicating how far it has read into a file. It is needed for when Promtail
is restarted to allow it to continue from where it left off.&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;YAML&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-yaml&#34;&gt;# Location of positions file
[filename: &amp;lt;string&amp;gt; | default = &amp;#34;/var/log/positions.yaml&amp;#34;]

# How often to update the positions file
[sync_period: &amp;lt;duration&amp;gt; | default = 10s]

# Whether to ignore &amp;amp; later overwrite positions files that are corrupted
[ignore_invalid_yaml: &amp;lt;boolean&amp;gt; | default = false]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;scrape_configs&#34;&gt;scrape_configs&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;scrape_configs&lt;/code&gt; block configures how Promtail can scrape logs from a series
of targets using a specified discovery method. Promtail uses the same &lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Prometheus scrape_configs&lt;/a&gt;. This means if you already own a Prometheus instance, the config will be very similar:&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;YAML&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-yaml&#34;&gt;# Name to identify this scrape config in the Promtail UI.
job_name: &amp;lt;string&amp;gt;

# Describes how to transform logs from targets.
[pipeline_stages: &amp;lt;pipeline_stages&amp;gt;]

# Defines decompression behavior for the given scrape target.
decompression:
  # Whether decompression should be tried or not.
  [enabled: &amp;lt;boolean&amp;gt; | default = false]

  # Initial delay to wait before starting the decompression.
  # Especially useful in scenarios where compressed files are found before the compression is finished.
  [initial_delay: &amp;lt;duration&amp;gt; | default = 0s]

  # Compression format. Supported formats are: &amp;#39;gz&amp;#39;, &amp;#39;bz2&amp;#39; and &amp;#39;z.
  [format: &amp;lt;string&amp;gt; | default = &amp;#34;&amp;#34;]

# Describes how to scrape logs from the journal.
[journal: &amp;lt;journal_config&amp;gt;]

# Describes from which encoding a scraped file should be converted.
[encoding: &amp;lt;iana_encoding_name&amp;gt;]

# Describes how to receive logs from syslog.
[syslog: &amp;lt;syslog_config&amp;gt;]

# Describes how to receive logs via the Loki push API, (e.g. from other Promtails or the Docker Logging Driver)
[loki_push_api: &amp;lt;loki_push_api_config&amp;gt;]

# Describes how to scrape logs from the Windows event logs.
[windows_events: &amp;lt;windows_events_config&amp;gt;]

# Configuration describing how to pull/receive Google Cloud Platform (GCP) logs.
[gcplog: &amp;lt;gcplog_config&amp;gt;]

# Configuration describing how to get Azure Event Hubs messages.
[azure_event_hub: &amp;lt;azure_event_hub_config&amp;gt;]

# Describes how to fetch logs from Kafka via a Consumer group.
[kafka: &amp;lt;kafka_config&amp;gt;]

# Describes how to receive logs from gelf client.
[gelf: &amp;lt;gelf_config&amp;gt;]

# Configuration describing how to pull logs from Cloudflare.
[cloudflare: &amp;lt;cloudflare&amp;gt;]

# Configuration describing how to pull logs from a Heroku LogPlex drain.
[heroku_drain: &amp;lt;heroku_drain&amp;gt;]

# Describes how to relabel targets to determine if they should
# be processed.
relabel_configs:
  - [&amp;lt;relabel_config&amp;gt;]

# Static targets to scrape.
static_configs:
  - [&amp;lt;static_config&amp;gt;]

# Files containing targets to scrape.
file_sd_configs:
  - [&amp;lt;file_sd_configs&amp;gt;]

# Describes how to discover Kubernetes services running on the
# same host.
kubernetes_sd_configs:
  - [&amp;lt;kubernetes_sd_config&amp;gt;]

# Describes how to use the Consul Catalog API to discover services registered with the
# consul cluster.
consul_sd_configs:
  [ - &amp;lt;consul_sd_config&amp;gt; ... ]

# Describes how to use the Consul Agent API to discover services registered with the consul agent
# running on the same host as Promtail.
consulagent_sd_configs:
  [ - &amp;lt;consulagent_sd_config&amp;gt; ... ]

# Describes how to use the Docker daemon API to discover containers running on
# the same host as Promtail.
docker_sd_configs:
  [ - &amp;lt;docker_sd_config&amp;gt; ... ]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;pipeline_stages&#34;&gt;pipeline_stages&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;../pipelines/&#34;&gt;Pipeline&lt;/a&gt; stages are used to transform log entries and their labels. The pipeline is executed after the discovery process finishes. The &lt;code&gt;pipeline_stages&lt;/code&gt; object consists of a list of stages which correspond to the items listed below.&lt;/p&gt;
&lt;p&gt;In most cases, you extract data from logs with &lt;code&gt;regex&lt;/code&gt; or &lt;code&gt;json&lt;/code&gt; stages. The extracted data is transformed into a temporary map object. The data can then be used by Promtail e.g. as values for &lt;code&gt;labels&lt;/code&gt; or as an &lt;code&gt;output&lt;/code&gt;. Additionally any other stage aside from &lt;code&gt;docker&lt;/code&gt; and &lt;code&gt;cri&lt;/code&gt; can access the extracted data.&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;YAML&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-yaml&#34;&gt;- [
    &amp;lt;docker&amp;gt; |
    &amp;lt;cri&amp;gt; |
    &amp;lt;regex&amp;gt; |
    &amp;lt;json&amp;gt; |
    &amp;lt;template&amp;gt; |
    &amp;lt;match&amp;gt; |
    &amp;lt;timestamp&amp;gt; |
    &amp;lt;output&amp;gt; |
    &amp;lt;labels&amp;gt; |
    &amp;lt;metrics&amp;gt; |
    &amp;lt;tenant&amp;gt; |
    &amp;lt;replace&amp;gt;
  ]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;docker&#34;&gt;docker&lt;/h4&gt;
&lt;p&gt;The Docker stage parses the contents of logs from Docker containers, and is defined by name with an empty object:&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;YAML&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-yaml&#34;&gt;docker: {}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The docker stage will match and parse log lines of this format:&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;nohighlight&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-nohighlight&#34;&gt;`{&amp;#34;log&amp;#34;:&amp;#34;level=info ts=2019-04-30T02:12:41.844179Z caller=filetargetmanager.go:180 msg=\&amp;#34;Adding target\&amp;#34;\n&amp;#34;,&amp;#34;stream&amp;#34;:&amp;#34;stderr&amp;#34;,&amp;#34;time&amp;#34;:&amp;#34;2019-04-30T02:12:41.8443515Z&amp;#34;}`&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Automatically extracting the &lt;code&gt;time&lt;/code&gt; into the logs timestamp, &lt;code&gt;stream&lt;/code&gt; into a label, and &lt;code&gt;log&lt;/code&gt; field into the output, this can be very helpful as docker is wrapping your application log in this way and this will unwrap it for further pipeline processing of just the log content.&lt;/p&gt;
&lt;p&gt;The Docker stage is just a convenience wrapper for this definition:&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;YAML&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-yaml&#34;&gt;- json:
    expressions:
      output: log
      stream: stream
      timestamp: time
- labels:
    stream:
- timestamp:
    source: timestamp
    format: RFC3339Nano
- output:
    source: output&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;cri&#34;&gt;cri&lt;/h4&gt;
&lt;p&gt;The CRI stage parses the contents of logs from CRI containers, and is defined by name with an empty object:&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;YAML&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-yaml&#34;&gt;cri: {}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The CRI  stage will match and parse log lines of this format:&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;nohighlight&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-nohighlight&#34;&gt;2019-01-01T01:00:00.000000001Z stderr P some log message&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Automatically extracting the &lt;code&gt;time&lt;/code&gt; into the logs timestamp, &lt;code&gt;stream&lt;/code&gt; into a label, and the remaining message into the output, this can be very helpful as CRI is wrapping your application log in this way and this will unwrap it for further pipeline processing of just the log content.&lt;/p&gt;
&lt;p&gt;The CRI stage is just a convenience wrapper for this definition:&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;YAML&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-yaml&#34;&gt;- regex:
    expression: &amp;#34;^(?s)(?P&amp;lt;time&amp;gt;\\S&amp;#43;?) (?P&amp;lt;stream&amp;gt;stdout|stderr) (?P&amp;lt;flags&amp;gt;\\S&amp;#43;?) (?P&amp;lt;content&amp;gt;.*)$&amp;#34;
- labels:
    stream:
- timestamp:
    source: time
    format: RFC3339Nano
- output:
    source: content&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;regex&#34;&gt;regex&lt;/h4&gt;
&lt;p&gt;The Regex stage takes a regular expression and extracts captured named groups to
be used in further stages.&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;YAML&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-yaml&#34;&gt;regex:
  # The RE2 regular expression. Each capture group must be named.
  expression: &amp;lt;string&amp;gt;

  # Name from extracted data to parse. If empty, uses the log message.
  [source: &amp;lt;string&amp;gt;]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;json&#34;&gt;json&lt;/h4&gt;
&lt;p&gt;The JSON stage parses a log line as JSON and takes
&lt;a href=&#34;http://jmespath.org/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMESPath&lt;/a&gt; expressions to extract data from the JSON to be
used in further stages.&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;YAML&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-yaml&#34;&gt;json:
  # Set of key/value pairs of JMESPath expressions. The key will be
  # the key in the extracted data while the expression will be the value,
  # evaluated as a JMESPath from the source data.
  expressions:
    [ &amp;lt;string&amp;gt;: &amp;lt;string&amp;gt; ... ]

  # Name from extracted data to parse. If empty, uses the log message.
  [source: &amp;lt;string&amp;gt;]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;template&#34;&gt;template&lt;/h4&gt;
&lt;p&gt;The template stage uses Go&amp;rsquo;s
&lt;a href=&#34;https://golang.org/pkg/text/template&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;text/template&lt;/code&gt;&lt;/a&gt; language to manipulate
values.&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;YAML&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-yaml&#34;&gt;template:
  # Name from extracted data to parse. If key in extract data doesn&amp;#39;t exist, an
  # entry for it will be created.
  source: &amp;lt;string&amp;gt;

  # Go template string to use. In additional to normal template
  # functions, ToLower, ToUpper, Replace, Trim, TrimLeft, TrimRight,
  # TrimPrefix, TrimSuffix, and TrimSpace are available as functions.
  template: &amp;lt;string&amp;gt;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Example:&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;YAML&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-yaml&#34;&gt;template:
  source: level
  template: &amp;#39;{{ if eq .Value &amp;#34;WARN&amp;#34; }}{{ Replace .Value &amp;#34;WARN&amp;#34; &amp;#34;OK&amp;#34; -1 }}{{ else }}{{ .Value }}{{ end }}&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;match&#34;&gt;match&lt;/h4&gt;
&lt;p&gt;The match stage conditionally executes a set of stages when a log entry matches
a configurable &lt;a href=&#34;../../../query/&#34;&gt;LogQL&lt;/a&gt; stream selector.&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;YAML&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-yaml&#34;&gt;match:
  # LogQL stream selector.
  selector: &amp;lt;string&amp;gt;

  # Names the pipeline. When defined, creates an additional label in
  # the pipeline_duration_seconds histogram, where the value is
  # concatenated with job_name using an underscore.
  [pipeline_name: &amp;lt;string&amp;gt;]

  # Nested set of pipeline stages only if the selector
  # matches the labels of the log entries:
  stages:
    - [
        &amp;lt;docker&amp;gt; |
        &amp;lt;cri&amp;gt; |
        &amp;lt;regex&amp;gt;
        &amp;lt;json&amp;gt; |
        &amp;lt;template&amp;gt; |
        &amp;lt;match&amp;gt; |
        &amp;lt;timestamp&amp;gt; |
        &amp;lt;output&amp;gt; |
        &amp;lt;labels&amp;gt; |
        &amp;lt;metrics&amp;gt;
      ]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;timestamp&#34;&gt;timestamp&lt;/h4&gt;
&lt;p&gt;The timestamp stage parses data from the extracted map and overrides the final
time value of the log that is stored by Loki. If this stage isn&amp;rsquo;t present,
Promtail will associate the timestamp of the log entry with the time that
log entry was read.&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;YAML&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-yaml&#34;&gt;timestamp:
  # Name from extracted data to use for the timestamp.
  source: &amp;lt;string&amp;gt;

  # Determines how to parse the time string. Can use
  # pre-defined formats by name: [ANSIC UnixDate RubyDate RFC822
  # RFC822Z RFC850 RFC1123 RFC1123Z RFC3339 RFC3339Nano Unix
  # UnixMs UnixUs UnixNs].
  format: &amp;lt;string&amp;gt;

  # IANA Timezone Database string.
  [location: &amp;lt;string&amp;gt;]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;output&#34;&gt;output&lt;/h4&gt;
&lt;p&gt;The output stage takes data from the extracted map and sets the contents of the
log entry that will be stored by Loki.&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;YAML&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-yaml&#34;&gt;output:
  # Name from extracted data to use for the log entry.
  source: &amp;lt;string&amp;gt;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;labels&#34;&gt;labels&lt;/h4&gt;
&lt;p&gt;The labels stage takes data from the extracted map and sets additional labels
on the log entry that will be sent to Loki.&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;YAML&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-yaml&#34;&gt;labels:
  # Key is REQUIRED and the name for the label that will be created.
  # Value is optional and will be the name from extracted data whose value
  # will be used for the value of the label. If empty, the value will be
  # inferred to be the same as the key.
  [ &amp;lt;string&amp;gt;: [&amp;lt;string&amp;gt;] ... ]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;metrics&#34;&gt;metrics&lt;/h4&gt;
&lt;p&gt;The metrics stage allows for defining metrics from the extracted data.&lt;/p&gt;
&lt;p&gt;Created metrics are not pushed to Loki and are instead exposed via Promtail&amp;rsquo;s
&lt;code&gt;/metrics&lt;/code&gt; endpoint. Prometheus should be configured to scrape Promtail to be
able to retrieve the metrics configured by this stage.
If Promtail&amp;rsquo;s configuration is reloaded, all metrics will be reset.&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;YAML&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-yaml&#34;&gt;# A map where the key is the name of the metric and the value is a specific
# metric type.
metrics:
  [&amp;lt;string&amp;gt;: [ &amp;lt;counter&amp;gt; | &amp;lt;gauge&amp;gt; | &amp;lt;histogram&amp;gt; ] ...]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h5 id=&#34;counter&#34;&gt;counter&lt;/h5&gt;
&lt;p&gt;Defines a counter metric whose value only goes up.&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;YAML&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-yaml&#34;&gt;# The metric type. Must be Counter.
type: Counter

# Describes the metric.
[description: &amp;lt;string&amp;gt;]

# Key from the extracted data map to use for the metric,
# defaulting to the metric&amp;#39;s name if not present.
[source: &amp;lt;string&amp;gt;]

config:
  # Filters down source data and only changes the metric
  # if the targeted value exactly matches the provided string.
  # If not present, all data will match.
  [value: &amp;lt;string&amp;gt;]

  # Must be either &amp;#34;inc&amp;#34; or &amp;#34;add&amp;#34; (case insensitive). If
  # inc is chosen, the metric value will increase by 1 for each
  # log line received that passed the filter. If add is chosen,
  # the extracted value must be convertible to a positive float
  # and its value will be added to the metric.
  action: &amp;lt;string&amp;gt;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h5 id=&#34;gauge&#34;&gt;gauge&lt;/h5&gt;
&lt;p&gt;Defines a gauge metric whose value can go up or down.&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;YAML&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-yaml&#34;&gt;# The metric type. Must be Gauge.
type: Gauge

# Describes the metric.
[description: &amp;lt;string&amp;gt;]

# Key from the extracted data map to use for the metric,
# defaulting to the metric&amp;#39;s name if not present.
[source: &amp;lt;string&amp;gt;]

config:
  # Filters down source data and only changes the metric
  # if the targeted value exactly matches the provided string.
  # If not present, all data will match.
  [value: &amp;lt;string&amp;gt;]

  # Must be either &amp;#34;set&amp;#34;, &amp;#34;inc&amp;#34;, &amp;#34;dec&amp;#34;,&amp;#34; add&amp;#34;, or &amp;#34;sub&amp;#34;. If
  # add, set, or sub is chosen, the extracted value must be
  # convertible to a positive float. inc and dec will increment
  # or decrement the metric&amp;#39;s value by 1 respectively.
  action: &amp;lt;string&amp;gt;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h5 id=&#34;histogram&#34;&gt;histogram&lt;/h5&gt;
&lt;p&gt;Defines a histogram metric whose values are bucketed.&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;YAML&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-yaml&#34;&gt;# The metric type. Must be Histogram.
type: Histogram

# Describes the metric.
[description: &amp;lt;string&amp;gt;]

# Key from the extracted data map to use for the metric,
# defaulting to the metric&amp;#39;s name if not present.
[source: &amp;lt;string&amp;gt;]

config:
  # Filters down source data and only changes the metric
  # if the targeted value exactly matches the provided string.
  # If not present, all data will match.
  [value: &amp;lt;string&amp;gt;]

  # Must be either &amp;#34;inc&amp;#34; or &amp;#34;add&amp;#34; (case insensitive). If
  # inc is chosen, the metric value will increase by 1 for each
  # log line received that passed the filter. If add is chosen,
  # the extracted value must be convertible to a positive float
  # and its value will be added to the metric.
  action: &amp;lt;string&amp;gt;

  # Holds all the numbers in which to bucket the metric.
  buckets:
    - &amp;lt;int&amp;gt;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;tenant&#34;&gt;tenant&lt;/h4&gt;
&lt;p&gt;The tenant stage is an action stage that sets the tenant ID for the log entry
picking it from a field in the extracted data map.&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;YAML&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-yaml&#34;&gt;tenant:
  # Either label, source or value config option is required, but not all (they
  # are mutually exclusive).

  # Name from labels to whose value should be set as tenant ID.
  [ label: &amp;lt;string&amp;gt; ]

  # Name from extracted data to whose value should be set as tenant ID.
  [ source: &amp;lt;string&amp;gt; ]

  # Value to use to set the tenant ID when this stage is executed. Useful
  # when this stage is included within a conditional pipeline with &amp;#34;match&amp;#34;.
  [ value: &amp;lt;string&amp;gt; ]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;replace&#34;&gt;replace&lt;/h4&gt;
&lt;p&gt;The replace stage is a parsing stage that parses a log line using
a regular expression and replaces the log line.&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;YAML&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-yaml&#34;&gt;replace:
  # The RE2 regular expression. Each named capture group will be added to extracted.
  # Each capture group and named capture group will be replaced with the value given in
  # `replace`
  expression: &amp;lt;string&amp;gt;

  # Name from extracted data to parse. If empty, uses the log message.
  # The replaced value will be assigned back to soure key
  [source: &amp;lt;string&amp;gt;]

  # Value to which the captured group will be replaced. The captured group or the named
  # captured group will be replaced with this value and the log line will be replaced with
  # new replaced values. An empty value will remove the captured group from the log line.
  [replace: &amp;lt;string&amp;gt;]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;journal&#34;&gt;journal&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;journal&lt;/code&gt; block configures reading from the systemd journal from
Promtail. Requires a build of Promtail that has journal support &lt;em&gt;enabled&lt;/em&gt;. If
using the AMD64 Docker image, this is enabled by default. On some systems a
permission is needed for the user promtail to access journal logs.
For Ubuntu (24.04) you need to add &lt;code&gt;promtail&lt;/code&gt; to the group &lt;code&gt;systemd-journal&lt;/code&gt; with &lt;code&gt;sudo usermod -a -G systemd-journal promtail&lt;/code&gt;.&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;YAML&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-yaml&#34;&gt;# When true, log messages from the journal are passed through the
# pipeline as a JSON message with all of the journal entries&amp;#39; original
# fields. When false, the log message is the text content of the MESSAGE
# field from the journal entry.
[json: &amp;lt;boolean&amp;gt; | default = false]

# The oldest relative time from process start that will be read
# and sent to Loki.
[max_age: &amp;lt;duration&amp;gt; | default = 7h]

# Label map to add to every log coming out of the journal
labels:
  [ &amp;lt;labelname&amp;gt;: &amp;lt;labelvalue&amp;gt; ... ]

# Get labels from journal, when it is not empty
relabel_configs:
- source_labels: [&amp;#39;__journal__hostname&amp;#39;]
  target_label: host
- source_labels: [&amp;#39;__journal__systemd_unit&amp;#39;]
  target_label: systemd_unit
  regex: &amp;#39;(.&amp;#43;)&amp;#39;
- source_labels: [&amp;#39;__journal__systemd_user_unit&amp;#39;]
  target_label: systemd_user_unit
  regex: &amp;#39;(.&amp;#43;)&amp;#39;
- source_labels: [&amp;#39;__journal__transport&amp;#39;]
  target_label: transport
  regex: &amp;#39;(.&amp;#43;)&amp;#39;
- source_labels: [&amp;#39;__journal_priority_keyword&amp;#39;]
  target_label: severity
  regex: &amp;#39;(.&amp;#43;)&amp;#39;

# Path to a directory to read entries from. Defaults to system
# paths (/var/log/journal and /run/log/journal) when empty.
[path: &amp;lt;string&amp;gt;]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;available-labels&#34;&gt;Available Labels&lt;/h4&gt;
&lt;p&gt;Labels are imported from systemd-journal fields. The label name is the field name set to lower case with &lt;strong&gt;_&lt;em&gt;journal&lt;/em&gt;&lt;/strong&gt; prefix. See the man page &lt;a href=&#34;https://www.freedesktop.org/software/systemd/man/latest/systemd.journal-fields.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;systemd.journal-fields&lt;/a&gt; for more information.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;journal field&lt;/th&gt;
              &lt;th&gt;label&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;_HOSTNAME&lt;/td&gt;
              &lt;td&gt;__journal__hostname&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;_SYSTEMD_UNIT&lt;/td&gt;
              &lt;td&gt;__journal__systemd_unit&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;_SYSTEMD_USER_UNIT&lt;/td&gt;
              &lt;td&gt;__journal__systemd_user_unit&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;ERRNO&lt;/td&gt;
              &lt;td&gt;__journal_errno&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;In addition to &lt;code&gt;__journal_priority&lt;/code&gt; (imported from &lt;code&gt;PRIORITY&lt;/code&gt; journal field, where the value is an integer from 0 to 7), promtail adds &lt;code&gt;__journal_priority_keyword&lt;/code&gt; label where the value is generated using the &lt;code&gt;makeJournalPriority&lt;/code&gt; mapping function.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;journal priority&lt;/th&gt;
              &lt;th&gt;keyword&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;0&lt;/td&gt;
              &lt;td&gt;emerg&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;alert&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;crit&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;error&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;warning&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;5&lt;/td&gt;
              &lt;td&gt;notice&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;6&lt;/td&gt;
              &lt;td&gt;info&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;7&lt;/td&gt;
              &lt;td&gt;debug&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;syslog&#34;&gt;syslog&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;syslog&lt;/code&gt; block configures a syslog listener allowing users to push
logs to Promtail with the syslog protocol. Currently supported both
&lt;a href=&#34;https://datatracker.ietf.org/doc/html/rfc3164&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;BSD syslog Protocol&lt;/a&gt; and
&lt;a href=&#34;https://tools.ietf.org/html/rfc5424&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;IETF Syslog (RFC5424)&lt;/a&gt; with and
without octet counting.&lt;/p&gt;
&lt;p&gt;The recommended deployment is to have a dedicated syslog forwarder like &lt;strong&gt;syslog-ng&lt;/strong&gt; or &lt;strong&gt;rsyslog&lt;/strong&gt;
in front of Promtail. The forwarder can take care of the various specifications
and transports that exist (UDP, BSD syslog, &amp;hellip;).&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://tools.ietf.org/html/rfc6587#section-3.4.1&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Octet counting&lt;/a&gt; is recommended as the
message framing method. In a stream with &lt;a href=&#34;https://tools.ietf.org/html/rfc6587#section-3.4.2&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;non-transparent framing&lt;/a&gt;,
Promtail needs to wait for the next message to catch multi-line messages,
therefore delays between messages can occur.&lt;/p&gt;
&lt;p&gt;See recommended output configurations for
&lt;a href=&#34;../scraping/#syslog-ng-output-configuration&#34;&gt;syslog-ng&lt;/a&gt; and
&lt;a href=&#34;../scraping/#rsyslog-output-configuration&#34;&gt;rsyslog&lt;/a&gt;. Both configurations enable
IETF Syslog with octet-counting.&lt;/p&gt;
&lt;p&gt;You may need to increase the open files limit for the Promtail process
if many clients are connected. (&lt;code&gt;ulimit -Sn&lt;/code&gt;)&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;YAML&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-yaml&#34;&gt;# TCP address to listen on. Has the format of &amp;#34;host:port&amp;#34;.
listen_address: &amp;lt;string&amp;gt;

# Configure the receiver to use TLS.
tls_config:
  # Certificate and key files sent by the server (required)
  cert_file: &amp;lt;string&amp;gt;
  key_file: &amp;lt;string&amp;gt;

  # CA certificate used to validate client certificate. Enables client certificate verification when specified.
  [ ca_file: &amp;lt;string&amp;gt; ]

# The idle timeout for tcp syslog connections, default is 120 seconds.
idle_timeout: &amp;lt;duration&amp;gt;

# Whether to convert syslog structured data to labels.
# A structured data entry of [example@99999 test=&amp;#34;yes&amp;#34;] would become
# the label &amp;#34;__syslog_message_sd_example_99999_test&amp;#34; with the value &amp;#34;yes&amp;#34;.
label_structured_data: &amp;lt;bool&amp;gt;

# Label map to add to every log message.
labels:
  [ &amp;lt;labelname&amp;gt;: &amp;lt;labelvalue&amp;gt; ... ]

# Whether Promtail should pass on the timestamp from the incoming syslog message.
# When false, or if no timestamp is present on the syslog message, Promtail will assign the current timestamp to the log when it was processed.
# Default is false
use_incoming_timestamp: &amp;lt;bool&amp;gt;

# Sets the maximum limit to the length of syslog messages
max_message_length: &amp;lt;int&amp;gt;

# Defines used Sylog format at the target. 
syslog_format:
 [type: &amp;lt;string&amp;gt; | default = &amp;#34;rfc5424&amp;#34;]

# Defines whether the full RFC5424 formatted syslog message should be pushed to Loki
use_rfc5424_message: &amp;lt;bool&amp;gt;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;available-labels-1&#34;&gt;Available Labels&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__syslog_connection_ip_address&lt;/code&gt;: The remote IP address.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__syslog_connection_hostname&lt;/code&gt;: The remote hostname.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__syslog_message_severity&lt;/code&gt;: The &lt;a href=&#34;https://tools.ietf.org/html/rfc5424#section-6.2.1&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;syslog severity&lt;/a&gt; parsed from the message. Symbolic name as per &lt;a href=&#34;https://github.com/influxdata/go-syslog/blob/v2.0.1/rfc5424/syslog_message.go#L184&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;syslog_message.go&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__syslog_message_facility&lt;/code&gt;: The &lt;a href=&#34;https://tools.ietf.org/html/rfc5424#section-6.2.1&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;syslog facility&lt;/a&gt; parsed from the message. Symbolic name as per &lt;a href=&#34;https://github.com/influxdata/go-syslog/blob/v2.0.1/rfc5424/syslog_message.go#L235&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;syslog_message.go&lt;/a&gt; and &lt;code&gt;syslog(3)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__syslog_message_hostname&lt;/code&gt;: The &lt;a href=&#34;https://tools.ietf.org/html/rfc5424#section-6.2.4&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;hostname&lt;/a&gt; parsed from the message.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__syslog_message_app_name&lt;/code&gt;: The &lt;a href=&#34;https://tools.ietf.org/html/rfc5424#section-6.2.5&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;app-name field&lt;/a&gt; parsed from the message.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__syslog_message_proc_id&lt;/code&gt;: The &lt;a href=&#34;https://tools.ietf.org/html/rfc5424#section-6.2.6&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;procid field&lt;/a&gt; parsed from the message.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__syslog_message_msg_id&lt;/code&gt;: The &lt;a href=&#34;https://tools.ietf.org/html/rfc5424#section-6.2.7&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;msgid field&lt;/a&gt; parsed from the message.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__syslog_message_sd_&amp;lt;sd_id&amp;gt;[_&amp;lt;iana_enterprise_id&amp;gt;]_&amp;lt;sd_name&amp;gt;&lt;/code&gt;: The &lt;a href=&#34;https://tools.ietf.org/html/rfc5424#section-6.3&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;structured-data field&lt;/a&gt; parsed from the message. The data field &lt;code&gt;[custom@99770 example=&amp;quot;1&amp;quot;]&lt;/code&gt; becomes &lt;code&gt;__syslog_message_sd_custom_99770_example&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;loki_push_api&#34;&gt;loki_push_api&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;loki_push_api&lt;/code&gt; block configures Promtail to expose a 
    &lt;a href=&#34;/docs/loki/v3.6.x/reference/loki-http-api/#ingest-logs&#34;&gt;Loki push API&lt;/a&gt; server.&lt;/p&gt;
&lt;p&gt;Each job configured with a &lt;code&gt;loki_push_api&lt;/code&gt; will expose this API and will require a separate port.&lt;/p&gt;
&lt;p&gt;Note the &lt;code&gt;server&lt;/code&gt; configuration is the same as &lt;a href=&#34;#server&#34;&gt;server&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Promtail also exposes a second endpoint on &lt;code&gt;/promtail/api/v1/raw&lt;/code&gt; which expects newline-delimited log lines.
This can be used to send NDJSON or plaintext logs.&lt;/p&gt;
&lt;p&gt;The readiness of the loki_push_api server can be checked using the endpoint &lt;code&gt;/ready&lt;/code&gt;.&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;YAML&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-yaml&#34;&gt;# The push server configuration options
[server: &amp;lt;server_config&amp;gt;]

# Label map to add to every log line sent to the push API
labels:
  [ &amp;lt;labelname&amp;gt;: &amp;lt;labelvalue&amp;gt; ... ]

# If Promtail should pass on the timestamp from the incoming log or not.
# When false Promtail will assign the current timestamp to the log when it was processed.
# Does not apply to the plaintext endpoint on `/promtail/api/v1/raw`.
[use_incoming_timestamp: &amp;lt;bool&amp;gt; | default = false]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;See &lt;a href=&#34;#example-push-config&#34;&gt;Example Push Config&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&#34;windows_events&#34;&gt;windows_events&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;windows_events&lt;/code&gt; block configures Promtail to scrape windows event logs and send them to Loki.&lt;/p&gt;
&lt;p&gt;To subscribe to a specific events stream you need to provide either an &lt;code&gt;eventlog_name&lt;/code&gt; or an &lt;code&gt;xpath_query&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Events are scraped periodically every 3 seconds by default but can be changed using &lt;code&gt;poll_interval&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;A bookmark path &lt;code&gt;bookmark_path&lt;/code&gt; is mandatory and will be used as a position file where Promtail will
keep record of the last event processed. This file persists across Promtail restarts.&lt;/p&gt;
&lt;p&gt;You can set &lt;code&gt;use_incoming_timestamp&lt;/code&gt; if you want to keep incoming event timestamps. By default Promtail will use the timestamp when
the event was read from the event log.&lt;/p&gt;
&lt;p&gt;Promtail will serialize JSON windows events, adding &lt;code&gt;channel&lt;/code&gt; and &lt;code&gt;computer&lt;/code&gt; labels from the event received.
You can add additional labels with the &lt;code&gt;labels&lt;/code&gt; property.&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;YAML&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-yaml&#34;&gt;# LCID (Locale ID) for event rendering
# - 1033 to force English language
# -  0 to use default Windows locale
[locale: &amp;lt;int&amp;gt; | default = 0]

# Name of eventlog, used only if xpath_query is empty
# Example: &amp;#34;Application&amp;#34;
[eventlog_name: &amp;lt;string&amp;gt; | default = &amp;#34;&amp;#34;]

# xpath_query can be in defined short form like &amp;#34;Event/System[EventID=999]&amp;#34;
# or you can form a XML Query. Refer to the Consuming Events article:
# https://docs.microsoft.com/en-us/windows/win32/wes/consuming-events
# XML query is the recommended form, because it is most flexible
# You can create or debug XML Query by creating Custom View in Windows Event Viewer
# and then copying resulting XML here
[xpath_query: &amp;lt;string&amp;gt; | default = &amp;#34;*&amp;#34;]

# Sets the bookmark location on the filesystem.
# The bookmark contains the current position of the target in XML.
# When restarting or rolling out Promtail, the target will continue to scrape events where it left off based on the bookmark position.
# The position is updated after each entry processed.
[bookmark_path: &amp;lt;string&amp;gt; | default = &amp;#34;&amp;#34;]

# PollInterval is the interval at which we&amp;#39;re looking if new events are available. By default the target will check every 3seconds.
[poll_interval: &amp;lt;duration&amp;gt; | default = 3s]

# Allows to exclude the xml event data.
[exclude_event_data: &amp;lt;bool&amp;gt; | default = false]

# Allows to exclude the human-friendly event message.
[exclude_event_message: &amp;lt;bool&amp;gt; | default = false]

# Allows to exclude the user data of each windows event.
[exclude_user_data: &amp;lt;bool&amp;gt; | default = false]

# Label map to add to every log line read from the windows event log
labels:
  [ &amp;lt;labelname&amp;gt;: &amp;lt;labelvalue&amp;gt; ... ]

# If Promtail should pass on the timestamp from the incoming log or not.
# When false Promtail will assign the current timestamp to the log when it was processed
[use_incoming_timestamp: &amp;lt;bool&amp;gt; | default = false]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;gcp-log&#34;&gt;GCP Log&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;gcplog&lt;/code&gt; block configures how Promtail receives GCP logs. There are two strategies, based on the configuration of &lt;code&gt;subscription_type&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Pull&lt;/strong&gt;: Using GCP Pub/Sub &lt;a href=&#34;https://cloud.google.com/pubsub/docs/pull&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;pull subscriptions&lt;/a&gt;. Promtail will consume log messages directly from the configured GCP Pub/Sub topic.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Push&lt;/strong&gt;: Using GCP Pub/Sub &lt;a href=&#34;https://cloud.google.com/pubsub/docs/push&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;push subscriptions&lt;/a&gt;. Promtail will expose an HTTP server, and GCP will deliver logs to that server.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When using the &lt;code&gt;push&lt;/code&gt; subscription type, keep in mind:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;server&lt;/code&gt; configuration is the same as &lt;a href=&#34;#server&#34;&gt;server&lt;/a&gt;, since Promtail exposes an HTTP server for target that requires so.&lt;/li&gt;
&lt;li&gt;An endpoint at &lt;code&gt;POST /gcp/api/v1/push&lt;/code&gt;, which expects requests from GCP PubSub message delivery system.&lt;/li&gt;
&lt;/ul&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;YAML&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-yaml&#34;&gt;# Type of subscription used to fetch logs from GCP. Can be either `pull` (default) or `push`.
[subscription_type: &amp;lt;string&amp;gt; | default = &amp;#34;pull&amp;#34;]

# If the subscription_type is pull,  the GCP project ID
[project_id: &amp;lt;string&amp;gt;]

# If the subscription_type is pull, GCP PubSub subscription from where Promtail will pull logs from
[subscription: &amp;lt;string&amp;gt;]

# If the subscription_type is push, the server configuration options
[server: &amp;lt;server_config&amp;gt;]

# Whether Promtail should pass on the timestamp from the incoming GCP Log message.
# When false, or if no timestamp is present in the GCP Log message, Promtail will assign the current
# timestamp to the log when it was processed.
[use_incoming_timestamp: &amp;lt;boolean&amp;gt; | default = false]

# use_full_line to force Promtail to send the full line from Cloud Logging even if `textPayload` is available.
# By default, if `textPayload` is present in the line, then it&amp;#39;s used as log line.
[use_full_line: &amp;lt;boolean&amp;gt; | default = false]

# If the subscription_type is push, configures an HTTP handler timeout. If processing the incoming GCP Logs request takes longer
# than the configured duration, that is processing and then sending the entry down the processing pipeline, the server will abort
# and respond with a 503 HTTP status code.
[push_timeout: &amp;lt;duration&amp;gt;|  default = 0 (no timeout)]

# Label map to add to every log message.
labels:
  [ &amp;lt;labelname&amp;gt;: &amp;lt;labelvalue&amp;gt; ... ]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;available-labels-2&#34;&gt;Available Labels&lt;/h4&gt;
&lt;p&gt;When Promtail receives GCP logs, various internal labels are made available for &lt;a href=&#34;#relabel_configs&#34;&gt;relabeling&lt;/a&gt;. This depends on the subscription type chosen.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Internal labels available for pull&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__gcp_logname&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_severity&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_resource_type&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_resource_labels_&amp;lt;NAME&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_labels_&amp;lt;NAME&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Internal labels available for push&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__gcp_message_id&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_subscription_name&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_attributes_&amp;lt;NAME&amp;gt;&lt;/code&gt;: All attributes read from &lt;code&gt;.message.attributes&lt;/code&gt; in the incoming push message. Each attribute key is conveniently renamed, since it might contain unsupported characters. For example, &lt;code&gt;logging.googleapis.com/timestamp&lt;/code&gt; is converted to &lt;code&gt;__gcp_attributes_logging_googleapis_com_timestamp&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_logname&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_severity&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_resource_type&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_resource_labels_&amp;lt;NAME&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_labels_&amp;lt;NAME&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;azure-event-hubs&#34;&gt;Azure Event Hubs&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;azure_event_hubs&lt;/code&gt; block configures how Promtail receives Azure Event Hubs messages. Promtail uses an Apache Kafka endpoint on Event Hubs to receive messages. For more information, see the &lt;a href=&#34;https://learn.microsoft.com/en-us/azure/event-hubs/azure-event-hubs-kafka-overview&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Azure Event Hubs documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To learn more about streaming Azure logs to an Azure Event Hubs, you can see this &lt;a href=&#34;https://learn.microsoft.com/en-us/azure/active-directory/reports-monitoring/tutorial-azure-monitor-stream-logs-to-event-hub&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;tutorial&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Note that an Apache Kafka endpoint is not available within the &lt;code&gt;Basic&lt;/code&gt; pricing plan. For more information, see the &lt;a href=&#34;https://azure.microsoft.com/en-us/pricing/details/event-hubs/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Event Hubs pricing page&lt;/a&gt;.&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;YAML&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-yaml&#34;&gt;# Event Hubs namespace host names (Required). Typically, it looks like &amp;lt;your-namespace&amp;gt;.servicebus.windows.net:9093.
fully_qualified_namespace: &amp;lt;string&amp;gt; | default = &amp;#34;&amp;#34;

# Event Hubs to consume (Required).
event_hubs:
    [ - &amp;lt;string&amp;gt; ... ]

# Event Hubs ConnectionString for authentication on Azure Cloud (Required).
connection_string: &amp;lt;string&amp;gt; | default = &amp;#34;range&amp;#34;

# The consumer group id.
[group_id: &amp;lt;string&amp;gt; | default = &amp;#34;promtail&amp;#34;]

# If Promtail should pass on the timestamp from the incoming message or not.
# When false Promtail will assign the current timestamp to the log when it was processed.
[use_incoming_timestamp: &amp;lt;bool&amp;gt; | default = false]

# If Promtail should ignore messages that don&amp;#39;t match the schema for Azure resource logs.
# Schema is described here https://learn.microsoft.com/en-us/azure/azure-monitor/essentials/resource-logs-schema.
[disallow_custom_messages: &amp;lt;bool&amp;gt; | default = false]

# Labels optionally hold labels to associate with each log line.
[labels]:
  [ &amp;lt;labelname&amp;gt;: &amp;lt;labelvalue&amp;gt; ... ]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;available-labels-3&#34;&gt;Available Labels&lt;/h4&gt;
&lt;p&gt;When Promtail receives Azure Event Hubs messages, various internal labels are made available for &lt;a href=&#34;#relabel_configs&#34;&gt;relabeling&lt;/a&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__azure_event_hubs_category&lt;/code&gt;: The log category of the message when a message is an application log.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The following list of labels is discovered using the Kafka endpoint in Event Hubs.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__meta_kafka_topic&lt;/code&gt;: The current topic for where the message has been read.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kafka_partition&lt;/code&gt;: The partition id where the message has been read.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kafka_member_id&lt;/code&gt;: The consumer group member id.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kafka_group_id&lt;/code&gt;: The consumer group id.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kafka_message_key&lt;/code&gt;: The message key. If it is empty, this value will be &amp;rsquo;none&#39;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;kafka&#34;&gt;kafka&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;kafka&lt;/code&gt; block configures Promtail to scrape logs from &lt;a href=&#34;https://kafka.apache.org/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Kafka&lt;/a&gt; using a group consumer.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;brokers&lt;/code&gt; should list available brokers to communicate with the Kafka cluster. Use multiple brokers when you want to increase availability.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;topics&lt;/code&gt; is the list of topics Promtail will subscribe to. If a topic starts with &lt;code&gt;^&lt;/code&gt; then a regular expression (&lt;a href=&#34;https://github.com/google/re2/wiki/Syntax&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;RE2&lt;/a&gt;) is used to match topics.
For instance &lt;code&gt;^promtail-.*&lt;/code&gt; will match the topic &lt;code&gt;promtail-dev&lt;/code&gt; and &lt;code&gt;promtail-prod&lt;/code&gt;. Topics are refreshed every 30 seconds, so if a new topic matches, it will be automatically added without requiring a Promtail restart.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;group_id&lt;/code&gt; defined the unique consumer group id to use for consuming logs. Each log record published to a topic is delivered to one consumer instance within each subscribing consumer group.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If all promtail instances have the same consumer group, then the records will effectively be load balanced over the promtail instances.&lt;/li&gt;
&lt;li&gt;If all promtail instances have different consumer groups, then each record will be broadcast to all promtail instances.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;code&gt;group_id&lt;/code&gt; is useful if you want to effectively send the data to multiple Loki instances and/or other sinks.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;assignor&lt;/code&gt; configuration allow you to select the rebalancing strategy to use for the consumer group.
Rebalancing is the process where a group of consumer instances (belonging to the same group) co-ordinate to own a mutually exclusive set of partitions of topics that the group is subscribed to.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;range&lt;/code&gt; the default, assigns partitions as ranges to consumer group members.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;sticky&lt;/code&gt; assigns partitions to members with an attempt to preserve earlier assignments&lt;/li&gt;
&lt;li&gt;&lt;code&gt;roundrobin&lt;/code&gt; assigns partitions to members in alternating order.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;code&gt;version&lt;/code&gt; allows to select the kafka version required to connect to the cluster.(default to &lt;code&gt;2.2.1&lt;/code&gt;)&lt;/p&gt;
&lt;p&gt;By default, timestamps are assigned by Promtail when the message is read, if you want to keep the actual message timestamp from Kafka you can set the &lt;code&gt;use_incoming_timestamp&lt;/code&gt; to true.&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;YAML&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-yaml&#34;&gt;# The list of brokers to connect to kafka (Required).
[brokers: &amp;lt;strings&amp;gt; | default = [&amp;#34;&amp;#34;]]

# The list of Kafka topics to consume (Required).
[topics: &amp;lt;strings&amp;gt; | default = [&amp;#34;&amp;#34;]]

# The Kafka consumer group id.
[group_id: &amp;lt;string&amp;gt; | default = &amp;#34;promtail&amp;#34;]

# The consumer group rebalancing strategy to use. (e.g `sticky`, `roundrobin` or `range`)
[assignor: &amp;lt;string&amp;gt; | default = &amp;#34;range&amp;#34;]

# Kafka version to connect to.
[version: &amp;lt;string&amp;gt; | default = &amp;#34;2.2.1&amp;#34;]

# Optional authentication configuration with Kafka brokers
authentication:
  # Type is authentication type. Supported values [none, ssl, sasl]
  [type: &amp;lt;string&amp;gt; | default = &amp;#34;none&amp;#34;]

  # TLS configuration for authentication and encryption. It is used only when authentication type is ssl.
  tls_config:
    [ &amp;lt;tls_config&amp;gt; ]

  # SASL configuration for authentication. It is used only when authentication type is sasl.
  sasl_config:
    # SASL mechanism. Supported values [PLAIN, SCRAM-SHA-256, SCRAM-SHA-512]
    [mechanism: &amp;lt;string&amp;gt; | default = &amp;#34;PLAIN&amp;#34;]

    # The user name to use for SASL authentication
    [user: &amp;lt;string&amp;gt;]

    # The password to use for SASL authentication
    [password: &amp;lt;secret&amp;gt;]

    # If true, SASL authentication is executed over TLS
    [use_tls: &amp;lt;boolean&amp;gt; | default = false]

    # The CA file to use to verify the server
    [ca_file: &amp;lt;string&amp;gt;]

    # Validates that the server name in the server&amp;#39;s certificate
    # is this value.
    [server_name: &amp;lt;string&amp;gt;]

    # If true, ignores the server certificate being signed by an
    # unknown CA.
    [insecure_skip_verify: &amp;lt;boolean&amp;gt; | default = false]


# Label map to add to every log line read from kafka
labels:
  [ &amp;lt;labelname&amp;gt;: &amp;lt;labelvalue&amp;gt; ... ]

# If Promtail should pass on the timestamp from the incoming log or not.
# When false Promtail will assign the current timestamp to the log when it was processed
[use_incoming_timestamp: &amp;lt;bool&amp;gt; | default = false]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;available-labels-4&#34;&gt;Available Labels&lt;/h4&gt;
&lt;p&gt;The list of labels below are discovered when consuming kafka:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__meta_kafka_topic&lt;/code&gt;: The current topic for where the message has been read.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kafka_partition&lt;/code&gt;: The partition id where the message has been read.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kafka_member_id&lt;/code&gt;: The consumer group member id.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kafka_group_id&lt;/code&gt;: The consumer group id.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kafka_message_key&lt;/code&gt;: The message key. If it is empty, this value will be &amp;rsquo;none&#39;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To keep discovered labels to your logs use the &lt;a href=&#34;#relabel_configs&#34;&gt;relabel_configs&lt;/a&gt; section.&lt;/p&gt;
&lt;h3 id=&#34;gelf&#34;&gt;GELF&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;gelf&lt;/code&gt; block configures a GELF UDP listener allowing users to push
logs to Promtail with the &lt;a href=&#34;https://docs.graylog.org/docs/gelf&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;GELF&lt;/a&gt; protocol.
Currently only UDP is supported, submit a feature request if you&amp;rsquo;re interested into TCP support.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;GELF messages can be sent uncompressed or compressed with either GZIP or ZLIB.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Each GELF message received will be encoded in JSON as the log line. For example:&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;JSON&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-json&#34;&gt;{&amp;#34;version&amp;#34;:&amp;#34;1.1&amp;#34;,&amp;#34;host&amp;#34;:&amp;#34;example.org&amp;#34;,&amp;#34;short_message&amp;#34;:&amp;#34;A short message&amp;#34;,&amp;#34;timestamp&amp;#34;:1231231123,&amp;#34;level&amp;#34;:5,&amp;#34;_some_extra&amp;#34;:&amp;#34;extra&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can leverage &lt;a href=&#34;../stages/&#34;&gt;pipeline stages&lt;/a&gt; with the GELF target,
if for example, you want to parse the log line and extract more labels or change the log line format.&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;YAML&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-yaml&#34;&gt;# UDP address to listen on. Has the format of &amp;#34;host:port&amp;#34;. Default to 0.0.0.0:12201
listen_address: &amp;lt;string&amp;gt;

# Label map to add to every log message.
labels:
  [ &amp;lt;labelname&amp;gt;: &amp;lt;labelvalue&amp;gt; ... ]

# Whether Promtail should pass on the timestamp from the incoming gelf message.
# When false, or if no timestamp is present on the gelf message, Promtail will assign the current timestamp to the log when it was processed.
# Default is false
use_incoming_timestamp: &amp;lt;bool&amp;gt;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;available-labels-5&#34;&gt;Available Labels&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__gelf_message_level&lt;/code&gt;: The GELF level as string.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gelf_message_host&lt;/code&gt;: The host sending the GELF message.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gelf_message_version&lt;/code&gt;: The GELF level message version set by the client.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gelf_message_facility&lt;/code&gt;: The GELF facility.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To keep discovered labels to your logs use the &lt;a href=&#34;#relabel_configs&#34;&gt;relabel_configs&lt;/a&gt; section.&lt;/p&gt;
&lt;h3 id=&#34;cloudflare&#34;&gt;Cloudflare&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;cloudflare&lt;/code&gt; block configures Promtail to pull logs from the Cloudflare
&lt;a href=&#34;https://developers.cloudflare.com/logs/logpull&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Logpull API&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;These logs contain data related to the connecting client, the request path through the Cloudflare network, and the response from the origin web server. This data is useful for enriching existing logs on an origin server.&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;YAML&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-yaml&#34;&gt;# The Cloudflare API token to use. (Required)
# You can create a new token by visiting your [Cloudflare profile](https://dash.cloudflare.com/profile/api-tokens).
api_token: &amp;lt;string&amp;gt;

# The Cloudflare zone id to pull logs for. (Required)
zone_id: &amp;lt;string&amp;gt;

# The time range to pull logs for.
[pull_range: &amp;lt;duration&amp;gt; | default = 1m]

# The quantity of workers that will pull logs.
[workers: &amp;lt;int&amp;gt; | default = 3]

# The type list of fields to fetch for logs.
# Supported values: default, minimal, extended, all.
[fields_type: &amp;lt;string&amp;gt; | default = default]

# The additional list of fields to supplement those provided via `fields_type`.
[additional_fields: &amp;lt;string&amp;gt; ... ]

# Label map to add to every log message.
labels:
  [ &amp;lt;labelname&amp;gt;: &amp;lt;labelvalue&amp;gt; ... ]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;By default Promtail fetches logs with the default set of fields.
Here are the different set of fields type available and the fields they include :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;default&lt;/code&gt; includes &lt;code&gt;&amp;quot;ClientIP&amp;quot;, &amp;quot;ClientRequestHost&amp;quot;, &amp;quot;ClientRequestMethod&amp;quot;, &amp;quot;ClientRequestURI&amp;quot;, &amp;quot;EdgeEndTimestamp&amp;quot;, &amp;quot;EdgeResponseBytes&amp;quot;, &amp;quot;EdgeRequestHost&amp;quot;, &amp;quot;EdgeResponseStatus&amp;quot;, &amp;quot;EdgeStartTimestamp&amp;quot;, &amp;quot;RayID&amp;quot;&lt;/code&gt;
plus any extra fields provided via &lt;code&gt;additional_fields&lt;/code&gt; argument.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;minimal&lt;/code&gt; includes all &lt;code&gt;default&lt;/code&gt; fields and adds &lt;code&gt;&amp;quot;ZoneID&amp;quot;, &amp;quot;ClientSSLProtocol&amp;quot;, &amp;quot;ClientRequestProtocol&amp;quot;, &amp;quot;ClientRequestPath&amp;quot;, &amp;quot;ClientRequestUserAgent&amp;quot;, &amp;quot;ClientRequestReferer&amp;quot;, &amp;quot;EdgeColoCode&amp;quot;, &amp;quot;ClientCountry&amp;quot;, &amp;quot;CacheCacheStatus&amp;quot;, &amp;quot;CacheResponseStatus&amp;quot;, &amp;quot;EdgeResponseContentType&amp;quot;&lt;/code&gt;
plus any extra fields provided via &lt;code&gt;additional_fields&lt;/code&gt; argument.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;extended&lt;/code&gt; includes all &lt;code&gt;minimal&lt;/code&gt;fields and adds &lt;code&gt;&amp;quot;ClientSSLCipher&amp;quot;, &amp;quot;ClientASN&amp;quot;, &amp;quot;ClientIPClass&amp;quot;, &amp;quot;CacheResponseBytes&amp;quot;, &amp;quot;EdgePathingOp&amp;quot;, &amp;quot;EdgePathingSrc&amp;quot;, &amp;quot;EdgePathingStatus&amp;quot;, &amp;quot;ParentRayID&amp;quot;, &amp;quot;WorkerCPUTime&amp;quot;, &amp;quot;WorkerStatus&amp;quot;, &amp;quot;WorkerSubrequest&amp;quot;, &amp;quot;WorkerSubrequestCount&amp;quot;, &amp;quot;OriginIP&amp;quot;, &amp;quot;OriginResponseStatus&amp;quot;, &amp;quot;OriginSSLProtocol&amp;quot;, &amp;quot;OriginResponseHTTPExpires&amp;quot;, &amp;quot;OriginResponseHTTPLastModified&amp;quot;&lt;/code&gt;
plus any extra fields provided via &lt;code&gt;additional_fields&lt;/code&gt; argument.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;all&lt;/code&gt; includes all &lt;code&gt;extended&lt;/code&gt; fields and adds &lt;code&gt;&amp;quot;BotScore&amp;quot;, &amp;quot;BotScoreSrc&amp;quot;, &amp;quot;BotTags&amp;quot;, &amp;quot;ClientRequestBytes&amp;quot;, &amp;quot;ClientSrcPort&amp;quot;, &amp;quot;ClientXRequestedWith&amp;quot;, &amp;quot;CacheTieredFill&amp;quot;, &amp;quot;EdgeResponseCompressionRatio&amp;quot;, &amp;quot;EdgeServerIP&amp;quot;, &amp;quot;FirewallMatchesSources&amp;quot;, &amp;quot;FirewallMatchesActions&amp;quot;, &amp;quot;FirewallMatchesRuleIDs&amp;quot;, &amp;quot;OriginResponseBytes&amp;quot;, &amp;quot;OriginResponseTime&amp;quot;, &amp;quot;ClientDeviceType&amp;quot;, &amp;quot;WAFFlags&amp;quot;, &amp;quot;WAFMatchedVar&amp;quot;, &amp;quot;EdgeColoID&amp;quot;, &amp;quot;RequestHeaders&amp;quot;, &amp;quot;ResponseHeaders&amp;quot;, &amp;quot;ClientRequestSource&amp;quot;&lt;/code&gt;
plus any extra fields provided via &lt;code&gt;additional_fields&lt;/code&gt; argument (this is still relevant when new fields are made available via Cloudflare API but are not yet included in &lt;code&gt;all&lt;/code&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;custom&lt;/code&gt; includes only the fields defined in &lt;code&gt;additional_fields&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To learn more about each field and its value, refer to the &lt;a href=&#34;https://developers.cloudflare.com/logs/reference/log-fields/zone/http_requests&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Cloudflare documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Promtail saves the last successfully-fetched timestamp in the position file.
If a position is found in the file for a given zone ID, Promtail will restart pulling logs
from that position. When no position is found, Promtail will start pulling logs from the current time.&lt;/p&gt;
&lt;p&gt;Promtail fetches logs using multiple workers (configurable via &lt;code&gt;workers&lt;/code&gt;) which request the last available pull range
(configured via &lt;code&gt;pull_range&lt;/code&gt;) repeatedly. Verify the last timestamp fetched by Promtail using the &lt;code&gt;cloudflare_target_last_requested_end_timestamp&lt;/code&gt; metric.
It is possible for Promtail to fall behind due to having too many log lines to process for each pull.
Adding more workers, decreasing the pull range, or decreasing the quantity of fields fetched can mitigate this performance issue.&lt;/p&gt;
&lt;p&gt;All Cloudflare logs are in JSON. Here is an example:&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;JSON&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-json&#34;&gt;{
	&amp;#34;CacheCacheStatus&amp;#34;: &amp;#34;miss&amp;#34;,
	&amp;#34;CacheResponseBytes&amp;#34;: 8377,
	&amp;#34;CacheResponseStatus&amp;#34;: 200,
	&amp;#34;CacheTieredFill&amp;#34;: false,
	&amp;#34;ClientASN&amp;#34;: 786,
	&amp;#34;ClientCountry&amp;#34;: &amp;#34;gb&amp;#34;,
	&amp;#34;ClientDeviceType&amp;#34;: &amp;#34;desktop&amp;#34;,
	&amp;#34;ClientIP&amp;#34;: &amp;#34;100.100.5.5&amp;#34;,
	&amp;#34;ClientIPClass&amp;#34;: &amp;#34;noRecord&amp;#34;,
	&amp;#34;ClientRequestBytes&amp;#34;: 2691,
	&amp;#34;ClientRequestHost&amp;#34;: &amp;#34;www.foo.com&amp;#34;,
	&amp;#34;ClientRequestMethod&amp;#34;: &amp;#34;GET&amp;#34;,
	&amp;#34;ClientRequestPath&amp;#34;: &amp;#34;/comments/foo/&amp;#34;,
	&amp;#34;ClientRequestProtocol&amp;#34;: &amp;#34;HTTP/1.0&amp;#34;,
	&amp;#34;ClientRequestReferer&amp;#34;: &amp;#34;https://www.foo.com/foo/168855/?offset=8625&amp;#34;,
	&amp;#34;ClientRequestURI&amp;#34;: &amp;#34;/foo/15248108/&amp;#34;,
	&amp;#34;ClientRequestUserAgent&amp;#34;: &amp;#34;some bot&amp;#34;,
        &amp;#34;ClientRequestSource&amp;#34;: &amp;#34;1&amp;#34;
	&amp;#34;ClientSSLCipher&amp;#34;: &amp;#34;ECDHE-ECDSA-AES128-GCM-SHA256&amp;#34;,
	&amp;#34;ClientSSLProtocol&amp;#34;: &amp;#34;TLSv1.2&amp;#34;,
	&amp;#34;ClientSrcPort&amp;#34;: 39816,
	&amp;#34;ClientXRequestedWith&amp;#34;: &amp;#34;&amp;#34;,
	&amp;#34;EdgeColoCode&amp;#34;: &amp;#34;MAN&amp;#34;,
	&amp;#34;EdgeColoID&amp;#34;: 341,
	&amp;#34;EdgeEndTimestamp&amp;#34;: 1637336610671000000,
	&amp;#34;EdgePathingOp&amp;#34;: &amp;#34;wl&amp;#34;,
	&amp;#34;EdgePathingSrc&amp;#34;: &amp;#34;macro&amp;#34;,
	&amp;#34;EdgePathingStatus&amp;#34;: &amp;#34;nr&amp;#34;,
	&amp;#34;EdgeRateLimitAction&amp;#34;: &amp;#34;&amp;#34;,
	&amp;#34;EdgeRateLimitID&amp;#34;: 0,
	&amp;#34;EdgeRequestHost&amp;#34;: &amp;#34;www.foo.com&amp;#34;,
	&amp;#34;EdgeResponseBytes&amp;#34;: 14878,
	&amp;#34;EdgeResponseCompressionRatio&amp;#34;: 1,
	&amp;#34;EdgeResponseContentType&amp;#34;: &amp;#34;text/html&amp;#34;,
	&amp;#34;EdgeResponseStatus&amp;#34;: 200,
	&amp;#34;EdgeServerIP&amp;#34;: &amp;#34;8.8.8.8&amp;#34;,
	&amp;#34;EdgeStartTimestamp&amp;#34;: 1637336610517000000,
	&amp;#34;FirewallMatchesActions&amp;#34;: [],
	&amp;#34;FirewallMatchesRuleIDs&amp;#34;: [],
	&amp;#34;FirewallMatchesSources&amp;#34;: [],
	&amp;#34;OriginIP&amp;#34;: &amp;#34;8.8.8.8&amp;#34;,
	&amp;#34;OriginResponseBytes&amp;#34;: 0,
	&amp;#34;OriginResponseHTTPExpires&amp;#34;: &amp;#34;&amp;#34;,
	&amp;#34;OriginResponseHTTPLastModified&amp;#34;: &amp;#34;&amp;#34;,
	&amp;#34;OriginResponseStatus&amp;#34;: 200,
	&amp;#34;OriginResponseTime&amp;#34;: 123000000,
	&amp;#34;OriginSSLProtocol&amp;#34;: &amp;#34;TLSv1.2&amp;#34;,
	&amp;#34;ParentRayID&amp;#34;: &amp;#34;00&amp;#34;,
	&amp;#34;RayID&amp;#34;: &amp;#34;6b0a...&amp;#34;,
        &amp;#34;RequestHeaders&amp;#34;: [],
        &amp;#34;ResponseHeaders&amp;#34;: [
          &amp;#34;x-foo&amp;#34;: &amp;#34;bar&amp;#34;
        ],
	&amp;#34;SecurityLevel&amp;#34;: &amp;#34;med&amp;#34;,
	&amp;#34;WAFAction&amp;#34;: &amp;#34;unknown&amp;#34;,
	&amp;#34;WAFFlags&amp;#34;: &amp;#34;0&amp;#34;,
	&amp;#34;WAFMatchedVar&amp;#34;: &amp;#34;&amp;#34;,
	&amp;#34;WAFProfile&amp;#34;: &amp;#34;unknown&amp;#34;,
	&amp;#34;WAFRuleID&amp;#34;: &amp;#34;&amp;#34;,
	&amp;#34;WAFRuleMessage&amp;#34;: &amp;#34;&amp;#34;,
	&amp;#34;WorkerCPUTime&amp;#34;: 0,
	&amp;#34;WorkerStatus&amp;#34;: &amp;#34;unknown&amp;#34;,
	&amp;#34;WorkerSubrequest&amp;#34;: false,
	&amp;#34;WorkerSubrequestCount&amp;#34;: 0,
	&amp;#34;ZoneID&amp;#34;: 1234
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can leverage &lt;a href=&#34;../stages/&#34;&gt;pipeline stages&lt;/a&gt; if, for example, you want to parse the JSON log line and extract more labels or change the log line format.&lt;/p&gt;
&lt;h3 id=&#34;heroku_drain&#34;&gt;heroku_drain&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;heroku_drain&lt;/code&gt; block configures Promtail to expose a &lt;a href=&#34;https://devcenter.heroku.com/articles/log-drains#https-drains&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Heroku HTTPS Drain&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Each job configured with a Heroku Drain will expose a Drain and will require a separate port.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;server&lt;/code&gt; configuration is the same as &lt;a href=&#34;#server&#34;&gt;server&lt;/a&gt;, since Promtail exposes an HTTP server for each new drain.&lt;/p&gt;
&lt;p&gt;Promtail exposes an endpoint at &lt;code&gt;/heroku/api/v1/drain&lt;/code&gt;, which expects requests from Heroku&amp;rsquo;s log delivery.&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;YAML&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-yaml&#34;&gt;# The Heroku drain server configuration options
[server: &amp;lt;server_config&amp;gt;]

# Label map to add to every log message.
labels:
  [ &amp;lt;labelname&amp;gt;: &amp;lt;labelvalue&amp;gt; ... ]

# Whether Promtail should pass on the timestamp from the incoming Heroku drain message.
# When false, or if no timestamp is present in the syslog message, Promtail will assign the current
# timestamp to the log when it was processed.
[use_incoming_timestamp: &amp;lt;boolean&amp;gt; | default = false]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;available-labels-6&#34;&gt;Available Labels&lt;/h4&gt;
&lt;p&gt;Heroku Log drains send logs in &lt;a href=&#34;https://datatracker.ietf.org/doc/html/rfc5424#section-6&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Syslog-formatted messages&lt;/a&gt; (with
some &lt;a href=&#34;https://devcenter.heroku.com/articles/log-drains#https-drain-caveats&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;minor tweaks&lt;/a&gt;; they are not RFC-compatible).&lt;/p&gt;
&lt;p&gt;The Heroku Drain target exposes for each log entry the received syslog fields with the following labels:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__heroku_drain_host&lt;/code&gt;: The &lt;a href=&#34;https://tools.ietf.org/html/rfc5424#section-6.2.4&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;HOSTNAME&lt;/a&gt; field parsed from the message.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__heroku_drain_app&lt;/code&gt;: The &lt;a href=&#34;https://tools.ietf.org/html/rfc5424#section-6.2.5&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;APP-NAME&lt;/a&gt; field parsed from the message.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__heroku_drain_proc&lt;/code&gt;: The &lt;a href=&#34;https://tools.ietf.org/html/rfc5424#section-6.2.6&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;PROCID&lt;/a&gt; field parsed from the message.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__heroku_drain_log_id&lt;/code&gt;: The &lt;a href=&#34;https://tools.ietf.org/html/rfc5424#section-6.2.7&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;MSGID&lt;/a&gt; field parsed from the message.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Additionally, the Heroku drain target will read all url query parameters from the
configured drain target url and make them available as
&lt;code&gt;__heroku_drain_param_&amp;lt;name&amp;gt;&lt;/code&gt; labels, multiple instances of the same parameter
will appear as comma separated strings&lt;/p&gt;
&lt;h3 id=&#34;relabel_configs&#34;&gt;relabel_configs&lt;/h3&gt;
&lt;p&gt;Relabeling is a powerful tool to dynamically rewrite the label set of a target
before it gets scraped. Multiple relabeling steps can be configured per scrape
configuration. They are applied to the label set of each target in order of
their appearance in the configuration file.&lt;/p&gt;
&lt;p&gt;After relabeling, the &lt;code&gt;instance&lt;/code&gt; label is set to the value of &lt;code&gt;__address__&lt;/code&gt; by
default if it was not set during relabeling. The &lt;code&gt;__scheme__&lt;/code&gt; and
&lt;code&gt;__metrics_path__&lt;/code&gt; labels are set to the scheme and metrics path of the target
respectively. The &lt;code&gt;__param_&amp;lt;name&amp;gt;&lt;/code&gt; label is set to the value of the first passed
URL parameter called &lt;code&gt;&amp;lt;name&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Additional labels prefixed with &lt;code&gt;__meta_&lt;/code&gt; may be available during the relabeling
phase. They are set by the service discovery mechanism that provided the target
and vary between mechanisms.&lt;/p&gt;
&lt;p&gt;Labels starting with &lt;code&gt;__&lt;/code&gt; will be removed from the label set after target
relabeling is completed.&lt;/p&gt;
&lt;p&gt;If a relabeling step needs to store a label value only temporarily (as the
input to a subsequent relabeling step), use the &lt;code&gt;__tmp&lt;/code&gt; label name prefix. This
prefix is guaranteed to never be used by Prometheus itself.&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;YAML&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-yaml&#34;&gt;# The source labels select values from existing labels. Their content is concatenated
# using the configured separator and matched against the configured regular expression
# for the replace, keep, and drop actions.
[ source_labels: &amp;#39;[&amp;#39; &amp;lt;labelname&amp;gt; [, ...] &amp;#39;]&amp;#39; ]

# Separator placed between concatenated source label values.
[ separator: &amp;lt;string&amp;gt; | default = ; ]

# Label to which the resulting value is written in a replace action.
# It is mandatory for replace actions. Regex capture groups are available.
[ target_label: &amp;lt;labelname&amp;gt; ]

# Regular expression against which the extracted value is matched.
[ regex: &amp;lt;regex&amp;gt; | default = (.*) ]

# Modulus to take of the hash of the source label values.
[ modulus: &amp;lt;uint64&amp;gt; ]

# Replacement value against which a regex replace is performed if the
# regular expression matches. Regex capture groups are available.
[ replacement: &amp;lt;string&amp;gt; | default = $1 ]

# Action to perform based on regex matching.
[ action: &amp;lt;relabel_action&amp;gt; | default = replace ]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;regex&amp;gt;&lt;/code&gt; is any valid
&lt;a href=&#34;https://github.com/google/re2/wiki/Syntax&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;RE2 regular expression&lt;/a&gt;. It is
required for the &lt;code&gt;replace&lt;/code&gt;, &lt;code&gt;keep&lt;/code&gt;, &lt;code&gt;drop&lt;/code&gt;, &lt;code&gt;labelmap&lt;/code&gt;,&lt;code&gt;labeldrop&lt;/code&gt; and
&lt;code&gt;labelkeep&lt;/code&gt; actions. The regex is anchored on both ends. To un-anchor the regex,
use &lt;code&gt;.*&amp;lt;regex&amp;gt;.*&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;relabel_action&amp;gt;&lt;/code&gt; determines the relabeling action to take:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;replace&lt;/code&gt;: Match &lt;code&gt;regex&lt;/code&gt; against the concatenated &lt;code&gt;source_labels&lt;/code&gt;. Then, set
&lt;code&gt;target_label&lt;/code&gt; to &lt;code&gt;replacement&lt;/code&gt;, with match group references
(&lt;code&gt;${1}&lt;/code&gt;, &lt;code&gt;${2}&lt;/code&gt;, &amp;hellip;) in &lt;code&gt;replacement&lt;/code&gt; substituted by their value. If &lt;code&gt;regex&lt;/code&gt;
does not match, no replacement takes place.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;keep&lt;/code&gt;: Drop targets for which &lt;code&gt;regex&lt;/code&gt; does not match the concatenated &lt;code&gt;source_labels&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;drop&lt;/code&gt;: Drop targets for which &lt;code&gt;regex&lt;/code&gt; matches the concatenated &lt;code&gt;source_labels&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;hashmod&lt;/code&gt;: Set &lt;code&gt;target_label&lt;/code&gt; to the &lt;code&gt;modulus&lt;/code&gt; of a hash of the concatenated &lt;code&gt;source_labels&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;labelmap&lt;/code&gt;: Match &lt;code&gt;regex&lt;/code&gt; against all label names. Then copy the values of the matching labels
to label names given by &lt;code&gt;replacement&lt;/code&gt; with match group references
(&lt;code&gt;${1}&lt;/code&gt;, &lt;code&gt;${2}&lt;/code&gt;, &amp;hellip;) in &lt;code&gt;replacement&lt;/code&gt; substituted by their value.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;labeldrop&lt;/code&gt;: Match &lt;code&gt;regex&lt;/code&gt; against all label names. Any label that matches will be
removed from the set of labels.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;labelkeep&lt;/code&gt;: Match &lt;code&gt;regex&lt;/code&gt; against all label names. Any label that does not match will be
removed from the set of labels.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Care must be taken with &lt;code&gt;labeldrop&lt;/code&gt; and &lt;code&gt;labelkeep&lt;/code&gt; to ensure that logs are
still uniquely labeled once the labels are removed.&lt;/p&gt;
&lt;h3 id=&#34;static_configs&#34;&gt;static_configs&lt;/h3&gt;
&lt;p&gt;A &lt;code&gt;static_configs&lt;/code&gt; allows specifying a list of targets and a common label set
for them.  It is the canonical way to specify static targets in a scrape
configuration.&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;YAML&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-yaml&#34;&gt;# Configures the discovery to look on the current machine.
# This is required by the prometheus service discovery code but doesn&amp;#39;t
# really apply to Promtail which can ONLY look at files on the local machine
# As such it should only have the value of localhost, OR it can be excluded
# entirely and a default value of localhost will be applied by Promtail.
targets:
  - localhost

# Defines a file to scrape and an optional set of additional labels to apply to
# all streams defined by the files from __path__.
labels:
  # The path to load logs from. Can use glob patterns (e.g., /var/log/*.log).
  __path__: &amp;lt;string&amp;gt;

  # Used to exclude files from being loaded. Can also use glob patterns.
  __path_exclude__: &amp;lt;string&amp;gt;

  # Additional labels to assign to the logs
  [ &amp;lt;labelname&amp;gt;: &amp;lt;labelvalue&amp;gt; ... ]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;file_sd_config&#34;&gt;file_sd_config&lt;/h3&gt;
&lt;p&gt;File-based service discovery provides a more generic way to configure static
targets and serves as an interface to plug in custom service discovery
mechanisms.&lt;/p&gt;
&lt;p&gt;It reads a set of files containing a list of zero or more
&lt;code&gt;&amp;lt;static_config&amp;gt;&lt;/code&gt;s. Changes to all defined files are detected via disk watches
and applied immediately. Files may be provided in YAML or JSON format. Only
changes resulting in well-formed target groups are applied.&lt;/p&gt;
&lt;p&gt;The JSON file must contain a list of static configs, using this format:&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;YAML&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-yaml&#34;&gt;[
  {
    &amp;#34;targets&amp;#34;: [ &amp;#34;localhost&amp;#34; ],
    &amp;#34;labels&amp;#34;: {
      &amp;#34;__path__&amp;#34;: &amp;#34;&amp;lt;string&amp;gt;&amp;#34;, ...
      &amp;#34;&amp;lt;labelname&amp;gt;&amp;#34;: &amp;#34;&amp;lt;labelvalue&amp;gt;&amp;#34;, ...
    }
  },
  ...
]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;As a fallback, the file contents are also re-read periodically at the specified
refresh interval.&lt;/p&gt;
&lt;p&gt;Each target has a meta label &lt;code&gt;__meta_filepath&lt;/code&gt; during the
&lt;a href=&#34;#relabel_configs&#34;&gt;relabeling phase&lt;/a&gt;. Its value is set to the
filepath from which the target was extracted.&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;YAML&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-yaml&#34;&gt;# Patterns for files from which target groups are extracted.
files:
  [ - &amp;lt;filename_pattern&amp;gt; ... ]

# Refresh interval to re-read the files.
[ refresh_interval: &amp;lt;duration&amp;gt; | default = 5m ]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Where &lt;code&gt;&amp;lt;filename_pattern&amp;gt;&lt;/code&gt; may be a path ending in &lt;code&gt;.json&lt;/code&gt;, &lt;code&gt;.yml&lt;/code&gt; or &lt;code&gt;.yaml&lt;/code&gt;.
The last path segment may contain a single &lt;code&gt;*&lt;/code&gt; that matches any character
sequence, e.g. &lt;code&gt;my/path/tg_*.json&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;kubernetes_sd_config&#34;&gt;kubernetes_sd_config&lt;/h3&gt;
&lt;p&gt;Kubernetes SD configurations allow retrieving scrape targets from
&lt;a href=&#34;https://kubernetes.io/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Kubernetes&amp;rsquo;&lt;/a&gt; REST API and always staying synchronized
with the cluster state.&lt;/p&gt;
&lt;p&gt;One of the following &lt;code&gt;role&lt;/code&gt; types can be configured to discover targets:&lt;/p&gt;
&lt;h4 id=&#34;node&#34;&gt;&lt;code&gt;node&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;node&lt;/code&gt; role discovers one target per cluster node with the address
defaulting to the Kubelet&amp;rsquo;s HTTP port.&lt;/p&gt;
&lt;p&gt;The target address defaults to the first existing address of the Kubernetes
node object in the address type order of &lt;code&gt;NodeInternalIP&lt;/code&gt;, &lt;code&gt;NodeExternalIP&lt;/code&gt;,
&lt;code&gt;NodeLegacyHostIP&lt;/code&gt;, and &lt;code&gt;NodeHostName&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Available meta labels:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_node_name&lt;/code&gt;: The name of the node object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_node_label_&amp;lt;labelname&amp;gt;&lt;/code&gt;: Each label from the node object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_node_labelpresent_&amp;lt;labelname&amp;gt;&lt;/code&gt;: &lt;code&gt;true&lt;/code&gt; for each label from the node object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_node_annotation_&amp;lt;annotationname&amp;gt;&lt;/code&gt;: Each annotation from the node object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_node_annotationpresent_&amp;lt;annotationname&amp;gt;&lt;/code&gt;: &lt;code&gt;true&lt;/code&gt; for each annotation from the node object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_node_address_&amp;lt;address_type&amp;gt;&lt;/code&gt;: The first address for each node address type, if it exists.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In addition, the &lt;code&gt;instance&lt;/code&gt; label for the node will be set to the node name
as retrieved from the API server.&lt;/p&gt;
&lt;h4 id=&#34;service&#34;&gt;&lt;code&gt;service&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;service&lt;/code&gt; role discovers a target for each service port of each service.
This is generally useful for blackbox monitoring of a service.
The address will be set to the Kubernetes DNS name of the service and respective
service port.&lt;/p&gt;
&lt;p&gt;Available meta labels:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_namespace&lt;/code&gt;: The namespace of the service object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_service_annotation_&amp;lt;annotationname&amp;gt;&lt;/code&gt;: Each annotation from the service object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_service_annotationpresent_&amp;lt;annotationname&amp;gt;&lt;/code&gt;: &amp;ldquo;true&amp;rdquo; for each annotation of the service object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_service_cluster_ip&lt;/code&gt;: The cluster IP address of the service. (Does not apply to services of type ExternalName)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_service_external_name&lt;/code&gt;: The DNS name of the service. (Applies to services of type ExternalName)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_service_label_&amp;lt;labelname&amp;gt;&lt;/code&gt;: Each label from the service object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_service_labelpresent_&amp;lt;labelname&amp;gt;&lt;/code&gt;: &lt;code&gt;true&lt;/code&gt; for each label of the service object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_service_name&lt;/code&gt;: The name of the service object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_service_port_name&lt;/code&gt;: Name of the service port for the target.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_service_port_protocol&lt;/code&gt;: Protocol of the service port for the target.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;pod&#34;&gt;&lt;code&gt;pod&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;pod&lt;/code&gt; role discovers all pods and exposes their containers as targets. For
each declared port of a container, a single target is generated. If a container
has no specified ports, a port-free target per container is created for manually
adding a port via relabeling.&lt;/p&gt;
&lt;p&gt;Available meta labels:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_namespace&lt;/code&gt;: The namespace of the pod object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_pod_name&lt;/code&gt;: The name of the pod object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_pod_ip&lt;/code&gt;: The pod IP of the pod object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_pod_label_&amp;lt;labelname&amp;gt;&lt;/code&gt;: Each label from the pod object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_pod_labelpresent_&amp;lt;labelname&amp;gt;&lt;/code&gt;: &lt;code&gt;true&lt;/code&gt;for each label from the pod object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_pod_annotation_&amp;lt;annotationname&amp;gt;&lt;/code&gt;: Each annotation from the pod object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_pod_annotationpresent_&amp;lt;annotationname&amp;gt;&lt;/code&gt;: &lt;code&gt;true&lt;/code&gt; for each annotation from the pod object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_pod_container_init&lt;/code&gt;: &lt;code&gt;true&lt;/code&gt; if the container is an &lt;a href=&#34;https://kubernetes.io/docs/concepts/workloads/pods/init-containers/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;InitContainer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_pod_container_name&lt;/code&gt;: Name of the container the target address points to.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_pod_container_port_name&lt;/code&gt;: Name of the container port.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_pod_container_port_number&lt;/code&gt;: Number of the container port.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_pod_container_port_protocol&lt;/code&gt;: Protocol of the container port.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_pod_ready&lt;/code&gt;: Set to &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt; for the pod&amp;rsquo;s ready state.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_pod_phase&lt;/code&gt;: Set to &lt;code&gt;Pending&lt;/code&gt;, &lt;code&gt;Running&lt;/code&gt;, &lt;code&gt;Succeeded&lt;/code&gt;, &lt;code&gt;Failed&lt;/code&gt; or &lt;code&gt;Unknown&lt;/code&gt;
in the &lt;a href=&#34;https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;lifecycle&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_pod_node_name&lt;/code&gt;: The name of the node the pod is scheduled onto.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_pod_host_ip&lt;/code&gt;: The current host IP of the pod object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_pod_uid&lt;/code&gt;: The UID of the pod object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_pod_controller_kind&lt;/code&gt;: Object kind of the pod controller.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_pod_controller_name&lt;/code&gt;: Name of the pod controller.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;endpoints&#34;&gt;&lt;code&gt;endpoints&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;endpoints&lt;/code&gt; role discovers targets from listed endpoints of a service. For
each endpoint address one target is discovered per port. If the endpoint is
backed by a pod, all additional container ports of the pod, not bound to an
endpoint port, are discovered as targets as well.&lt;/p&gt;
&lt;p&gt;Available meta labels:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_namespace&lt;/code&gt;: The namespace of the endpoints object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_endpoints_name&lt;/code&gt;: The names of the endpoints object.&lt;/li&gt;
&lt;li&gt;For all targets discovered directly from the endpoints list (those not additionally inferred
from underlying pods), the following labels are attached:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_endpoint_hostname&lt;/code&gt;: Hostname of the endpoint.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_endpoint_node_name&lt;/code&gt;: Name of the node hosting the endpoint.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_endpoint_ready&lt;/code&gt;: Set to &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt; for the endpoint&amp;rsquo;s ready state.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_endpoint_port_name&lt;/code&gt;: Name of the endpoint port.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_endpoint_port_protocol&lt;/code&gt;: Protocol of the endpoint port.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_endpoint_address_target_kind&lt;/code&gt;: Kind of the endpoint address target.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_endpoint_address_target_name&lt;/code&gt;: Name of the endpoint address target.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;If the endpoints belong to a service, all labels of the &lt;code&gt;role: service&lt;/code&gt; discovery are attached.&lt;/li&gt;
&lt;li&gt;For all targets backed by a pod, all labels of the &lt;code&gt;role: pod&lt;/code&gt; discovery are attached.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;ingress&#34;&gt;&lt;code&gt;ingress&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;ingress&lt;/code&gt; role discovers a target for each path of each ingress.
This is generally useful for blackbox monitoring of an ingress.
The address will be set to the host specified in the ingress spec.&lt;/p&gt;
&lt;p&gt;Available meta labels:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_namespace&lt;/code&gt;: The namespace of the ingress object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_ingress_name&lt;/code&gt;: The name of the ingress object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_ingress_label_&amp;lt;labelname&amp;gt;&lt;/code&gt;: Each label from the ingress object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_ingress_labelpresent_&amp;lt;labelname&amp;gt;&lt;/code&gt;: &lt;code&gt;true&lt;/code&gt; for each label from the ingress object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_ingress_annotation_&amp;lt;annotationname&amp;gt;&lt;/code&gt;: Each annotation from the ingress object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_ingress_annotationpresent_&amp;lt;annotationname&amp;gt;&lt;/code&gt;: &lt;code&gt;true&lt;/code&gt; for each annotation from the ingress object.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_ingress_scheme&lt;/code&gt;: Protocol scheme of ingress, &lt;code&gt;https&lt;/code&gt; if TLS
config is set. Defaults to &lt;code&gt;http&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_kubernetes_ingress_path&lt;/code&gt;: Path from ingress spec. Defaults to &lt;code&gt;/&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;See below for the configuration options for Kubernetes discovery:&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;YAML&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-yaml&#34;&gt;# The information to access the Kubernetes API.

# The API server addresses. If left empty, Prometheus is assumed to run inside
# of the cluster and will discover API servers automatically and use the pod&amp;#39;s
# CA certificate and bearer token file at /var/run/secrets/kubernetes.io/serviceaccount/.
[ api_server: &amp;lt;host&amp;gt; ]

# The Kubernetes role of entities that should be discovered.
role: &amp;lt;role&amp;gt;

# Optional authentication information used to authenticate to the API server.
# Note that `basic_auth`, `bearer_token` and `bearer_token_file` options are
# mutually exclusive.
# password and password_file are mutually exclusive.

# Optional HTTP basic authentication information.
basic_auth:
  [ username: &amp;lt;string&amp;gt; ]
  [ password: &amp;lt;secret&amp;gt; ]
  [ password_file: &amp;lt;string&amp;gt; ]

# Optional bearer token authentication information.
[ bearer_token: &amp;lt;secret&amp;gt; ]

# Optional bearer token file authentication information.
[ bearer_token_file: &amp;lt;filename&amp;gt; ]

# Optional proxy URL.
[ proxy_url: &amp;lt;string&amp;gt; ]

# TLS configuration.
tls_config:
  [ &amp;lt;tls_config&amp;gt; ]

# Optional namespace discovery. If omitted, all namespaces are used.
namespaces:
  names:
    [ - &amp;lt;string&amp;gt; ]

# Optional label and field selectors to limit the discovery process to a subset of available
#  resources. See
# https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/
# and https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ to learn
# more about the possible filters that can be used. The endpoints role supports pod,
# service, and endpoint selectors. Roles only support selectors matching the role itself;
# for example, the node role can only contain node selectors.
# Note: When making decisions about using field/label selectors, make sure that this
# is the best approach. It will prevent Promtail from reusing single list/watch
# for all scrape configurations. This might result in a bigger load on the Kubernetes API,
# because for each selector combination, there will be additional LIST/WATCH.
# On the other hand, if you want to monitor a small subset of pods of a large cluster,
# we recommend using selectors. The decision on the use of selectors or not depends
# on the particular situation.
[ selectors:
          [ - role: &amp;lt;string&amp;gt;
                  [ label: &amp;lt;string&amp;gt; ]
                  [ field: &amp;lt;string&amp;gt; ] ]]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Where &lt;code&gt;&amp;lt;role&amp;gt;&lt;/code&gt; must be &lt;code&gt;endpoints&lt;/code&gt;, &lt;code&gt;service&lt;/code&gt;, &lt;code&gt;pod&lt;/code&gt;, &lt;code&gt;node&lt;/code&gt;, or
&lt;code&gt;ingress&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;See
&lt;a href=&#34;https://github.com/prometheus/prometheus/blob/master/documentation/examples/prometheus-kubernetes.yml&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;this example Prometheus configuration file&lt;/a&gt;
for a detailed example of configuring Prometheus for Kubernetes.&lt;/p&gt;
&lt;p&gt;You may wish to check out the 3rd party
&lt;a href=&#34;https://github.com/coreos/prometheus-operator&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Prometheus Operator&lt;/a&gt;,
which automates the Prometheus setup on top of Kubernetes.&lt;/p&gt;
&lt;h3 id=&#34;consul_sd_config&#34;&gt;consul_sd_config&lt;/h3&gt;
&lt;p&gt;Consul SD configurations allow retrieving scrape targets from the &lt;a href=&#34;https://www.consul.io&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Consul Catalog API&lt;/a&gt;.
When using the Catalog API, each running Promtail will get
a list of all services known to the whole consul cluster when discovering
new targets.&lt;/p&gt;
&lt;p&gt;The following meta labels are available on targets during &lt;a href=&#34;#relabel_configs&#34;&gt;relabeling&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__meta_consul_address&lt;/code&gt;: the address of the target&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consul_dc&lt;/code&gt;: the datacenter name for the target&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consul_health&lt;/code&gt;: the health status of the service&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consul_metadata_&amp;lt;key&amp;gt;&lt;/code&gt;: each node metadata key value of the target&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consul_node&lt;/code&gt;: the node name defined for the target&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consul_service_address&lt;/code&gt;: the service address of the target&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consul_service_id&lt;/code&gt;: the service ID of the target&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consul_service_metadata_&amp;lt;key&amp;gt;&lt;/code&gt;: each service metadata key value of the target&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consul_service_port&lt;/code&gt;: the service port of the target&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consul_service&lt;/code&gt;: the name of the service the target belongs to&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consul_tagged_address_&amp;lt;key&amp;gt;&lt;/code&gt;: each node tagged address key value of the target&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consul_tags&lt;/code&gt;: the list of tags of the target joined by the tag separator&lt;/li&gt;
&lt;/ul&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;YAML&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-yaml&#34;&gt;# The information to access the Consul Catalog API. It is to be defined
# as the Consul documentation requires.
[ server: &amp;lt;host&amp;gt; | default = &amp;#34;localhost:8500&amp;#34; ]
[ token: &amp;lt;secret&amp;gt; ]
[ datacenter: &amp;lt;string&amp;gt; ]
[ scheme: &amp;lt;string&amp;gt; | default = &amp;#34;http&amp;#34; ]
[ username: &amp;lt;string&amp;gt; ]
[ password: &amp;lt;secret&amp;gt; ]

tls_config:
  [ &amp;lt;tls_config&amp;gt; ]

# A list of services for which targets are retrieved. If omitted, all services
# are scraped.
services:
  [ - &amp;lt;string&amp;gt; ]

# See https://www.consul.io/api/catalog.html#list-nodes-for-service to know more
# about the possible filters that can be used.

# An optional list of tags used to filter nodes for a given service. Services must contain all tags in the list.
tags:
  [ - &amp;lt;string&amp;gt; ]

# Node metadata key/value pairs to filter nodes for a given service.
[ node_meta:
  [ &amp;lt;string&amp;gt;: &amp;lt;string&amp;gt; ... ] ]

# The string by which Consul tags are joined into the tag label.
[ tag_separator: &amp;lt;string&amp;gt; | default = , ]

# Allow stale Consul results (see https://www.consul.io/api/features/consistency.html). Will reduce load on Consul.
[ allow_stale: &amp;lt;boolean&amp;gt; | default = true ]

# The time after which the provided names are refreshed.
# On large setup it might be a good idea to increase this value because the catalog will change all the time.
[ refresh_interval: &amp;lt;duration&amp;gt; | default = 30s ]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Note that the IP number and port used to scrape the targets is assembled as
&lt;code&gt;&amp;lt;__meta_consul_address&amp;gt;:&amp;lt;__meta_consul_service_port&amp;gt;&lt;/code&gt;. However, in some
Consul setups, the relevant address is in &lt;code&gt;__meta_consul_service_address&lt;/code&gt;.
In those cases, you can use the &lt;a href=&#34;#relabel_configs&#34;&gt;relabel&lt;/a&gt;
feature to replace the special &lt;code&gt;__address__&lt;/code&gt; label.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&#34;#relabel_configs&#34;&gt;relabeling phase&lt;/a&gt; is the preferred and more powerful
way to filter services or nodes for a service based on arbitrary labels. For
users with thousands of services it can be more efficient to use the Consul API
directly which has basic support for filtering nodes (currently by node
metadata and a single tag).&lt;/p&gt;
&lt;h3 id=&#34;consulagent_sd_config&#34;&gt;consulagent_sd_config&lt;/h3&gt;
&lt;p&gt;Consul Agent SD configurations allow retrieving scrape targets from &lt;a href=&#34;https://www.consul.io&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Consul&amp;rsquo;s&lt;/a&gt;
Agent API. When using the Agent API, each running Promtail will only get
services registered with the local agent running on the same host when discovering
new targets. This is suitable for very large Consul clusters for which using the
Catalog API would be too slow or resource intensive.&lt;/p&gt;
&lt;p&gt;The following meta labels are available on targets during &lt;a href=&#34;#relabel_configs&#34;&gt;relabeling&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__meta_consulagent_address&lt;/code&gt;: the address of the target&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consulagent_dc&lt;/code&gt;: the datacenter name for the target&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consulagent_health&lt;/code&gt;: the health status of the service&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consulagent_metadata_&amp;lt;key&amp;gt;&lt;/code&gt;: each node metadata key value of the target&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consulagent_node&lt;/code&gt;: the node name defined for the target&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consulagent_service_address&lt;/code&gt;: the service address of the target&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consulagent_service_id&lt;/code&gt;: the service ID of the target&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consulagent_service_metadata_&amp;lt;key&amp;gt;&lt;/code&gt;: each service metadata key value of the target&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consulagent_service_port&lt;/code&gt;: the service port of the target&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consulagent_service&lt;/code&gt;: the name of the service the target belongs to&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consulagent_tagged_address_&amp;lt;key&amp;gt;&lt;/code&gt;: each node tagged address key value of the target&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_consulagent_tags&lt;/code&gt;: the list of tags of the target joined by the tag separator&lt;/li&gt;
&lt;/ul&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;YAML&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-yaml&#34;&gt;# The information to access the Consul Agent API. It is to be defined
# as the Consul documentation requires.
[ server: &amp;lt;host&amp;gt; | default = &amp;#34;localhost:8500&amp;#34; ]
[ token: &amp;lt;secret&amp;gt; ]
[ datacenter: &amp;lt;string&amp;gt; ]
[ scheme: &amp;lt;string&amp;gt; | default = &amp;#34;http&amp;#34; ]
[ username: &amp;lt;string&amp;gt; ]
[ password: &amp;lt;secret&amp;gt; ]

tls_config:
  [ &amp;lt;tls_config&amp;gt; ]

# A list of services for which targets are retrieved. If omitted, all services
# are scraped.
services:
  [ - &amp;lt;string&amp;gt; ]

# See https://www.consul.io/api-docs/agent/service#filtering to know more
# about the possible filters that can be used.

# An optional list of tags used to filter nodes for a given service. Services must contain all tags in the list.
tags:
  [ - &amp;lt;string&amp;gt; ]

# Node metadata key/value pairs to filter nodes for a given service.
[ node_meta:
  [ &amp;lt;string&amp;gt;: &amp;lt;string&amp;gt; ... ] ]

# The string by which Consul tags are joined into the tag label.
[ tag_separator: &amp;lt;string&amp;gt; | default = , ]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Note that the IP address and port number used to scrape the targets is assembled as
&lt;code&gt;&amp;lt;__meta_consul_address&amp;gt;:&amp;lt;__meta_consul_service_port&amp;gt;&lt;/code&gt;. However, in some
Consul setups, the relevant address is in &lt;code&gt;__meta_consul_service_address&lt;/code&gt;.
In those cases, you can use the &lt;a href=&#34;#relabel_configs&#34;&gt;relabel&lt;/a&gt;
feature to replace the special &lt;code&gt;__address__&lt;/code&gt; label.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&#34;#relabel_configs&#34;&gt;relabeling phase&lt;/a&gt; is the preferred and more powerful
way to filter services or nodes for a service based on arbitrary labels. For
users with thousands of services it can be more efficient to use the Consul API
directly which has basic support for filtering nodes (currently by node
metadata and a single tag).&lt;/p&gt;
&lt;h3 id=&#34;docker_sd_configs&#34;&gt;docker_sd_configs&lt;/h3&gt;
&lt;p&gt;Docker service discovery allows retrieving targets from a Docker daemon.
It will only watch containers of the Docker daemon referenced with the host parameter. Docker
service discovery should run on each node in a distributed setup. The containers must run with
either the &lt;a href=&#34;https://docs.docker.com/config/containers/logging/json-file/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;json-file&lt;/a&gt;
or &lt;a href=&#34;https://docs.docker.com/config/containers/logging/journald/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;journald&lt;/a&gt; logging driver.&lt;/p&gt;
&lt;p&gt;Note that the discovery will not pick up finished containers. That means
Promtail will not scrape the remaining logs from finished containers after a restart.&lt;/p&gt;
&lt;p&gt;The Docker target correctly joins log segments if a long line was split into different frames by Docker.
To avoid hypothetically unlimited line size and out-of-memory errors in Promtail, this target applies
a default soft line size limit of 256 kiB corresponding to the default max line size in Loki.
If the buffer increases above this size, then the line will be sent to output immediately, and the rest
of the line discarded. To change this behaviour, set &lt;code&gt;limits_config.max_line_size&lt;/code&gt; to a non-zero value
to apply a hard limit.&lt;/p&gt;
&lt;p&gt;The configuration is inherited from &lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/configuration/configuration/#docker_sd_config&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Prometheus&amp;rsquo; Docker service discovery&lt;/a&gt;.&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;YAML&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-yaml&#34;&gt;# Address of the Docker daemon.  Use unix:///var/run/docker.sock for a local setup.
host: &amp;lt;string&amp;gt;

# Optional proxy URL.
[ proxy_url: &amp;lt;string&amp;gt; ]

# TLS configuration.
tls_config:
  [ &amp;lt;tls_config&amp;gt; ]

# The port to scrape metrics from, when `role` is nodes, and for discovered
# tasks and services that don&amp;#39;t have published ports.
[ port: &amp;lt;int&amp;gt; | default = 80 ]

# The host to use if the container is in host networking mode.
[ host_networking_host: &amp;lt;string&amp;gt; | default = &amp;#34;localhost&amp;#34; ]

# Sort all non-nil networks in ascending order based on network name and
# get the first network if the container has multiple networks defined, 
# thus avoiding collecting duplicate targets.
[ match_first_network: &amp;lt;bool&amp;gt; | default = true ]

# Optional filters to limit the discovery process to a subset of available
# resources.
# The available filters are listed in the Docker documentation:
# Containers: https://docs.docker.com/engine/api/v1.41/#operation/ContainerList
[ filters:
  [ - name: &amp;lt;string&amp;gt;
      values: &amp;lt;string&amp;gt;, [...] ]
]

# The time after which the containers are refreshed.
[ refresh_interval: &amp;lt;duration&amp;gt; | default = 60s ]

# Authentication information used by Promtail to authenticate itself to the
# Docker daemon.
# Note that `basic_auth` and `authorization` options are mutually exclusive.
# `password` and `password_file` are mutually exclusive.

# Optional HTTP basic authentication information.
basic_auth:
  [ username: &amp;lt;string&amp;gt; ]
  [ password: &amp;lt;secret&amp;gt; ]
  [ password_file: &amp;lt;string&amp;gt; ]

# Optional `Authorization` header configuration.
authorization:
  # Sets the authentication type.
  [ type: &amp;lt;string&amp;gt; | default: Bearer ]
  # Sets the credentials. It is mutually exclusive with
  # `credentials_file`.
  [ credentials: &amp;lt;secret&amp;gt; ]
  # Sets the credentials to the credentials read from the configured file.
  # It is mutually exclusive with `credentials`.
  [ credentials_file: &amp;lt;filename&amp;gt; ]

# Optional OAuth 2.0 configuration.
# Cannot be used at the same time as basic_auth or authorization.
oauth2:
  [ &amp;lt;oauth2&amp;gt; ]

# Configure whether HTTP requests follow HTTP 3xx redirects.
[ follow_redirects: &amp;lt;bool&amp;gt; | default = true ]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Available meta labels:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__meta_docker_container_id&lt;/code&gt;: the ID of the container&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_docker_container_name&lt;/code&gt;: the name of the container&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_docker_container_network_mode&lt;/code&gt;: the network mode of the container&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_docker_container_label_&amp;lt;labelname&amp;gt;&lt;/code&gt;: each label of the container&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_docker_container_log_stream&lt;/code&gt;: the log stream type &lt;code&gt;stdout&lt;/code&gt; or &lt;code&gt;stderr&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_docker_network_id&lt;/code&gt;: the ID of the network&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_docker_network_name&lt;/code&gt;: the name of the network&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_docker_network_ingress&lt;/code&gt;: whether the network is ingress&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_docker_network_internal&lt;/code&gt;: whether the network is internal&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_docker_network_label_&amp;lt;labelname&amp;gt;&lt;/code&gt;: each label of the network&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_docker_network_scope&lt;/code&gt;: the scope of the network&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_docker_network_ip&lt;/code&gt;: the IP of the container in this network&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_docker_port_private&lt;/code&gt;: the port on the container&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_docker_port_public&lt;/code&gt;: the external port if a port-mapping exists&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__meta_docker_port_public_ip&lt;/code&gt;: the public IP if a port-mapping exists&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These labels can be used during relabeling. For instance, the following configuration scrapes the container named &lt;code&gt;flog&lt;/code&gt; and removes the leading slash (&lt;code&gt;/&lt;/code&gt;) from the container name.&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;YAML&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-yaml&#34;&gt;scrape_configs:
  - job_name: flog_scrape
    docker_sd_configs:
      - host: unix:///var/run/docker.sock
        refresh_interval: 5s
        filters:
          - name: name
            values: [flog]
    relabel_configs:
      - source_labels: [&amp;#39;__meta_docker_container_name&amp;#39;]
        regex: &amp;#39;/(.*)&amp;#39;
        target_label: &amp;#39;container&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;limits_config&#34;&gt;limits_config&lt;/h2&gt;
&lt;p&gt;The optional &lt;code&gt;limits_config&lt;/code&gt; block configures global limits for this instance of Promtail.&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;YAML&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-yaml&#34;&gt;# When true, enforces rate limiting on this instance of Promtail.
[readline_rate_enabled: &amp;lt;bool&amp;gt; | default = false]

# The rate limit in log lines per second that this instance of Promtail may push to Loki.
[readline_rate: &amp;lt;int&amp;gt; | default = 10000]

# The cap in the quantity of burst lines that this instance of Promtail may push
# to Loki.
[readline_burst: &amp;lt;int&amp;gt; | default = 10000]

# When true, exceeding the rate limit causes this instance of Promtail to discard
# log lines, rather than sending them to Loki. When false, exceeding the rate limit
# causes this instance of Promtail to temporarily hold off on sending the log lines and retry later.
[readline_rate_drop: &amp;lt;bool&amp;gt; | default = true]

# Limits the max number of active streams.
# Limiting the number of streams is useful as a mechanism to limit memory usage by Promtail, which helps
# to avoid OOM scenarios.
# 0 means it is disabled.
[max_streams: &amp;lt;int&amp;gt; | default = 0]

# Maximum log line byte size allowed without dropping. Example: 256kb, 2M. 0 to disable.
# If disabled, targets may apply default buffer size safety limits. If a target implements
# a default limit, this will be documented under the `scrape_configs` entry.
[max_line_size: &amp;lt;int&amp;gt; | default = 0]
# Whether to truncate lines that exceed max_line_size. No effect if max_line_size is disabled
[max_line_size_truncate: &amp;lt;bool&amp;gt; | default = false]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;target_config&#34;&gt;target_config&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;target_config&lt;/code&gt; block controls the behavior of reading files from discovered
targets.&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;YAML&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-yaml&#34;&gt;# Period to resync directories being watched and files being tailed to discover
# new ones or stop watching removed ones.
sync_period: &amp;#34;10s&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;options_config&#34;&gt;options_config&lt;/h2&gt;
&lt;h2 id=&#34;tracing_config&#34;&gt;tracing_config&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;tracing&lt;/code&gt; block configures tracing for Jaeger. Currently, limited to configuration per &lt;a href=&#34;https://www.jaegertracing.io/docs/1.16/client-features/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;environment variables&lt;/a&gt; only.&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;YAML&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-yaml&#34;&gt;# When true,
[enabled: &amp;lt;boolean&amp;gt; | default = false]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;example-docker-config&#34;&gt;Example Docker Config&lt;/h2&gt;
&lt;p&gt;It&amp;rsquo;s fairly difficult to tail Docker files on a standalone machine because they are in different locations for every OS.  We recommend the &lt;a href=&#34;../../docker-driver/&#34;&gt;Docker logging driver&lt;/a&gt; for local Docker installs or Docker Compose.&lt;/p&gt;
&lt;p&gt;If running in a Kubernetes environment, you should look at the defined configs which are in &lt;a href=&#34;https://github.com/grafana/helm-charts/blob/main/charts/promtail/templates/configmap.yaml&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;helm&lt;/a&gt; and &lt;a href=&#34;https://github.com/grafana/loki/blob/main/production/ksonnet/promtail/scrape_config.libsonnet&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;jsonnet&lt;/a&gt;, these leverage the prometheus service discovery libraries (and give Promtail its name) for automatically finding and tailing pods.  The jsonnet config explains with comments what each section is for.&lt;/p&gt;
&lt;h2 id=&#34;example-static-config&#34;&gt;Example Static Config&lt;/h2&gt;
&lt;p&gt;While Promtail may have been named for the prometheus service discovery code, that same code works very well for tailing logs without containers or container environments directly on virtual machines or bare metal.&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;YAML&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-yaml&#34;&gt;server:
  http_listen_port: 9080
  grpc_listen_port: 0

positions:
  filename: /var/log/positions.yaml # This location needs to be writeable by Promtail.

clients:
  - url: http://ip_or_hostname_where_Loki_run:3100/loki/api/v1/push

scrape_configs:
 - job_name: system
   pipeline_stages:
   static_configs:
   - targets:
      - localhost
     labels:
      job: varlogs  # A `job` label is fairly standard in prometheus and useful for linking metrics and logs.
      host: yourhost # A `host` label will help identify logs from this machine vs others
      __path__: /var/log/*.log  # The path matching uses a third party library: https://github.com/bmatcuk/doublestar&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If you are rotating logs, be careful when using a wildcard pattern like &lt;code&gt;*.log&lt;/code&gt;, and make sure it doesn&amp;rsquo;t match the rotated log file. For example, if you move your logs from &lt;code&gt;server.log&lt;/code&gt; to &lt;code&gt;server.01-01-1970.log&lt;/code&gt; in the same directory every night, a static config with a wildcard search pattern like &lt;code&gt;*.log&lt;/code&gt; will pick up that new file and read it, effectively causing the entire days logs to be re-ingested.&lt;/p&gt;
&lt;h2 id=&#34;example-static-config-without-targets&#34;&gt;Example Static Config without targets&lt;/h2&gt;
&lt;p&gt;While Promtail may have been named for the prometheus service discovery code, that same code works very well for tailing logs without containers or container environments directly on virtual machines or bare metal.&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;YAML&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-yaml&#34;&gt;server:
  http_listen_port: 9080
  grpc_listen_port: 0

positions:
  filename: /var/log/positions.yaml # This location needs to be writeable by Promtail.

clients:
  - url: http://ip_or_hostname_where_Loki_run:3100/loki/api/v1/push

scrape_configs:
 - job_name: system
   pipeline_stages:
   static_configs:
   - labels:
      job: varlogs  # A `job` label is fairly standard in prometheus and useful for linking metrics and logs.
      host: yourhost # A `host` label will help identify logs from this machine vs others
      __path__: /var/log/*.log  # The path matching uses a third party library: https://github.com/bmatcuk/doublestar&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;example-journal-config&#34;&gt;Example Journal Config&lt;/h2&gt;
&lt;p&gt;This example reads entries from a systemd journal:&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;YAML&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-yaml&#34;&gt;server:
  http_listen_port: 9080
  grpc_listen_port: 0

positions:
  filename: /tmp/positions.yaml

clients:
  - url: http://ip_or_hostname_where_loki_runs:3100/loki/api/v1/push

scrape_configs:
  - job_name: journal
    journal:
      max_age: 12h
      labels:
        job: systemd-journal
    relabel_configs:
      - source_labels: [&amp;#39;__journal__systemd_unit&amp;#39;]
        target_label: &amp;#39;unit&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;example-syslog-config&#34;&gt;Example Syslog Config&lt;/h2&gt;
&lt;p&gt;This example starts Promtail as a syslog receiver and can accept syslog entries in Promtail over TCP:&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;YAML&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-yaml&#34;&gt;server:
  http_listen_port: 9080
  grpc_listen_port: 0

positions:
  filename: /tmp/positions.yaml

clients:
  - url: http://loki_addr:3100/loki/api/v1/push

scrape_configs:
  - job_name: syslog
    syslog:
      listen_address: 0.0.0.0:1514
      labels:
        job: &amp;#34;syslog&amp;#34;
    relabel_configs:
      - source_labels: [&amp;#39;__syslog_message_hostname&amp;#39;]
        target_label: &amp;#39;host&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;example-push-config&#34;&gt;Example Push Config&lt;/h2&gt;
&lt;p&gt;The example starts Promtail as a Push receiver and will accept logs from other Promtail instances or the Docker Logging Driver:&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;YAML&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-yaml&#34;&gt;server:
  http_listen_port: 9080
  grpc_listen_port: 0

positions:
  filename: /tmp/positions.yaml

clients:
  - url: http://ip_or_hostname_where_Loki_run:3100/loki/api/v1/push

scrape_configs:
- job_name: push1
  loki_push_api:
    server:
      http_listen_port: 3500
      grpc_listen_port: 3600
    labels:
      pushserver: push1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Note the &lt;code&gt;job_name&lt;/code&gt; must be provided and must be unique between multiple &lt;code&gt;loki_push_api&lt;/code&gt; scrape_configs, it will be used to register metrics.&lt;/p&gt;
&lt;p&gt;A new server instance is created so the &lt;code&gt;http_listen_port&lt;/code&gt; and &lt;code&gt;grpc_listen_port&lt;/code&gt; must be different from the Promtail &lt;code&gt;server&lt;/code&gt; config section (unless it&amp;rsquo;s disabled)&lt;/p&gt;
&lt;p&gt;You can set &lt;code&gt;grpc_listen_port&lt;/code&gt; to &lt;code&gt;0&lt;/code&gt; to have a random port assigned if not using httpgrpc.&lt;/p&gt;
]]></content><description>&lt;h1 id="configure-promtail">Configure Promtail&lt;/h1>
&lt;div data-shared="promtail-deprecation.md">
&lt;div class="admonition admonition-caution">&lt;blockquote>&lt;p class="title text-uppercase">Caution&lt;/p>&lt;p>Promtail has been deprecated and is in Long-Term Support (LTS) through February 28, 2026. Promtail will reach an End-of-Life (EOL) on March 2, 2026. You can find migration resources &lt;a href="/docs/alloy/latest/set-up/migrate/from-promtail/">here&lt;/a>.&lt;/p></description></item><item><title>Ingesting logs to Loki using OpenTelemetry Collector</title><link>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/otel/</link><pubDate>Sat, 11 Apr 2026 00:53:11 +0000</pubDate><guid>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/otel/</guid><content><![CDATA[&lt;h1 id=&#34;ingesting-logs-to-loki-using-opentelemetry-collector&#34;&gt;Ingesting logs to Loki using OpenTelemetry Collector&lt;/h1&gt;


&lt;div data-shared=&#34;otel.md&#34;&gt;
            &lt;p&gt;Loki natively supports ingesting OpenTelemetry logs over HTTP.
For ingesting logs to Loki using the OpenTelemetry Collector, you must use the &lt;a href=&#34;https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter/otlphttpexporter&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;otlphttp&lt;/code&gt; exporter&lt;/a&gt;.&lt;/p&gt;


  &lt;div
    class=&#34;youtube-lazyload responsive-video&#34;
    data-embed=&#34;snXhe1fDDa8&#34;
    data-url=&#34;https://www.youtube.com/embed/snXhe1fDDa8?autoplay=1&#34;
    data-title=&#34;YouTube Video&#34;
  &gt;
    &lt;div class=&#34;play-button&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;p&gt;For more information about using OpenTelemetry with Grafana products, refer to the &lt;a href=&#34;/docs/opentelemetry/&#34;&gt;Grafana OpenTelemetry documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;loki-configuration&#34;&gt;Loki configuration&lt;/h2&gt;
&lt;p&gt;When logs are ingested by Loki using an OpenTelemetry protocol (OTLP) ingestion endpoint, some of the data is stored as &lt;a href=&#34;../../get-started/labels/structured-metadata/&#34;&gt;Structured Metadata&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You must set &lt;code&gt;allow_structured_metadata&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt; within your Loki config file. Otherwise, Loki will reject the log payload as malformed.  Note that Structured Metadata is enabled by default in Loki 3.0 and later.&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;YAML&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-yaml&#34;&gt;limits_config:
  allow_structured_metadata: true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;configure-the-opentelemetry-collector-to-write-logs-into-loki&#34;&gt;Configure the OpenTelemetry Collector to write logs into Loki&lt;/h2&gt;
&lt;p&gt;You need to make the following changes to the &lt;a href=&#34;https://opentelemetry.io/docs/collector/configuration/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;OpenTelemetry Collector config&lt;/a&gt; to write logs to Loki on its OTLP ingestion endpoint.&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;YAML&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-yaml&#34;&gt;exporters:
  otlphttp:
    endpoint: http://&amp;lt;loki-addr&amp;gt;/otlp&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;And enable it in &lt;code&gt;service.pipelines&lt;/code&gt;:&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;YAML&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-yaml&#34;&gt;service:
  pipelines:
    logs:
      receivers: [...]
      processors: [...]
      exporters: [..., otlphttp]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If you want to authenticate using basic auth, we recommend the &lt;a href=&#34;https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/basicauthextension&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;basicauth&lt;/code&gt; extension&lt;/a&gt;.&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;YAML&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-yaml&#34;&gt;extensions:
  basicauth/otlp:
    client_auth:
      username: username
      password: password

exporters:
  otlphttp:
    auth:
      authenticator: basicauth/otlp
    endpoint: http://&amp;lt;loki-addr&amp;gt;/otlp

service:
  extensions: [basicauth/otlp]
  pipelines:
    logs:
      receivers: [...]
      processors: [...]
      exporters: [..., otlphttp]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;format-considerations&#34;&gt;Format considerations&lt;/h2&gt;
&lt;p&gt;Since the OpenTelemetry protocol differs from the Loki storage model, here is how data in the OpenTelemetry format will be mapped by default to the Loki data model during ingestion, which can be changed as explained later:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Index labels: Resource attributes map well to index labels in Loki, since both usually identify the source of the logs. The default list of Resource Attributes to store as Index labels can be configured using &lt;code&gt;default_resource_attributes_as_index_labels&lt;/code&gt; under 
    &lt;a href=&#34;/docs/loki/v3.6.x/configure/#distributor&#34;&gt;distributor&amp;rsquo;s otlp_config&lt;/a&gt;. By default, the following resource attributes will be stored as index labels, while the remaining attributes are stored as &lt;a href=&#34;../../get-started/labels/structured-metadata/&#34;&gt;Structured Metadata&lt;/a&gt; with each log entry:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;cloud.availability_zone&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;cloud.region&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;container.name&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;deployment.environment.name&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;k8s.cluster.name&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;k8s.container.name&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;k8s.cronjob.name&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;k8s.daemonset.name&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;k8s.deployment.name&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;k8s.job.name&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;k8s.namespace.name&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;k8s.pod.name&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;k8s.replicaset.name&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;k8s.statefulset.name&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;service.instance.id&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;service.name&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;service.namespace&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Because Loki has a default limit of 15 index labels, we recommend storing only select resource attributes as index labels. Although the default config selects more than 15 Resource Attributes, it should be fine since a few are mutually exclusive.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;



&lt;div class=&#34;admonition admonition-tip&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Tip&lt;/p&gt;&lt;p&gt;For Grafana Cloud Logs, see the &lt;a href=&#34;/docs/grafana-cloud/send-data/otlp/otlp-format-considerations/#logs&#34;&gt;current OpenTelemetry guidance&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Timestamp: One of &lt;code&gt;LogRecord.TimeUnixNano&lt;/code&gt; or &lt;code&gt;LogRecord.ObservedTimestamp&lt;/code&gt;, based on which one is set. If both are not set, the ingestion timestamp will be used.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;LogLine: &lt;code&gt;LogRecord.Body&lt;/code&gt; holds the body of the log. However, since Loki only supports Log body in string format, we will stringify non-string values using the &lt;a href=&#34;https://github.com/open-telemetry/opentelemetry-collector/blob/ab3d6c5b64701e690aaa340b0a63f443ff22c1f0/pdata/pcommon/value.go#L353&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;AsString method from the OTel collector lib&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;../../get-started/labels/structured-metadata/&#34;&gt;Structured Metadata&lt;/a&gt;: Anything which can’t be stored in Index labels and LogLine would be stored as Structured Metadata. Here is a non-exhaustive list of what will be stored in Structured Metadata to give a sense of what it will hold:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Resource Attributes not stored as Index labels is replicated and stored with each log entry.&lt;/li&gt;
&lt;li&gt;Everything under InstrumentationScope is replicated and stored with each log entry.&lt;/li&gt;
&lt;li&gt;Everything under LogRecord except &lt;code&gt;LogRecord.Body&lt;/code&gt;, &lt;code&gt;LogRecord.TimeUnixNano&lt;/code&gt; and sometimes &lt;code&gt;LogRecord.ObservedTimestamp&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The default list of resource attributes to store as labels can be configured using &lt;code&gt;default_resource_attributes_as_index_labels&lt;/code&gt; under the 
    &lt;a href=&#34;/docs/loki/v3.6.x/configure/#distributor&#34;&gt;distributor&amp;rsquo;s otlp_config&lt;/a&gt;. You can set global limits using 
    &lt;a href=&#34;/docs/loki/v3.6.x/configure/#limits_config&#34;&gt;limits_config.otlp_config&lt;/a&gt;. If you are using Grafana Cloud, contact support to configure this setting.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-caution&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Caution&lt;/p&gt;&lt;p&gt;Because of the potential for high 
    &lt;a href=&#34;/docs/loki/v3.6.x/get-started/labels/cardinality/&#34;&gt;cardinality&lt;/a&gt;, &lt;code&gt;k8s.pod.name&lt;/code&gt; and &lt;code&gt;service.instance.id&lt;/code&gt; are no longer recommended as default labels. But because removing these resource attributes from the default labels would be a breaking change for existing users, they have not yet been deprecated as default labels. If you are a new user of Grafana Loki, we recommend that you modify your Alloy or OpenTelemetry Collector configuration to convert &lt;code&gt;k8s.pod.name&lt;/code&gt; and &lt;code&gt;service.instance.id&lt;/code&gt; from index labels to structured metadata.
For sample configurations, refer to 
    &lt;a href=&#34;/docs/loki/v3.6.x/get-started/labels/remove-default-labels/&#34;&gt;Remove default labels&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;Things to note before ingesting OpenTelemetry logs to Loki:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Dots (.) are converted to underscores (_).&lt;/p&gt;
&lt;p&gt;Loki does not support &lt;code&gt;.&lt;/code&gt; or any other special characters other than &lt;code&gt;_&lt;/code&gt; in label names. The unsupported characters are replaced with an &lt;code&gt;_&lt;/code&gt; while converting Attributes to Index Labels or Structured Metadata.
Also, please note that while writing the queries, you must use the normalized format, i.e. use &lt;code&gt;_&lt;/code&gt; instead of special characters while querying data using OTel Attributes.&lt;/p&gt;
&lt;p&gt;For example, &lt;code&gt;service.name&lt;/code&gt; in OTLP would become &lt;code&gt;service_name&lt;/code&gt; in Loki.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Flattening of nested Attributes&lt;/p&gt;
&lt;p&gt;While converting Attributes in OTLP to Index labels or Structured Metadata, any nested attribute values are flattened out using &lt;code&gt;_&lt;/code&gt; as a separator.
It is done in a similar way as to how it is done in the 
    &lt;a href=&#34;/docs/loki/v3.6.x/query/log_queries/#json&#34;&gt;LogQL json parser&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Stringification of non-string Attribute values&lt;/p&gt;
&lt;p&gt;While converting Attribute values in OTLP to Index label values or Structured Metadata, any non-string values are converted to string using &lt;a href=&#34;https://github.com/open-telemetry/opentelemetry-collector/blob/ab3d6c5b64701e690aaa340b0a63f443ff22c1f0/pdata/pcommon/value.go#L353&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;AsString method from the OTel collector lib&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;changing-the-default-mapping-of-otlp-to-loki-format&#34;&gt;Changing the default mapping of OTLP to Loki Format&lt;/h3&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Loki supports 
    &lt;a href=&#34;/docs/loki/v3.6.x/configure/#limits_config&#34;&gt;per tenant&lt;/a&gt; OTLP config which lets you change the default mapping of OTLP to Loki format for each tenant.
It currently only supports changing the storage of Attributes. Here is what the config looks like:&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;YAML&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-yaml&#34;&gt;# OTLP log ingestion configurations
limits_config:
  otlp_config:
    # Configuration for Resource Attributes to store them as index labels or
    # Structured Metadata or drop them altogether
    resource_attributes:
      # Configure whether to ignore the default list of resource attributes set in
      # &amp;#39;distributor.otlp.default_resource_attributes_as_index_labels&amp;#39; to be
      # stored as index labels and only use the given resource attributes config
      [ignore_defaults: &amp;lt;boolean&amp;gt;]
  
      [attributes_config: &amp;lt;list of attributes_configs&amp;gt;]
  
    # Configuration for Scope Attributes to store them as Structured Metadata or
    # drop them altogether
    [scope_attributes: &amp;lt;list of attributes_configs&amp;gt;]
  
    # Configuration for Log Attributes to store them as Structured Metadata or
    # drop them altogether
    [log_attributes: &amp;lt;list of attributes_configs&amp;gt;]
  
  attributes_config:
    # Configures action to take on matching Attributes. It allows one of
    # [structured_metadata, drop] for all Attribute types. It additionally allows
    # index_label action for Resource Attributes
    [action: &amp;lt;string&amp;gt; | default = &amp;#34;&amp;#34;]
  
    # List of attributes to configure how to store them or drop them altogether
    [attributes: &amp;lt;list of strings&amp;gt;]
  
    # Regex to choose attributes to configure how to store them or drop them
    # altogether
    [regex: &amp;lt;Regexp&amp;gt;]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;If you are a Grafana Cloud customer, open a support escalation listing the Attributes you want to promote to indexed labels, and any additional context.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;/div&gt;

        
&lt;p&gt;Here are some example configs to change the default mapping of OTLP to Loki format:&lt;/p&gt;
&lt;h4 id=&#34;example-1&#34;&gt;Example 1&lt;/h4&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;YAML&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-yaml&#34;&gt;limits_config:
  otlp_config:
    resource_attributes:
      attributes_config:
        - action: index_label
          attributes:
            - service.group&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;With the example config, here is how various kinds of Attributes would be stored:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Store all 17 Resource Attributes mentioned earlier and &lt;code&gt;service.group&lt;/code&gt; Resource Attribute as index labels.&lt;/li&gt;
&lt;li&gt;Store remaining Resource Attributes as Structured Metadata.&lt;/li&gt;
&lt;li&gt;Store all the Scope and Log Attributes as Structured Metadata.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;example-2&#34;&gt;Example 2&lt;/h4&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;YAML&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-yaml&#34;&gt;limits_config:
  otlp_config:
    resource_attributes:
      ignore_defaults: true
      attributes_config:
        - action: index_label
          regex: service.group&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;With the example config, here is how various kinds of Attributes would be stored:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Only&lt;/strong&gt; store &lt;code&gt;service.group&lt;/code&gt; Resource Attribute as index labels.&lt;/li&gt;
&lt;li&gt;Store remaining Resource Attributes as Structured Metadata.&lt;/li&gt;
&lt;li&gt;Store all the Scope and Log Attributes as Structured Metadata.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;example-3&#34;&gt;Example 3&lt;/h4&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;YAML&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-yaml&#34;&gt;limits_config:
  otlp_config:
    resource_attributes:
      attributes_config:
        - action: index_label
          regex: service.group
    scope_attributes:
      - action: drop
        attributes:
          - method.name
    log_attributes:
      - action: structured_metadata
        attributes:
          - user.id
      - action: drop
        regex: .*&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;With the example config, here is how various kinds of Attributes would be stored:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Store all 17 Resource Attributes mentioned earlier and &lt;code&gt;service.group&lt;/code&gt; Resource Attribute as index labels.&lt;/li&gt;
&lt;li&gt;Store remaining Resource Attributes as Structured Metadata.&lt;/li&gt;
&lt;li&gt;Drop Scope Attribute named &lt;code&gt;method.name&lt;/code&gt; and store all other Scope Attributes as Structured Metadata.&lt;/li&gt;
&lt;li&gt;Store Log Attribute named &lt;code&gt;user.id&lt;/code&gt; as Structured Metadata and drop all other Log Attributes.&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="ingesting-logs-to-loki-using-opentelemetry-collector">Ingesting logs to Loki using OpenTelemetry Collector&lt;/h1>
&lt;div data-shared="otel.md">
&lt;p>Loki natively supports ingesting OpenTelemetry logs over HTTP.
For ingesting logs to Loki using the OpenTelemetry Collector, you must use the &lt;a href="https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter/otlphttpexporter" target="_blank" rel="noopener noreferrer">&lt;code>otlphttp&lt;/code> exporter&lt;/a>.&lt;/p></description></item><item><title>Sending logs from the cloud</title><link>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/promtail/cloud/</link><pubDate>Sat, 11 Apr 2026 00:53:11 +0000</pubDate><guid>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/promtail/cloud/</guid><content><![CDATA[&lt;h1 id=&#34;sending-logs-from-the-cloud&#34;&gt;Sending logs from the cloud&lt;/h1&gt;


&lt;div data-shared=&#34;promtail-deprecation.md&#34;&gt;
            

&lt;div class=&#34;admonition admonition-caution&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Caution&lt;/p&gt;&lt;p&gt;Promtail has been deprecated and is in Long-Term Support (LTS) through February 28, 2026. Promtail will reach an End-of-Life (EOL) on March 2, 2026. You can find migration resources &lt;a href=&#34;/docs/alloy/latest/set-up/migrate/from-promtail/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;/div&gt;

        
&lt;p&gt;Sending logs from cloud services to Grafana Loki is a little different depending on the AWS service you are using. The following tutorials walk you through configuring cloud services to send logs to Loki.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;ec2/&#34;&gt;Amazon Elastic Compute Cloud (EC2)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;ecs/&#34;&gt;Amazon Elastic Container Service (ECS)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;eks/&#34;&gt;Amazon Elastic Kubernetes Service (EKS)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;gcp/&#34;&gt;Google Cloud Platform (GCP)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="sending-logs-from-the-cloud">Sending logs from the cloud&lt;/h1>
&lt;div data-shared="promtail-deprecation.md">
&lt;div class="admonition admonition-caution">&lt;blockquote>&lt;p class="title text-uppercase">Caution&lt;/p>&lt;p>Promtail has been deprecated and is in Long-Term Support (LTS) through February 28, 2026. Promtail will reach an End-of-Life (EOL) on March 2, 2026. You can find migration resources &lt;a href="/docs/alloy/latest/set-up/migrate/from-promtail/">here&lt;/a>.&lt;/p></description></item><item><title>Configuring Promtail for service discovery</title><link>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/promtail/scraping/</link><pubDate>Sat, 11 Apr 2026 00:53:11 +0000</pubDate><guid>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/promtail/scraping/</guid><content><![CDATA[&lt;h1 id=&#34;configuring-promtail-for-service-discovery&#34;&gt;Configuring Promtail for service discovery&lt;/h1&gt;


&lt;div data-shared=&#34;promtail-deprecation.md&#34;&gt;
            

&lt;div class=&#34;admonition admonition-caution&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Caution&lt;/p&gt;&lt;p&gt;Promtail has been deprecated and is in Long-Term Support (LTS) through February 28, 2026. Promtail will reach an End-of-Life (EOL) on March 2, 2026. You can find migration resources &lt;a href=&#34;/docs/alloy/latest/set-up/migrate/from-promtail/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;/div&gt;

        
&lt;p&gt;Promtail currently supports scraping from the following sources:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#azure-event-hubs&#34;&gt;Azure event hubs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#cloudflare&#34;&gt;Cloudflare&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#file-target-discovery&#34;&gt;File target discovery&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#gcp-log-scraping&#34;&gt;GCP Logs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#gelf&#34;&gt;GELF&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#gcp-log-scraping&#34;&gt;Heroku Drain&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#http-client&#34;&gt;HTTP client&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#journal-scraping-linux-only&#34;&gt;journal scraping&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#kafka&#34;&gt;Kafka&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#relabeling&#34;&gt;Relabeling&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#syslog-receiver&#34;&gt;Syslog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#windows-event-log&#34;&gt;Windows&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;azure-event-hubs&#34;&gt;Azure Event Hubs&lt;/h2&gt;
&lt;p&gt;Promtail supports reading messages from Azure Event Hubs.
Targets can be configured using the &lt;code&gt;azure_event_hubs&lt;/code&gt; stanza:&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;YAML&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-yaml&#34;&gt;- job_name: azure_event_hubs
  azure_event_hubs:
    group_id: &amp;#34;mygroup&amp;#34;
    fully_qualified_namespace: my-namespace.servicebus.windows.net:9093
    connection_string: &amp;#34;my-connection-string&amp;#34;
    event_hubs:
      - event-hub-name
    labels:
      job: azure_event_hub
  relabel_configs:
    - action: replace
      source_labels:
        - __azure_event_hubs_category
      target_label: category&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Only &lt;code&gt;fully_qualified_namespace&lt;/code&gt;, &lt;code&gt;connection_string&lt;/code&gt; and &lt;code&gt;event_hubs&lt;/code&gt; are required fields.
Read the &lt;a href=&#34;../configuration/#azure-event-hubs&#34;&gt;configuration&lt;/a&gt; section for more information.&lt;/p&gt;
&lt;h2 id=&#34;cloudflare&#34;&gt;Cloudflare&lt;/h2&gt;
&lt;p&gt;Promtail supports pulling HTTP log messages from Cloudflare using the &lt;a href=&#34;https://developers.cloudflare.com/logs/logpull&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Logpull API&lt;/a&gt;.
The Cloudflare targets can be configured with a &lt;code&gt;cloudflare&lt;/code&gt; block:&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;YAML&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-yaml&#34;&gt;scrape_configs:
- job_name: cloudflare
  cloudflare:
    api_token: REDACTED
    zone_id: REDACTED
    fields_type: all
    labels:
      job: cloudflare-foo.com&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Only &lt;code&gt;api_token&lt;/code&gt; and &lt;code&gt;zone_id&lt;/code&gt; are required.
Refer to the &lt;a href=&#34;../configuration/#cloudflare&#34;&gt;Cloudfare&lt;/a&gt; configuration section for details.&lt;/p&gt;
&lt;h2 id=&#34;file-target-discovery&#34;&gt;File Target Discovery&lt;/h2&gt;
&lt;p&gt;Promtail discovers locations of log files and extract labels from them through
the &lt;code&gt;scrape_configs&lt;/code&gt; section in the config YAML. The syntax is identical to what
&lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Prometheus uses&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;scrape_configs&lt;/code&gt; contains one or more entries which are executed for each
discovered target (i.e., each container in each new pod running in the
instance):&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&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&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;scrape_configs:
  - job_name: local
    static_configs:
      - ...

  - job_name: kubernetes
    kubernetes_sd_config:
      - ...&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If more than one scrape config section matches your logs, you will get duplicate
entries as the logs are sent in different streams likely with slightly
different labels.&lt;/p&gt;
&lt;p&gt;There are different types of labels present in Promtail:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Labels starting with &lt;code&gt;__&lt;/code&gt; (two underscores) are internal labels. They usually
come from dynamic sources like service discovery. Once relabeling is done,
they are removed from the label set. To persist internal labels so they&amp;rsquo;re
sent to Grafana Loki, rename them so they don&amp;rsquo;t start with &lt;code&gt;__&lt;/code&gt;. See
&lt;a href=&#34;#relabeling&#34;&gt;Relabeling&lt;/a&gt; for more information.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Labels starting with &lt;code&gt;__meta_kubernetes_pod_label_*&lt;/code&gt; are &amp;ldquo;meta labels&amp;rdquo; which
are generated based on your Kubernetes pod&amp;rsquo;s labels.&lt;/p&gt;
&lt;p&gt;For example, if your Kubernetes pod has a label &lt;code&gt;name&lt;/code&gt; set to &lt;code&gt;foobar&lt;/code&gt;, then
the &lt;code&gt;scrape_configs&lt;/code&gt; section will receive an internal label
&lt;code&gt;__meta_kubernetes_pod_label_name&lt;/code&gt; with a value set to &lt;code&gt;foobar&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Other labels starting with &lt;code&gt;__meta_kubernetes_*&lt;/code&gt; exist based on other
Kubernetes metadata, such as the namespace of the pod
(&lt;code&gt;__meta_kubernetes_namespace&lt;/code&gt;) or the name of the container inside the pod
(&lt;code&gt;__meta_kubernetes_pod_container_name&lt;/code&gt;). Refer to
&lt;a href=&#34;https://prometheus.io/docs/prometheus/latest/configuration/configuration/#kubernetes_sd_config&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;the Prometheus docs&lt;/a&gt;
for the full list of Kubernetes meta labels.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The &lt;code&gt;__path__&lt;/code&gt; label is a special label which Promtail uses after discovery to
figure out where the file to read is located. Wildcards are allowed, for example &lt;code&gt;/var/log/*.log&lt;/code&gt; to get all files with a &lt;code&gt;log&lt;/code&gt; extension in the specified directory, and &lt;code&gt;/var/log/**/*.log&lt;/code&gt; for matching files and directories recursively. For a full list of options check out the docs for the &lt;a href=&#34;https://github.com/bmatcuk/doublestar&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;library&lt;/a&gt; Promtail uses.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The &lt;code&gt;__path_exclude__&lt;/code&gt; label is another special label Promtail uses after
discovery, to exclude a subset of the files discovered using &lt;code&gt;__path__&lt;/code&gt; from
being read in the current scrape_config block. It uses the same
&lt;a href=&#34;https://github.com/bmatcuk/doublestar&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;library&lt;/a&gt; to enable usage of
wildcards and glob patterns.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The label &lt;code&gt;filename&lt;/code&gt; is added for every file found in &lt;code&gt;__path__&lt;/code&gt; to ensure the
uniqueness of the streams. It is set to the absolute path of the file the line
was read from.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;example-of-file-discovery&#34;&gt;Example of File Discovery&lt;/h3&gt;
&lt;p&gt;To scrape a set of log files defined manually on a machine, one can use &lt;code&gt;static_configs&lt;/code&gt; or &lt;code&gt;file_sd_configs&lt;/code&gt;. Using static_configs, one must reload Promtail to apply modifications. Using &lt;code&gt;file_sd_configs&lt;/code&gt; that reload is not needed. Promtail reloads discovery files when they are updated.&lt;/p&gt;
&lt;p&gt;The below excerpt of Promtail&amp;rsquo;s configuration show a file_sd_configs that is used to scrape &lt;code&gt;apt&lt;/code&gt; and &lt;code&gt;dpkg&lt;/code&gt;&amp;rsquo;s logs.&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;YAML&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-yaml&#34;&gt;scrape_configs:
 - job_name: apt-dpkg
    file_sd_configs:
      - files:
        - /etc/promtail/dpkg-apt.yaml
    refresh_interval: 5m&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The targets to be scraped by Promtail are defined in &lt;code&gt;/etc/promtail/dpkg-apt.yaml&lt;/code&gt;. In fact, Promtail read the target to scrape in the list of file provided under &lt;code&gt;files&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Below is the content of &lt;code&gt;/etc/promtail/dpkg-apt.yaml&lt;/code&gt;.&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;YAML&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-yaml&#34;&gt;- targets: [&amp;#34;localhost&amp;#34;]
  labels:
    job: dpkg
    __path__: /var/log/dpkg.log
- targets: [&amp;#34;localhost&amp;#34;]
  labels:
    job: apt
    __path__: /var/log/apt/*.log&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;As one can realize, &lt;code&gt;/etc/promtail/dpkg-apt.yaml&lt;/code&gt; contains the list of targets we would have defined under &lt;a href=&#34;/docs/loki/latest/send-data/promtail/configuration/#static_configs&#34;&gt;static_configs&lt;/a&gt;.&lt;br /&gt;
It defines two targets. The first one with label job set to &lt;code&gt;dpkg&lt;/code&gt; and &lt;code&gt;__path__&lt;/code&gt; specifying dpkg&amp;rsquo;s log file: &lt;code&gt;/var/log/dpkg.log&lt;/code&gt;. The second has two labels: the label &lt;code&gt;job&lt;/code&gt; and again &lt;code&gt;__path__&lt;/code&gt; specifying the path to APT&amp;rsquo;s log files. This &lt;code&gt;__path__&lt;/code&gt; contains a glob. Every log file matching that regular expression will be scrapped under that target.&lt;br /&gt;
To summarize, the above &lt;code&gt;/etc/promtail/dpkg-apt.yaml&lt;/code&gt; showcase YAML format of file_sd_config discovery file. The JSON format can be seen &lt;a href=&#34;/docs/loki/latest/send-data/promtail/configuration/#file_sd_config&#34;&gt;here&lt;/a&gt;,&lt;/p&gt;
&lt;h3 id=&#34;kubernetes-discovery&#34;&gt;Kubernetes Discovery&lt;/h3&gt;
&lt;p&gt;While Promtail can use the Kubernetes API to discover pods as
targets, it can only read log files from pods that are running on the same node
as the one Promtail is running on. Promtail looks for a &lt;code&gt;__host__&lt;/code&gt; label on
each target and validates that it is set to the same hostname as Promtail&amp;rsquo;s
(using either &lt;code&gt;$HOSTNAME&lt;/code&gt; or the hostname reported by the kernel if the
environment variable is not set).&lt;/p&gt;
&lt;p&gt;This means that any time Kubernetes service discovery is used, there must be a
&lt;code&gt;relabel_config&lt;/code&gt; that creates the intermediate label &lt;code&gt;__host__&lt;/code&gt; from
&lt;code&gt;__meta_kubernetes_pod_node_name&lt;/code&gt;:&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;YAML&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-yaml&#34;&gt;relabel_configs:
  - source_labels: [&amp;#39;__meta_kubernetes_pod_node_name&amp;#39;]
    target_label: &amp;#39;__host__&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;See &lt;a href=&#34;#relabeling&#34;&gt;Relabeling&lt;/a&gt; for more information. For more information on how to configure the service discovery see the &lt;a href=&#34;../configuration/#kubernetes_sd_config&#34;&gt;Kubernetes Service Discovery configuration&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;gcp-log-scraping&#34;&gt;GCP Log scraping&lt;/h2&gt;
&lt;p&gt;Promtail supports scraping cloud resource logs such as GCS bucket logs, load balancer logs, and Kubernetes cluster logs from GCP.
Configuration is specified in the &lt;code&gt;gcplog&lt;/code&gt; section, within &lt;code&gt;scrape_config&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;There are two kind of scraping strategies: &lt;code&gt;pull&lt;/code&gt; and &lt;code&gt;push&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;pull&#34;&gt;Pull&lt;/h3&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;YAML&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-yaml&#34;&gt;  - job_name: gcplog
    gcplog:
      subscription_type: &amp;#34;pull&amp;#34; # If the `subscription_type` field is empty, defaults to `pull`
      project_id: &amp;#34;my-gcp-project&amp;#34;
      subscription: &amp;#34;my-pubsub-subscription&amp;#34;
      use_incoming_timestamp: false # default rewrite timestamps.
      use_full_line: false # default use textPayload as log line.
      labels:
        job: &amp;#34;gcplog&amp;#34;
    relabel_configs:
      - source_labels: [&amp;#39;__gcp_resource_type&amp;#39;]
        target_label: &amp;#39;resource_type&amp;#39;
      - source_labels: [&amp;#39;__gcp_resource_labels_project_id&amp;#39;]
        target_label: &amp;#39;project&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Here &lt;code&gt;project_id&lt;/code&gt; and &lt;code&gt;subscription&lt;/code&gt; are the only required fields.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;project_id&lt;/code&gt; is the GCP project id.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;subscription&lt;/code&gt; is the GCP pubsub subscription where Promtail can consume log entries from.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Before using &lt;code&gt;gcplog&lt;/code&gt; target, GCP should be &lt;a href=&#34;../cloud/gcp/&#34;&gt;configured&lt;/a&gt; with pubsub subscription to receive logs from.&lt;/p&gt;
&lt;p&gt;It also supports &lt;code&gt;relabeling&lt;/code&gt; and &lt;code&gt;pipeline&lt;/code&gt; stages just like other targets.&lt;/p&gt;
&lt;p&gt;When Promtail receives GCP logs, various internal labels are made available for &lt;a href=&#34;#relabeling&#34;&gt;relabeling&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__gcp_logname&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_severity&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_resource_type&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_resource_labels_&amp;lt;NAME&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_labels_&amp;lt;NAME&amp;gt;&lt;/code&gt;
In the example above, the &lt;code&gt;project_id&lt;/code&gt; label from a GCP resource was transformed into a label called &lt;code&gt;project&lt;/code&gt; through &lt;code&gt;relabel_configs&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;push&#34;&gt;Push&lt;/h3&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;YAML&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-yaml&#34;&gt;  - job_name: gcplog
    gcplog:
      subscription_type: &amp;#34;push&amp;#34;
      use_incoming_timestamp: false
      labels:
        job: &amp;#34;gcplog-push&amp;#34;
      server:
        http_listen_address: 0.0.0.0
        http_listen_port: 8080
    relabel_configs:
      - source_labels: [&amp;#39;__gcp_message_id&amp;#39;]
        target_label: &amp;#39;message_id&amp;#39;
      - source_labels: [&amp;#39;__gcp_attributes_logging_googleapis_com_timestamp&amp;#39;]
        target_label: &amp;#39;incoming_ts&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;When configuring the GCP Log push target, Promtail will start an HTTP server listening on port &lt;code&gt;8080&lt;/code&gt;, as configured in the &lt;code&gt;server&lt;/code&gt;
section. This server exposes the single endpoint &lt;code&gt;POST /gcp/api/v1/push&lt;/code&gt;, responsible for receiving logs from GCP.&lt;/p&gt;
&lt;p&gt;For Google&amp;rsquo;s PubSub to be able to send logs, &lt;strong&gt;Promtail server must be publicly accessible, and support HTTPS&lt;/strong&gt;. For that, Promtail can be deployed
as part of a larger orchestration service like Kubernetes, which can handle HTTPS traffic through an ingress, or it can be hosted behind
a proxy/gateway, offloading the HTTPS to that component and routing the request to Promtail. Once that&amp;rsquo;s solved, GCP can be &lt;a href=&#34;../cloud/gcp/&#34;&gt;configured&lt;/a&gt;
to send logs to Promtail.&lt;/p&gt;
&lt;p&gt;It also supports &lt;code&gt;relabeling&lt;/code&gt; and &lt;code&gt;pipeline&lt;/code&gt; stages.&lt;/p&gt;
&lt;p&gt;When Promtail receives GCP logs, various internal labels are made available for &lt;a href=&#34;#relabeling&#34;&gt;relabeling&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__gcp_message_id&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_subscription_name&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_attributes_&amp;lt;NAME&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_logname&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_severity&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_resource_type&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_resource_labels_&amp;lt;NAME&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__gcp_labels_&amp;lt;NAME&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the example above, the &lt;code&gt;__gcp_message_id&lt;/code&gt; and the &lt;code&gt;__gcp_attributes_logging_googleapis_com_timestamp&lt;/code&gt; labels are
transformed to &lt;code&gt;message_id&lt;/code&gt; and &lt;code&gt;incoming_ts&lt;/code&gt; through &lt;code&gt;relabel_configs&lt;/code&gt;. All other internal labels, for example some other attribute,
will be dropped by the target if not transformed.&lt;/p&gt;
&lt;h2 id=&#34;gelf&#34;&gt;GELF&lt;/h2&gt;
&lt;p&gt;Promtail supports listening message using the &lt;a href=&#34;https://docs.graylog.org/docs/gelf&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;GELF&lt;/a&gt; UDP protocol.
The GELF targets can be configured using the &lt;code&gt;gelf&lt;/code&gt; stanza:&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;YAML&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-yaml&#34;&gt;scrape_configs:
- job_name: gelf
  gelf:
    listen_address: &amp;#34;0.0.0.0:12201&amp;#34;
    use_incoming_timestamp: true
    labels:
      job: gelf
  relabel_configs:
      - action: replace
        source_labels:
          - __gelf_message_host
        target_label: host
      - action: replace
        source_labels:
          - __gelf_message_level
        target_label: level
      - action: replace
        source_labels:
          - __gelf_message_facility
        target_label: facility&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;heroku-drain&#34;&gt;Heroku Drain&lt;/h2&gt;
&lt;p&gt;Promtail supports receiving logs from a Heroku application by using a &lt;a href=&#34;https://devcenter.heroku.com/articles/log-drains#https-drains&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Heroku HTTPS Drain&lt;/a&gt;.
Configuration is specified in a&lt;code&gt;heroku_drain&lt;/code&gt; block within the Promtail &lt;code&gt;scrape_config&lt;/code&gt; configuration.&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;YAML&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-yaml&#34;&gt;- job_name: heroku_drain
    heroku_drain:
      server:
        http_listen_address: 0.0.0.0
        http_listen_port: 8080
      labels:
        job: heroku_drain_docs
      use_incoming_timestamp: true
    relabel_configs:
      - source_labels: [&amp;#39;__heroku_drain_host&amp;#39;]
        target_label: &amp;#39;host&amp;#39;
      - source_labels: [&amp;#39;__heroku_drain_app&amp;#39;]
        target_label: &amp;#39;source&amp;#39;
      - source_labels: [&amp;#39;__heroku_drain_proc&amp;#39;]
        target_label: &amp;#39;proc&amp;#39;
      - source_labels: [&amp;#39;__heroku_drain_log_id&amp;#39;]
        target_label: &amp;#39;log_id&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Within the &lt;code&gt;scrape_configs&lt;/code&gt; configuration for a Heroku Drain target, the &lt;code&gt;job_name&lt;/code&gt; must be a Prometheus-compatible &lt;a href=&#34;https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;metric name&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&#34;../configuration/#server&#34;&gt;server&lt;/a&gt; section configures the HTTP server created for receiving logs.
&lt;code&gt;labels&lt;/code&gt; defines a static set of label values added to each received log entry. &lt;code&gt;use_incoming_timestamp&lt;/code&gt; can be used to pass
the timestamp received from Heroku.&lt;/p&gt;
&lt;p&gt;Before using a &lt;code&gt;heroku_drain&lt;/code&gt; target, Heroku should be configured with the URL where the Promtail instance will be listening.
Follow the steps in &lt;a href=&#34;https://devcenter.heroku.com/articles/log-drains#https-drains&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Heroku HTTPS Drain docs&lt;/a&gt; for using the Heroku CLI
with a command like the following:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&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&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;heroku drains:add [http|https]://HOSTNAME:8080/heroku/api/v1/drain -a HEROKU_APP_NAME&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;getting-the-heroku-application-name&#34;&gt;Getting the Heroku application name&lt;/h3&gt;
&lt;p&gt;Note that the &lt;code&gt;__heroku_drain_app&lt;/code&gt; label will contain the source of the log line, either &lt;code&gt;app&lt;/code&gt; or &lt;code&gt;heroku&lt;/code&gt; and not the name of the heroku application.&lt;/p&gt;
&lt;p&gt;The easiest way to provide the actual application name is to include a query parameter when creating the heroku drain and then relabel that parameter in your scraping config, for example:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&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&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;heroku drains:add [http|https]://HOSTNAME:8080/heroku/api/v1/drain?app_name=HEROKU_APP_NAME -a HEROKU_APP_NAME&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;And then in a relabel_config:&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;YAML&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-yaml&#34;&gt;    relabel_configs:
      - source_labels: [&amp;#39;__heroku_drain_param_app_name&amp;#39;]
        target_label: &amp;#39;app&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;It also supports &lt;code&gt;relabeling&lt;/code&gt; and &lt;code&gt;pipeline&lt;/code&gt; stages just like other targets.&lt;/p&gt;
&lt;p&gt;When Promtail receives Heroku Drain logs, various internal labels are made available for &lt;a href=&#34;#relabeling&#34;&gt;relabeling&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__heroku_drain_host&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__heroku_drain_app&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__heroku_drain_proc&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__heroku_drain_log_id&lt;/code&gt;
In the example above, the &lt;code&gt;project_id&lt;/code&gt; label from a GCP resource was transformed into a label called &lt;code&gt;project&lt;/code&gt; through &lt;code&gt;relabel_configs&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;http-client&#34;&gt;HTTP client&lt;/h2&gt;
&lt;p&gt;Promtail uses the Prometheus HTTP client implementation for all calls to Loki.
Therefore it can be configured using the &lt;code&gt;clients&lt;/code&gt; stanza, where one or more
connections to Loki can be established:&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;YAML&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-yaml&#34;&gt;clients:
  - [ &amp;lt;client_option&amp;gt; ]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Refer to &lt;a href=&#34;../configuration/#clients&#34;&gt;&lt;code&gt;client_config&lt;/code&gt;&lt;/a&gt; from the Promtail
Configuration reference for all available options.&lt;/p&gt;
&lt;h2 id=&#34;journal-scraping-linux-only&#34;&gt;Journal Scraping (Linux Only)&lt;/h2&gt;
&lt;p&gt;On systems with &lt;code&gt;systemd&lt;/code&gt;, Promtail also supports reading from the journal. Unlike
file scraping which is defined in the &lt;code&gt;static_configs&lt;/code&gt; stanza, journal scraping is
defined in a &lt;code&gt;journal&lt;/code&gt; stanza:&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;YAML&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-yaml&#34;&gt;scrape_configs:
  - job_name: journal
    journal:
      json: false
      max_age: 12h
      path: /var/log/journal
      matches: _TRANSPORT=kernel
      labels:
        job: systemd-journal
    relabel_configs:
      - source_labels: [&amp;#39;__journal__systemd_unit&amp;#39;]
        target_label: &amp;#39;unit&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;All fields defined in the &lt;code&gt;journal&lt;/code&gt; section are optional, and are just provided
here for reference. The &lt;code&gt;max_age&lt;/code&gt; field ensures that no older entry than the
time specified will be sent to Loki; this circumvents &amp;ldquo;entry too old&amp;rdquo; errors.
The &lt;code&gt;path&lt;/code&gt; field tells Promtail where to read journal entries from. The labels
map defines a constant list of labels to add to every journal entry that Promtail
reads. The &lt;code&gt;matches&lt;/code&gt; field adds journal filters. If multiple filters are specified
matching different fields, the log entries are filtered by both, if two filters
apply to the same field, then they are automatically matched as alternatives.&lt;/p&gt;
&lt;p&gt;When the &lt;code&gt;json&lt;/code&gt; field is set to &lt;code&gt;true&lt;/code&gt;, messages from the journal will be
passed through the pipeline as JSON, keeping all of the original fields from the
journal entry. This is useful when you don&amp;rsquo;t want to index some fields but you
still want to know what values they contained.&lt;/p&gt;
&lt;p&gt;By default, Promtail reads from the journal by looking in the &lt;code&gt;/var/log/journal&lt;/code&gt;
and &lt;code&gt;/run/log/journal&lt;/code&gt; paths. If running Promtail inside of a Docker container,
the path appropriate to your distribution should be bind mounted inside of
Promtail along with binding &lt;code&gt;/etc/machine-id&lt;/code&gt;. Bind mounting &lt;code&gt;/etc/machine-id&lt;/code&gt;
to the path of the same name is required for the journal reader to know which
specific journal to read from. For example:&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;docker run \
  -v /var/log/journal/:/var/log/journal/ \
  -v /run/log/journal/:/run/log/journal/ \
  -v /etc/machine-id:/etc/machine-id \
  grafana/promtail:latest \
  -config.file=/path/to/config/file.yaml&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;When Promtail reads from the journal, it brings in all fields prefixed with
&lt;code&gt;__journal_&lt;/code&gt; as internal labels. Like in the example above, the &lt;code&gt;_SYSTEMD_UNIT&lt;/code&gt;
field from the journal was transformed into a label called &lt;code&gt;unit&lt;/code&gt; through
&lt;code&gt;relabel_configs&lt;/code&gt;. See &lt;a href=&#34;#relabeling&#34;&gt;Relabeling&lt;/a&gt; for more information, also look at &lt;a href=&#34;https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;the systemd man pages&lt;/a&gt; for a list of fields exposed by the journal.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s an example where the &lt;code&gt;SYSTEMD_UNIT&lt;/code&gt;, &lt;code&gt;HOSTNAME&lt;/code&gt;, and &lt;code&gt;SYSLOG_IDENTIFIER&lt;/code&gt; are relabeled for use in Loki.&lt;/p&gt;
&lt;p&gt;Keep in mind that labels prefixed with &lt;code&gt;__&lt;/code&gt; will be dropped, so relabeling is required to keep these labels.&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;YAML&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-yaml&#34;&gt;- job_name: systemd-journal
  journal:
    labels:
      cluster: ops-tools1
      job: default/systemd-journal
    path: /var/log/journal
  relabel_configs:
  - source_labels:
    - __journal__systemd_unit
    target_label: systemd_unit
  - source_labels:
    - __journal__hostname
    target_label: nodename
  - source_labels:
    - __journal_syslog_identifier
    target_label: syslog_identifier&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;kafka&#34;&gt;Kafka&lt;/h2&gt;
&lt;p&gt;Promtail supports reading message from Kafka using a consumer group.
The Kafka targets can be configured using the &lt;code&gt;kafka&lt;/code&gt; stanza:&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;YAML&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-yaml&#34;&gt;scrape_configs:
- job_name: kafka
  kafka:
    brokers:
    - my-kafka-0.org:50705
    - my-kafka-1.org:50705
    topics:
    - ^promtail.*
    - some_fixed_topic
    labels:
      job: kafka
  relabel_configs:
      - action: replace
        source_labels:
          - __meta_kafka_topic
        target_label: topic
      - action: replace
        source_labels:
          - __meta_kafka_partition
        target_label: partition
      - action: replace
        source_labels:
          - __meta_kafka_group_id
        target_label: group
      - action: replace
        source_labels:
          - __meta_kafka_message_key
        target_label: message_key&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Only the &lt;code&gt;brokers&lt;/code&gt; and &lt;code&gt;topics&lt;/code&gt; are required.
Read the &lt;a href=&#34;../configuration/#kafka&#34;&gt;configuration&lt;/a&gt; section for more information.&lt;/p&gt;
&lt;h2 id=&#34;relabeling&#34;&gt;Relabeling&lt;/h2&gt;
&lt;p&gt;Each &lt;code&gt;scrape_configs&lt;/code&gt; entry can contain a &lt;code&gt;relabel_configs&lt;/code&gt; stanza.
&lt;code&gt;relabel_configs&lt;/code&gt; is a list of operations to transform the labels from discovery
into another form.&lt;/p&gt;
&lt;p&gt;A single entry in &lt;code&gt;relabel_configs&lt;/code&gt; can also reject targets by doing an &lt;code&gt;action: drop&lt;/code&gt; if a label value matches a specified regex. When a target is dropped, the
owning &lt;code&gt;scrape_config&lt;/code&gt; will not process logs from that particular source.
Other &lt;code&gt;scrape_configs&lt;/code&gt; without the drop action reading from the same target
may still use and forward logs from it to Loki.&lt;/p&gt;
&lt;p&gt;A common use case of &lt;code&gt;relabel_configs&lt;/code&gt; is to transform an internal label such
as &lt;code&gt;__meta_kubernetes_*&lt;/code&gt; into an intermediate internal label such as
&lt;code&gt;__service__&lt;/code&gt;. The intermediate internal label may then be dropped based on
value or transformed to a final external label, such as &lt;code&gt;__job__&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;examples&#34;&gt;Examples&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Drop the target if a label (&lt;code&gt;__service__&lt;/code&gt; in the example) is empty:&lt;/li&gt;
&lt;/ul&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;YAML&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-yaml&#34;&gt;  - action: drop
    regex: &amp;#39;&amp;#39;
    source_labels:
    - __service__&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Drop the target if any of the &lt;code&gt;source_labels&lt;/code&gt; contain a value:&lt;/li&gt;
&lt;/ul&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;YAML&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-yaml&#34;&gt;  - action: drop
    regex: .&amp;#43;
    separator: &amp;#39;&amp;#39;
    source_labels:
    - __meta_kubernetes_pod_label_name
    - __meta_kubernetes_pod_label_app&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Persist an internal label by renaming it so it will be sent to Loki:&lt;/li&gt;
&lt;/ul&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;YAML&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-yaml&#34;&gt;  - action: replace
    source_labels:
    - __meta_kubernetes_namespace
    target_label: namespace&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Persist all Kubernetes pod labels by mapping them, like by mapping
&lt;code&gt;__meta_kube__meta_kubernetes_pod_label_foo&lt;/code&gt; to &lt;code&gt;foo&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&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;YAML&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-yaml&#34;&gt;  - action: labelmap
    regex: __meta_kubernetes_pod_label_(.&amp;#43;)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Additional reading:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.slideshare.net/roidelapluie/taking-advantage-of-prometheus-relabeling-109483749&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Julien Pivotto&amp;rsquo;s slides from PromConf Munich, 2017&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syslog-receiver&#34;&gt;Syslog Receiver&lt;/h2&gt;
&lt;p&gt;Promtail supports receiving &lt;a href=&#34;https://tools.ietf.org/html/rfc5424&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;IETF Syslog (RFC5424)&lt;/a&gt;
messages from a TCP or UDP stream. Receiving syslog messages is defined in a &lt;code&gt;syslog&lt;/code&gt;
stanza:&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;YAML&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-yaml&#34;&gt;scrape_configs:
  - job_name: syslog
    syslog:
      listen_address: 0.0.0.0:1514
      listen_protocol: tcp
      idle_timeout: 60s
      label_structured_data: yes
      labels:
        job: &amp;#34;syslog&amp;#34;
    relabel_configs:
      - source_labels: [&amp;#39;__syslog_message_hostname&amp;#39;]
        target_label: &amp;#39;host&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The only required field in the syslog section is the &lt;code&gt;listen_address&lt;/code&gt; field,
where a valid network address must be provided. The default protocol for
receiving messages is TCP. To change the protocol, the &lt;code&gt;listen_protocol&lt;/code&gt; field
can be changed to &lt;code&gt;udp&lt;/code&gt;. Note, that UDP does not support TLS.
The &lt;code&gt;idle_timeout&lt;/code&gt; can help with cleaning up stale syslog connections.
If &lt;code&gt;label_structured_data&lt;/code&gt; is set,
&lt;a href=&#34;https://tools.ietf.org/html/rfc5424#section-6.3&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;structured data&lt;/a&gt; in the
syslog header will be translated to internal labels in the form of
&lt;code&gt;__syslog_message_sd_&amp;lt;ID&amp;gt;_&amp;lt;KEY&amp;gt;&lt;/code&gt;.
The labels map defines a constant list of labels to add to every journal entry
that Promtail reads.&lt;/p&gt;
&lt;p&gt;Note that it is recommended to deploy a dedicated syslog forwarder
like &lt;strong&gt;syslog-ng&lt;/strong&gt; or &lt;strong&gt;rsyslog&lt;/strong&gt; in front of Promtail.
The forwarder can take care of the various specifications
and transports that exist (UDP, BSD syslog, &amp;hellip;). See recommended output
configurations for &lt;a href=&#34;#syslog-ng-output-configuration&#34;&gt;syslog-ng&lt;/a&gt; and
&lt;a href=&#34;#rsyslog-output-configuration&#34;&gt;rsyslog&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;When Promtail receives syslog messages, it brings in all header fields,
parsed from the received message, prefixed with &lt;code&gt;__syslog_&lt;/code&gt; as internal labels.
Like in the example above, the &lt;code&gt;__syslog_message_hostname&lt;/code&gt;
field from the journal was transformed into a label called &lt;code&gt;host&lt;/code&gt; through
&lt;code&gt;relabel_configs&lt;/code&gt;. See &lt;a href=&#34;#relabeling&#34;&gt;Relabeling&lt;/a&gt; for more information.&lt;/p&gt;
&lt;h3 id=&#34;syslog-ng-output-configuration&#34;&gt;Syslog-NG Output Configuration&lt;/h3&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&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&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;destination d_loki {
  syslog(&amp;#34;localhost&amp;#34; transport(&amp;#34;tcp&amp;#34;) port(&amp;lt;promtail_port&amp;gt;));
};&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;rsyslog-output-configuration&#34;&gt;Rsyslog Output Configuration&lt;/h3&gt;
&lt;p&gt;For sending messages via TCP:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&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&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;*.* action(type=&amp;#34;omfwd&amp;#34; protocol=&amp;#34;tcp&amp;#34; target=&amp;#34;&amp;lt;promtail_host&amp;gt;&amp;#34; port=&amp;#34;&amp;lt;promtail_port&amp;gt;&amp;#34; Template=&amp;#34;RSYSLOG_SyslogProtocol23Format&amp;#34; TCP_Framing=&amp;#34;octet-counted&amp;#34; KeepAlive=&amp;#34;on&amp;#34;)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;For sending messages via UDP:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&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&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;*.* action(type=&amp;#34;omfwd&amp;#34; protocol=&amp;#34;udp&amp;#34; target=&amp;#34;&amp;lt;promtail_host&amp;gt;&amp;#34; port=&amp;#34;&amp;lt;promtail_port&amp;gt;&amp;#34; Template=&amp;#34;RSYSLOG_SyslogProtocol23Format&amp;#34;)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;windows-event-log&#34;&gt;Windows Event Log&lt;/h2&gt;
&lt;p&gt;On Windows Promtail supports reading from the event log.
Windows event targets can be configured using the &lt;code&gt;windows_events&lt;/code&gt; stanza:&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;YAML&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-yaml&#34;&gt;scrape_configs:
- job_name: windows
  windows_events:
    use_incoming_timestamp: false
    bookmark_path: &amp;#34;./bookmark.xml&amp;#34;
    eventlog_name: &amp;#34;Application&amp;#34;
    xpath_query: &amp;#39;*&amp;#39;
    labels:
      job: windows
  relabel_configs:
    - source_labels: [&amp;#39;computer&amp;#39;]
      target_label: &amp;#39;host&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;When Promtail receives an event it will attach the &lt;code&gt;channel&lt;/code&gt; and &lt;code&gt;computer&lt;/code&gt; labels
and serialize the event in json.
You can relabel default labels via &lt;a href=&#34;#relabeling&#34;&gt;Relabeling&lt;/a&gt; if required.&lt;/p&gt;
&lt;p&gt;Providing a path to a bookmark is mandatory, it will be used to persist the last event processed and allow
resuming the target without skipping logs.&lt;/p&gt;
&lt;p&gt;Read the &lt;a href=&#34;../configuration/#windows_events&#34;&gt;configuration&lt;/a&gt; section for more information.&lt;/p&gt;
&lt;p&gt;See the &lt;a href=&#34;../stages/eventlogmessage/&#34;&gt;eventlogmessage&lt;/a&gt; stage for extracting
data from the &lt;code&gt;message&lt;/code&gt;.&lt;/p&gt;
]]></content><description>&lt;h1 id="configuring-promtail-for-service-discovery">Configuring Promtail for service discovery&lt;/h1>
&lt;div data-shared="promtail-deprecation.md">
&lt;div class="admonition admonition-caution">&lt;blockquote>&lt;p class="title text-uppercase">Caution&lt;/p>&lt;p>Promtail has been deprecated and is in Long-Term Support (LTS) through February 28, 2026. Promtail will reach an End-of-Life (EOL) on March 2, 2026. You can find migration resources &lt;a href="/docs/alloy/latest/set-up/migrate/from-promtail/">here&lt;/a>.&lt;/p></description></item><item><title>Promtail and Log Rotation</title><link>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/promtail/logrotation/</link><pubDate>Sat, 11 Apr 2026 00:53:11 +0000</pubDate><guid>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/promtail/logrotation/</guid><content><![CDATA[&lt;h1 id=&#34;promtail-and-log-rotation&#34;&gt;Promtail and Log Rotation&lt;/h1&gt;


&lt;div data-shared=&#34;promtail-deprecation.md&#34;&gt;
            

&lt;div class=&#34;admonition admonition-caution&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Caution&lt;/p&gt;&lt;p&gt;Promtail has been deprecated and is in Long-Term Support (LTS) through February 28, 2026. Promtail will reach an End-of-Life (EOL) on March 2, 2026. You can find migration resources &lt;a href=&#34;/docs/alloy/latest/set-up/migrate/from-promtail/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;/div&gt;

        
&lt;h2 id=&#34;why-does-log-rotation-matter&#34;&gt;Why does log rotation matter?&lt;/h2&gt;
&lt;p&gt;At any point in time, there may be three processes working on a log file as shown in the image below.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;./logrotation-components.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;./logrotation-components.png&#34;alt=&#34;block diagram showing three processes&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;./logrotation-components.png&#34;
            alt=&#34;block diagram showing three processes&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;ol&gt;
&lt;li&gt;Appender - A writer that keeps appending to a log file. This can be your application or some system daemons like Syslog, Docker log driver or Kubelet, etc.&lt;/li&gt;
&lt;li&gt;Tailer - A reader that reads log lines as they are appended, for example, agents like Promtail.&lt;/li&gt;
&lt;li&gt;Log Rotator - A process that rotates the log file either based on time (for example, scheduled every day) or size (for example, a log file reached its maximum size).&lt;/li&gt;
&lt;/ol&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Here &lt;code&gt;fd&lt;/code&gt; defines a file descriptor. Once a file is open for read or write, The Operating System returns a unique file descriptor (usually an integer) per process, and all the operations like read and write are done over that file descriptor. In other words, once the file is opened successfully, the file descriptor matters more than the file name.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;One of the critical components here is the log rotator. Let&amp;rsquo;s understand how it impacts other components like the appender and tailer.&lt;/p&gt;
&lt;p&gt;In general, when a software program rotates a log, it can be done in two ways internally.&lt;/p&gt;
&lt;p&gt;Given a log file named &lt;code&gt;error.log&lt;/code&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Copy the log file with a different name, for example, &lt;code&gt;error.log.1&lt;/code&gt; and truncate the original log file &lt;code&gt;error.log&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Rename the log file with a different name, for example,  &lt;code&gt;error.log.1&lt;/code&gt; and create a new log file with the original name &lt;code&gt;error.log&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In both cases, after log rotation, all new log lines are written to the original &lt;code&gt;error.log&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;These two methods of log rotation are shown in the following images.&lt;/p&gt;
&lt;h3 id=&#34;copy-and-truncate&#34;&gt;Copy and Truncate&lt;/h3&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;./logrotation-copy-and-truncate.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;./logrotation-copy-and-truncate.png&#34;alt=&#34;Copy and truncate log rotation&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;./logrotation-copy-and-truncate.png&#34;
            alt=&#34;Copy and truncate log rotation&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h3 id=&#34;rename-and-create&#34;&gt;Rename and Create&lt;/h3&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;./logrotation-rename-and-create.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;./logrotation-rename-and-create.png&#34;alt=&#34;Rename and create log rotation&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;./logrotation-rename-and-create.png&#34;
            alt=&#34;Rename and create log rotation&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;Both types of log rotation produce the same result. However, there are some subtle differences.&lt;/p&gt;
&lt;p&gt;Copy and Truncate(1) favors the &lt;code&gt;appender&lt;/code&gt; as its descriptor for the original log file &lt;code&gt;error.log&lt;/code&gt; doesn&amp;rsquo;t change. Therefore, it can keep writing to the same file descriptor. In other words, re-opening the file is not needed.&lt;/p&gt;
&lt;p&gt;However, (1) has a serious problem when considering the &lt;code&gt;tailer&lt;/code&gt;. There is a race between truncating the file and the &lt;code&gt;tailer&lt;/code&gt; finishing reading that log file. Meaning, there is a high chance of the log rotation mechanism truncating the file &lt;code&gt;error.log&lt;/code&gt; before the &lt;code&gt;tailer&lt;/code&gt; reads everything from it.&lt;/p&gt;
&lt;p&gt;This is where Rename and Create(2) can help. Here, when the log file &lt;code&gt;error.log&lt;/code&gt; is renamed to &lt;code&gt;error.log.1&lt;/code&gt;, the &lt;code&gt;tailer&lt;/code&gt; still holds the file descriptor of &lt;code&gt;error.log.1&lt;/code&gt;. Therefore, it can continue reading the log file until it is completed. But that comes with the tradeoff: with (2), you have to signal the &lt;code&gt;appender&lt;/code&gt; to reopen &lt;code&gt;error.log&lt;/code&gt; (and &lt;code&gt;appender&lt;/code&gt; should be able to reopen it). Otherwise, it would keep writing to &lt;code&gt;error.log.1&lt;/code&gt; as the file descriptor won&amp;rsquo;t change. The good news is that most of the popular &lt;code&gt;appender&lt;/code&gt; solutions (for example, Syslog, Kubelet, Docker log driver) support reopening log files when they are renamed.&lt;/p&gt;
&lt;p&gt;We recommend Rename and Create(2) as that is the method which works well with Promtail (or any similar log scraping agent) without any data loss. Now let&amp;rsquo;s understand exactly how we configure log rotation in different platforms.&lt;/p&gt;
&lt;h2 id=&#34;configure-log-rotation&#34;&gt;Configure log rotation&lt;/h2&gt;
&lt;p&gt;Your logs can be rotated by different components depending on where you are running your applications or services. If you are running them on Linux machines, there is a high chance you are using the &lt;a href=&#34;https://man7.org/linux/man-pages/man8/logrotate.8.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;logrotate&lt;/code&gt;&lt;/a&gt; utility. However, if you are running in Kubernetes, it&amp;rsquo;s not that obvious what rotates the logs and interestingly it may depend on what container runtime your Kubernetes cluster is using.&lt;/p&gt;
&lt;h3 id=&#34;non-kubernetes&#34;&gt;Non-Kubernetes&lt;/h3&gt;
&lt;p&gt;As mentioned above, in Linux machines, log rotation is often handled by the &lt;a href=&#34;https://man7.org/linux/man-pages/man8/logrotate.8.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;logrotate&lt;/code&gt;&lt;/a&gt; utility.&lt;/p&gt;
&lt;p&gt;The configuration for &lt;code&gt;logrotate&lt;/code&gt; is usually located in &lt;code&gt;/etc/logrotate/&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It has a wide range of &lt;a href=&#34;https://man7.org/linux/man-pages/man8/logrotate.8.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;options&lt;/a&gt; for compression, mailing, running scripts pre- and post-rotation, etc.&lt;/p&gt;
&lt;p&gt;It supports both methods of log rotation described previously.&lt;/p&gt;
&lt;h4 id=&#34;copy-and-truncate-1&#34;&gt;Copy and Truncate&lt;/h4&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&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&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;/var/log/apache2/*.log {
        weekly
        maxsize 1G
        copytruncate
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Here &lt;code&gt;copytruncate&lt;/code&gt; mode works exactly like (1) explained above.&lt;/p&gt;
&lt;h4 id=&#34;rename-and-create-recommend&#34;&gt;Rename and Create &lt;strong&gt;(Recommend)&lt;/strong&gt;&lt;/h4&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&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&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;/var/log/apache2/*.log {
        weekly
        maxsize 1G
        create
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Here, the &lt;code&gt;create&lt;/code&gt; mode works as explained in (2) above. The &lt;code&gt;create&lt;/code&gt; mode is optional because it&amp;rsquo;s the default mode in &lt;code&gt;logrotate&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;kubernetes&#34;&gt;Kubernetes&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;../scraping/#kubernetes-discovery&#34;&gt;Kubernetes Service Discovery in Promtail&lt;/a&gt; also uses file-based scraping. Meaning, logs from your pods are stored on the nodes and Promtail scrapes the pod logs from the node files.&lt;/p&gt;
&lt;p&gt;You can &lt;a href=&#34;https://kubernetes.io/docs/concepts/cluster-administration/logging/#log-rotation&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;configure&lt;/a&gt; the &lt;code&gt;kubelet&lt;/code&gt; process running on each node to manage log rotation via two configuration settings.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;containerLogMaxSize&lt;/code&gt; - It defines the maximum size of the container log file before it is rotated. For example: &amp;ldquo;5Mi&amp;rdquo; or &amp;ldquo;256Ki&amp;rdquo;. Default: &amp;ldquo;10Mi&amp;rdquo;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;containerLogMaxFiles&lt;/code&gt; - It specifies the maximum number of container log files that can be present per container. Default: 5&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Both should be part of the &lt;code&gt;kubelet&lt;/code&gt; config. If you run a managed version of Kubernetes in Cloud, refer to your cloud provider documentation for configuring &lt;code&gt;kubelet&lt;/code&gt;. Examples &lt;a href=&#34;https://cloud.google.com/kubernetes-engine/docs/how-to/node-system-config#create&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;GKE&lt;/a&gt;, &lt;a href=&#34;https://learn.microsoft.com/en-us/azure/aks/custom-node-configuration#use-custom-node-configuration&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;AKS&lt;/a&gt; and &lt;a href=&#34;https://eksctl.io/usage/customizing-the-kubelet/#customizing-kubelet-configuration&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;EKS&lt;/a&gt;.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Log rotation managed by &lt;code&gt;kubelet&lt;/code&gt; supports only rename &#43; create and doesn&amp;rsquo;t support copy &#43; truncate.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;If &lt;code&gt;kubelet&lt;/code&gt; is not configured to manage the log rotation, then it&amp;rsquo;s up to the Container Runtime Interface (CRI) the cluster uses. Alternatively, log rotation can be managed by the &lt;code&gt;logrotate&lt;/code&gt; utility in the Kubernetes node itself.&lt;/p&gt;
&lt;p&gt;Check your container runtime (CRI) on your nodes by running:&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;$ kubectl get nodes -o wide&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Two of the commonly used CRI implementations are &lt;code&gt;containerd&lt;/code&gt; and &lt;code&gt;docker&lt;/code&gt;.&lt;/p&gt;
&lt;h4 id=&#34;containerd-cri&#34;&gt;containerd CRI&lt;/h4&gt;
&lt;p&gt;At the time of writing this guide, &lt;code&gt;containerd&lt;/code&gt; &lt;a href=&#34;https://github.com/containerd/containerd/issues/4830#issuecomment-744744375&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;doesn&amp;rsquo;t support any method of log rotation&lt;/a&gt;. In this case, rotation is often handled by &lt;code&gt;kubelet&lt;/code&gt; itself. Managed Kubernetes clusters like GKE and AKS use &lt;code&gt;containerd&lt;/code&gt; as runtime and log rotation is handled by &lt;code&gt;kubelet&lt;/code&gt;. &lt;a href=&#34;https://docs.aws.amazon.com/eks/latest/userguide/dockershim-deprecation.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;EKS after version 1.24&lt;/a&gt; also uses &lt;code&gt;containerd&lt;/code&gt; as its default container runtime.&lt;/p&gt;
&lt;h4 id=&#34;docker-cri&#34;&gt;docker CRI&lt;/h4&gt;
&lt;p&gt;When using &lt;code&gt;docker&lt;/code&gt; as runtime (EKS before 1.24 uses it by default), log rotation is managed by its logging driver (if supported). Docker has &lt;a href=&#34;https://docs.docker.com/config/containers/logging/configure/#supported-logging-drivers&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;support for several logging drivers&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can determine which logging driver &lt;code&gt;docker&lt;/code&gt; is using by running the following command:&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; docker info --format &amp;#39;{{.LoggingDriver}}&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Out of all these logging drivers only the &lt;code&gt;local&lt;/code&gt; (default) and the &lt;code&gt;json-file&lt;/code&gt; drivers support log rotation. You can configure the following &lt;code&gt;log-opts&lt;/code&gt; under &lt;code&gt;/etc/docker/daemon.json&lt;/code&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;max-size&lt;/code&gt; - The maximum size of the log file before it is rotated. A positive integer plus a modifier representing the unit of measure (k, m, or g). Defaults to &lt;code&gt;20m&lt;/code&gt; (20 megabytes).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;max-file&lt;/code&gt; - The maximum number of log files that can be present. If rolling the logs creates excess files, the oldest file is removed. A positive integer. Defaults to 5.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Example &lt;code&gt;/etc/docker/daemon.json&lt;/code&gt;:&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;JSON&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-json&#34;&gt;{
  &amp;#34;log-driver&amp;#34;: &amp;#34;local&amp;#34;,
  &amp;#34;log-opts&amp;#34;: {
    &amp;#34;max-size&amp;#34;: &amp;#34;10m&amp;#34;,
    &amp;#34;max-file&amp;#34;: &amp;#34;10&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If neither &lt;code&gt;kubelet&lt;/code&gt; nor &lt;code&gt;CRI&lt;/code&gt; is configured for rotating logs, then the &lt;code&gt;logrotate&lt;/code&gt; utility can be used on the Kubernetes nodes as explained previously.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;We recommend using kubelet for log rotation.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;configure-promtail&#34;&gt;Configure Promtail&lt;/h2&gt;
&lt;p&gt;Promtail uses &lt;code&gt;polling&lt;/code&gt; to watch for file changes. A &lt;code&gt;polling&lt;/code&gt; mechanism combined with a &lt;a href=&#34;#copy-and-truncate&#34;&gt;copy and truncate&lt;/a&gt; log rotation may result in losing some logs. As explained earlier in this topic, this happens when the file is truncated before Promtail reads all the log lines from such a file.&lt;/p&gt;
&lt;p&gt;Therefore, for a long-term solution, we strongly recommend changing the log rotation strategy to &lt;a href=&#34;#rename-and-create&#34;&gt;rename and create&lt;/a&gt;. Alternatively, as a workaround in the short term, you can tweak the promtail client&amp;rsquo;s &lt;code&gt;batchsize&lt;/code&gt; &lt;a href=&#34;../configuration/#clients&#34;&gt;config&lt;/a&gt; to set higher values (like 5M or 8M). This gives Promtail more room to read loglines without frequently waiting for push responses from the Loki server.&lt;/p&gt;
]]></content><description>&lt;h1 id="promtail-and-log-rotation">Promtail and Log Rotation&lt;/h1>
&lt;div data-shared="promtail-deprecation.md">
&lt;div class="admonition admonition-caution">&lt;blockquote>&lt;p class="title text-uppercase">Caution&lt;/p>&lt;p>Promtail has been deprecated and is in Long-Term Support (LTS) through February 28, 2026. Promtail will reach an End-of-Life (EOL) on March 2, 2026. You can find migration resources &lt;a href="/docs/alloy/latest/set-up/migrate/from-promtail/">here&lt;/a>.&lt;/p></description></item><item><title>Pipelines</title><link>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/promtail/pipelines/</link><pubDate>Sat, 11 Apr 2026 00:53:11 +0000</pubDate><guid>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/promtail/pipelines/</guid><content><![CDATA[&lt;h1 id=&#34;pipelines&#34;&gt;Pipelines&lt;/h1&gt;


&lt;div data-shared=&#34;promtail-deprecation.md&#34;&gt;
            

&lt;div class=&#34;admonition admonition-caution&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Caution&lt;/p&gt;&lt;p&gt;Promtail has been deprecated and is in Long-Term Support (LTS) through February 28, 2026. Promtail will reach an End-of-Life (EOL) on March 2, 2026. You can find migration resources &lt;a href=&#34;/docs/alloy/latest/set-up/migrate/from-promtail/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;/div&gt;

        
&lt;p&gt;A detailed look at how to set up Promtail to process your log lines, including
extracting metrics and labels.&lt;/p&gt;
&lt;h2 id=&#34;pipeline&#34;&gt;Pipeline&lt;/h2&gt;
&lt;p&gt;A pipeline is used to transform a single log line, its labels, and its
timestamp. A pipeline is comprised of a set of &lt;strong&gt;stages&lt;/strong&gt;. There are 4 types of
stages:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Parsing stages&lt;/strong&gt; parse the current log line and extract data out of it. The
extracted data is then available for use by other stages.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Transform stages&lt;/strong&gt; transform extracted data from previous stages.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Action stages&lt;/strong&gt; take extracted data from previous stages and do something
with them. Actions can:
&lt;ol&gt;
&lt;li&gt;Add or modify existing labels to the log line&lt;/li&gt;
&lt;li&gt;Change the timestamp of the log line&lt;/li&gt;
&lt;li&gt;Change the content of the log line&lt;/li&gt;
&lt;li&gt;Create a metric based on the extracted data&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Filtering stages&lt;/strong&gt; optionally apply a subset of stages or drop entries based on some
condition.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Typical pipelines will start with a parsing stage (such as a
&lt;a href=&#34;../stages/regex/&#34;&gt;regex&lt;/a&gt; or &lt;a href=&#34;../stages/json/&#34;&gt;json&lt;/a&gt; stage) to extract data
from the log line. Then, a series of action stages will be present to do
something with that extracted data. The most common action stage will be a
&lt;a href=&#34;../stages/labels/&#34;&gt;labels&lt;/a&gt; stage to turn extracted data into a label.&lt;/p&gt;
&lt;p&gt;A common stage will also be the &lt;a href=&#34;../stages/match/&#34;&gt;match&lt;/a&gt; stage to selectively
apply stages or drop entries based on a &lt;a href=&#34;../../../query/&#34;&gt;LogQL stream selector and filter expressions&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Note that pipelines can not currently be used to deduplicate logs; Grafana Loki will
receive the same log line multiple times if, for example:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Two scrape configs read from the same file&lt;/li&gt;
&lt;li&gt;Duplicate log lines in a file are sent through a pipeline. Deduplication is
not done.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;However, Loki will perform some deduplication at query time for logs that have
the exact same nanosecond timestamp, labels, and log contents.&lt;/p&gt;
&lt;p&gt;This documented example gives a good glimpse of what you can achieve with a
pipeline:&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;YAML&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-yaml&#34;&gt;scrape_configs:
- job_name: kubernetes-pods-name
  kubernetes_sd_configs: ....
  pipeline_stages:

  # This stage is only going to run if the scraped target has a label
  # of &amp;#34;name&amp;#34; with value &amp;#34;promtail&amp;#34;.
  - match:
      selector: &amp;#39;{name=&amp;#34;promtail&amp;#34;}&amp;#39;
      stages:
      # The regex stage parses out a level, timestamp, and component. At the end
      # of the stage, the values for level, timestamp, and component are only
      # set internally for the pipeline. Future stages can use these values and
      # decide what to do with them.
      - regex:
          expression: &amp;#39;.*level=(?P&amp;lt;level&amp;gt;[a-zA-Z]&amp;#43;).*ts=(?P&amp;lt;timestamp&amp;gt;[T\d-:.Z]*).*component=(?P&amp;lt;component&amp;gt;[a-zA-Z]&amp;#43;)&amp;#39;

      # The labels stage takes the level and component entries from the previous
      # regex stage and promotes them to a label. For example, level=error may
      # be a label added by this stage.
      - labels:
          level:
          component:

      # Finally, the timestamp stage takes the timestamp extracted from the
      # regex stage and promotes it to be the new timestamp of the log entry,
      # parsing it as an RFC3339Nano-formatted value.
      - timestamp:
          format: RFC3339Nano
          source: timestamp

  # This stage is only going to run if the scraped target has a label of
  # &amp;#34;name&amp;#34; with a value of &amp;#34;nginx&amp;#34; and if the log line contains the word &amp;#34;GET&amp;#34;
  - match:
      selector: &amp;#39;{name=&amp;#34;nginx&amp;#34;} |= &amp;#34;GET&amp;#34;&amp;#39;
      stages:
      # This regex stage extracts a new output by matching against some
      # values and capturing the rest.
      - regex:
          expression: \w{1,3}.\w{1,3}.\w{1,3}.\w{1,3}(?P&amp;lt;output&amp;gt;.*)

      # The output stage changes the content of the captured log line by
      # setting it to the value of output from the regex stage.
      - output:
          source: output

  # This stage is only going to run if the scraped target has a label of
  # &amp;#34;name&amp;#34; with a value of &amp;#34;jaeger-agent&amp;#34;.
  - match:
      selector: &amp;#39;{name=&amp;#34;jaeger-agent&amp;#34;}&amp;#39;
      stages:
      # The JSON stage reads the log line as a JSON string and extracts
      # the &amp;#34;level&amp;#34; field from the object for use in further stages.
      - json:
          expressions:
            level: level

      # The labels stage pulls the value from &amp;#34;level&amp;#34; that was extracted
      # from the previous stage and promotes it to a label.
      - labels:
          level:
- job_name: kubernetes-pods-app
  kubernetes_sd_configs: ....
  pipeline_stages:
  # This stage will only run if the scraped target has a label of &amp;#34;app&amp;#34;
  # with a name of *either* grafana or prometheus.
  - match:
      selector: &amp;#39;{app=~&amp;#34;grafana|prometheus&amp;#34;}&amp;#39;
      stages:
      # The regex stage will extract a level and component for use in further
      # stages, allowing the level to be defined as either lvl=&amp;lt;level&amp;gt; or
      # level=&amp;lt;level&amp;gt; and the component to be defined as either
      # logger=&amp;lt;component&amp;gt; or component=&amp;lt;component&amp;gt;
      - regex:
          expression: &amp;#34;.*(lvl|level)=(?P&amp;lt;level&amp;gt;[a-zA-Z]&amp;#43;).*(logger|component)=(?P&amp;lt;component&amp;gt;[a-zA-Z]&amp;#43;)&amp;#34;

      # The labels stage then promotes the level and component extracted from
      # the regex stage to labels.
      - labels:
          level:
          component:

  # This stage will only run if the scraped target has a label &amp;#34;app&amp;#34;
  # with a value of &amp;#34;some-app&amp;#34; and the log line doesn&amp;#39;t contain the word &amp;#34;info&amp;#34;
  - match:
      selector: &amp;#39;{app=&amp;#34;some-app&amp;#34;} != &amp;#34;info&amp;#34;&amp;#39;
      stages:
      # The regex stage tries to extract a Go panic by looking for panic:
      # in the log message.
      - regex:
          expression: &amp;#34;.*(?P&amp;lt;panic&amp;gt;panic: .*)&amp;#34;

      # The metrics stage is going to increment a panic_total metric counter
      # which Promtail exposes. The counter is only incremented when panic
      # was extracted from the regex stage.
      - metrics:
          panic_total:
            type: Counter
            description: &amp;#34;total count of panic&amp;#34;
            source: panic
            config:
              action: inc&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;data-accessible-to-stages&#34;&gt;Data Accessible to Stages&lt;/h3&gt;
&lt;p&gt;The following sections further describe the types that are accessible to each
stage (although not all may be used):&lt;/p&gt;
&lt;h4 id=&#34;label-set&#34;&gt;Label Set&lt;/h4&gt;
&lt;p&gt;The current set of labels for the log line. Initialized to be the set of labels
that were scraped along with the log line. The label set is only modified by an
action stage, but filtering stages read from it.&lt;/p&gt;
&lt;p&gt;The final label set will be index by Loki and can be used for queries.&lt;/p&gt;
&lt;h4 id=&#34;extracted-map&#34;&gt;Extracted Map&lt;/h4&gt;
&lt;p&gt;A collection of key-value pairs extracted during a parsing stage. Subsequent
stages operate on the extracted map, either transforming them or taking action
with them. At the end of a pipeline, the extracted map is discarded; for a
parsing stage to be useful, it must always be paired with at least one action
stage.&lt;/p&gt;
&lt;p&gt;The extracted map is initialized with the same set of initial labels that were
scraped along with the log line. This initial data allows for taking action on
the values of labels inside pipeline stages that only manipulate the extracted
map. For example, log entries tailed from files have the label &lt;code&gt;filename&lt;/code&gt; whose
value is the file path that was tailed. When a pipeline executes for that log
entry, the initial extracted map would contain &lt;code&gt;filename&lt;/code&gt; using the same value
as the label.&lt;/p&gt;
&lt;h4 id=&#34;log-timestamp&#34;&gt;Log Timestamp&lt;/h4&gt;
&lt;p&gt;The current timestamp for the log line. Action stages can modify this value.
If left unset, it defaults to the time when the log was scraped.&lt;/p&gt;
&lt;p&gt;The final value for the timestamp is sent to Loki.&lt;/p&gt;
&lt;h4 id=&#34;log-line&#34;&gt;Log Line&lt;/h4&gt;
&lt;p&gt;The current log line, represented as text. Initialized to be the text that
Promtail scraped. Action stages can modify this value.&lt;/p&gt;
&lt;p&gt;The final value for the log line is sent to Loki as the text content for the
given log entry.&lt;/p&gt;
&lt;h2 id=&#34;stages&#34;&gt;Stages&lt;/h2&gt;
&lt;p&gt;Refer to the &lt;a href=&#34;../stages/#promtail-pipeline-stages&#34;&gt;Promtail Stages Configuration Reference&lt;/a&gt; for the
schema on the various supported stages supported.&lt;/p&gt;
]]></content><description>&lt;h1 id="pipelines">Pipelines&lt;/h1>
&lt;div data-shared="promtail-deprecation.md">
&lt;div class="admonition admonition-caution">&lt;blockquote>&lt;p class="title text-uppercase">Caution&lt;/p>&lt;p>Promtail has been deprecated and is in Long-Term Support (LTS) through February 28, 2026. Promtail will reach an End-of-Life (EOL) on March 2, 2026. You can find migration resources &lt;a href="/docs/alloy/latest/set-up/migrate/from-promtail/">here&lt;/a>.&lt;/p></description></item><item><title>Promtail pipeline stages</title><link>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/promtail/stages/</link><pubDate>Sat, 11 Apr 2026 00:53:11 +0000</pubDate><guid>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/promtail/stages/</guid><content><![CDATA[&lt;h1 id=&#34;promtail-pipeline-stages&#34;&gt;Promtail pipeline stages&lt;/h1&gt;


&lt;div data-shared=&#34;promtail-deprecation.md&#34;&gt;
            

&lt;div class=&#34;admonition admonition-caution&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Caution&lt;/p&gt;&lt;p&gt;Promtail has been deprecated and is in Long-Term Support (LTS) through February 28, 2026. Promtail will reach an End-of-Life (EOL) on March 2, 2026. You can find migration resources &lt;a href=&#34;/docs/alloy/latest/set-up/migrate/from-promtail/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;/div&gt;

        
&lt;p&gt;This section is a collection of all stages Promtail supports in a
&lt;a href=&#34;../pipelines/&#34;&gt;Pipeline&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Parsing stages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;docker/&#34;&gt;docker&lt;/a&gt;: Extract data by parsing the log line using the standard Docker format.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;cri/&#34;&gt;cri&lt;/a&gt;: Extract data by parsing the log line using the standard CRI format.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;regex/&#34;&gt;regex&lt;/a&gt;: Extract data using a regular expression.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;json/&#34;&gt;json&lt;/a&gt;: Extract data by parsing the log line as JSON.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;logfmt/&#34;&gt;logfmt&lt;/a&gt;: Extract data by parsing the log line as logfmt.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;replace/&#34;&gt;replace&lt;/a&gt;: Replace data using a regular expression.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;multiline/&#34;&gt;multiline&lt;/a&gt;: Merge multiple lines into a multiline block.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;geoip/&#34;&gt;geoip&lt;/a&gt;: Extract geoip data from extracted labels.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Transform stages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;template/&#34;&gt;template&lt;/a&gt;: Use Go templates to modify extracted data.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;pack/&#34;&gt;pack&lt;/a&gt;: Packs a log line in a JSON object allowing extracted values and labels to be placed inside the log line.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;decolorize/&#34;&gt;decolorize&lt;/a&gt;: Strips ANSI color sequences from the log line.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Action stages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;timestamp/&#34;&gt;timestamp&lt;/a&gt;: Set the timestamp value for the log entry.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;output/&#34;&gt;output&lt;/a&gt;: Set the log line text.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;labeldrop/&#34;&gt;labeldrop&lt;/a&gt;: Drop label set for the log entry.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;labelallow/&#34;&gt;labelallow&lt;/a&gt;: Allow label set for the log entry.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;labels/&#34;&gt;labels&lt;/a&gt;: Update the label set for the log entry.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;limit/&#34;&gt;limit&lt;/a&gt;: Limit the rate lines will be sent to Loki.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;sampling/&#34;&gt;sampling&lt;/a&gt;: Sampling the lines will be sent to Loki.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;static_labels/&#34;&gt;static_labels&lt;/a&gt;: Add static-labels to the log entry.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;metrics/&#34;&gt;metrics&lt;/a&gt;: Calculate metrics based on extracted data.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;tenant/&#34;&gt;tenant&lt;/a&gt;: Set the tenant ID value to use for the log entry.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;structured_metadata/&#34;&gt;structured_metadata&lt;/a&gt;: Add structured metadata to the log entry.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Filtering stages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;match/&#34;&gt;match&lt;/a&gt;: Conditionally run stages based on the label set.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;drop/&#34;&gt;drop&lt;/a&gt;: Conditionally drop log lines based on several options.&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="promtail-pipeline-stages">Promtail pipeline stages&lt;/h1>
&lt;div data-shared="promtail-deprecation.md">
&lt;div class="admonition admonition-caution">&lt;blockquote>&lt;p class="title text-uppercase">Caution&lt;/p>&lt;p>Promtail has been deprecated and is in Long-Term Support (LTS) through February 28, 2026. Promtail will reach an End-of-Life (EOL) on March 2, 2026. You can find migration resources &lt;a href="/docs/alloy/latest/set-up/migrate/from-promtail/">here&lt;/a>.&lt;/p></description></item><item><title>Troubleshooting Promtail</title><link>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/promtail/troubleshooting/</link><pubDate>Sat, 11 Apr 2026 00:53:11 +0000</pubDate><guid>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/promtail/troubleshooting/</guid><content><![CDATA[&lt;h1 id=&#34;troubleshooting-promtail&#34;&gt;Troubleshooting Promtail&lt;/h1&gt;
&lt;p&gt;This document describes known failure modes of Promtail on edge cases and the adopted trade-offs.&lt;/p&gt;


&lt;div data-shared=&#34;promtail-deprecation.md&#34;&gt;
            

&lt;div class=&#34;admonition admonition-caution&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Caution&lt;/p&gt;&lt;p&gt;Promtail has been deprecated and is in Long-Term Support (LTS) through February 28, 2026. Promtail will reach an End-of-Life (EOL) on March 2, 2026. You can find migration resources &lt;a href=&#34;/docs/alloy/latest/set-up/migrate/from-promtail/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;/div&gt;

        
&lt;h2 id=&#34;dry-running&#34;&gt;Dry running&lt;/h2&gt;
&lt;p&gt;Promtail can be configured to print log stream entries instead of sending them to Loki.
This can be used in combination with &lt;a href=&#34;#pipe-data-to-promtail&#34;&gt;piping data&lt;/a&gt; to debug or troubleshoot Promtail log parsing.&lt;/p&gt;
&lt;p&gt;In dry run mode, Promtail still support reading from a &lt;a href=&#34;../configuration/#positions&#34;&gt;positions&lt;/a&gt; file however no update will be made to the targeted file, this is to ensure you can easily retry the same set of lines.&lt;/p&gt;
&lt;p&gt;To start Promtail in dry run mode use the flag &lt;code&gt;--dry-run&lt;/code&gt; as shown in the example below:&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;cat my.log | promtail --stdin --dry-run --client.url http://127.0.0.1:3100/loki/api/v1/push&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;inspecting-a-config-file&#34;&gt;Inspecting a config file&lt;/h2&gt;
&lt;p&gt;Promtail can validate and syntatically check your &lt;code&gt;config&lt;/code&gt; file for a valid configuration.
This can be used to check for errors and inconsistency in your config file and help prevent deploying invalid configurations.&lt;/p&gt;
&lt;p&gt;In check syntax mode, promtail will just validate the config file and then exit:&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;promtail -config.file=myConfigFile.yaml -check-syntax&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;inspecting-pipeline-stages&#34;&gt;Inspecting pipeline stages&lt;/h2&gt;
&lt;p&gt;Promtail can output all changes to log entries as each pipeline stage is executed.
Each log entry contains four fields:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;line&lt;/li&gt;
&lt;li&gt;timestamp&lt;/li&gt;
&lt;li&gt;labels&lt;/li&gt;
&lt;li&gt;extracted fields&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Enable the inspection output using the &lt;code&gt;--inspect&lt;/code&gt; command-line option. The &lt;code&gt;--inspect&lt;/code&gt; option can be used in combination with &lt;code&gt;--stdin&lt;/code&gt; and &lt;code&gt;--dry-run&lt;/code&gt;.&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;cat my.log | promtail --stdin --dry-run --inspect --client.url http://127.0.0.1:3100/loki/api/v1/push&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;./inspect.png&#34;
  alt=&#34;screenshot&#34;/&gt;&lt;/p&gt;
&lt;p&gt;The output uses color to highlight changes. Additions are in green, modifications in yellow, and removals in red.&lt;/p&gt;
&lt;p&gt;If no changes are applied during a stage, that is usually an indication of a misconfiguration or undesired behavior.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;--inspect&lt;/code&gt; flag should not be used in production, as the calculation of changes between pipeline stages negatively
impacts Promtail&amp;rsquo;s performance.&lt;/p&gt;
&lt;h2 id=&#34;pipe-data-to-promtail&#34;&gt;Pipe data to Promtail&lt;/h2&gt;
&lt;p&gt;Promtail supports piping data for sending logs to Loki (via the flag &lt;code&gt;--stdin&lt;/code&gt;). This is a very useful way to troubleshooting your configuration.
Once you have Promtail installed you can for instance use the following command to send logs to a local Loki instance:&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;cat my.log | promtail --stdin  --client.url http://127.0.0.1:3100/loki/api/v1/push&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can also add additional labels from command line using:&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;cat my.log | promtail --stdin  --client.url http://127.0.0.1:3100/loki/api/v1/push --client.external-labels=k1=v1,k2=v2&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This will add labels &lt;code&gt;k1&lt;/code&gt; and &lt;code&gt;k2&lt;/code&gt; with respective values &lt;code&gt;v1&lt;/code&gt; and &lt;code&gt;v2&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In pipe mode Promtail also support file configuration using &lt;code&gt;--config.file&lt;/code&gt;, however do note that positions config is not used and
only &lt;strong&gt;the first scrape config is used&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;../configuration/&#34;&gt;&lt;code&gt;static_configs:&lt;/code&gt;&lt;/a&gt; can be used to provide static labels, although the targets property is ignored.&lt;/p&gt;
&lt;p&gt;If you don&amp;rsquo;t provide any &lt;a href=&#34;../configuration/#scrape_configs&#34;&gt;&lt;code&gt;scrape_config:&lt;/code&gt;&lt;/a&gt; a default one is used which will automatically adds the following default labels: &lt;code&gt;{job=&amp;quot;stdin&amp;quot;,hostname=&amp;quot;&amp;lt;detected_hostname&amp;gt;&amp;quot;}&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;For example you could use this config below to parse and add the label &lt;code&gt;level&lt;/code&gt; on all your piped logs:&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;YAML&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-yaml&#34;&gt;clients:
  - url: http://localhost:3100/loki/api/v1/push

scrape_configs:
- job_name: system
  pipeline_stages:
  - regex:
      expression: &amp;#39;(level|lvl|severity)=(?P&amp;lt;level&amp;gt;\\w&amp;#43;)&amp;#39;
  - labels:
      level:
  static_configs:
  - labels:
      job: my-stdin-logs&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&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&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;cat my.log | promtail --config.file promtail.yaml&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;a-tailed-file-is-truncated-while-promtail-is-not-running&#34;&gt;A tailed file is truncated while Promtail is not running&lt;/h2&gt;
&lt;p&gt;Given the following order of events:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Promtail is tailing &lt;code&gt;/app.log&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Promtail current position for &lt;code&gt;/app.log&lt;/code&gt; is &lt;code&gt;100&lt;/code&gt; (byte offset)&lt;/li&gt;
&lt;li&gt;Promtail is stopped&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/app.log&lt;/code&gt; is truncated and new logs are appended to it&lt;/li&gt;
&lt;li&gt;Promtail is restarted&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;When Promtail is restarted, it reads the previous position (&lt;code&gt;100&lt;/code&gt;) from the
positions file. Two scenarios are then possible:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;/app.log&lt;/code&gt; size is less than the position before truncating&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/app.log&lt;/code&gt; size is greater than or equal to the position before truncating&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If the &lt;code&gt;/app.log&lt;/code&gt; file size is less than the previous position, then the file is
detected as truncated and logs will be tailed starting from position &lt;code&gt;0&lt;/code&gt;.
Otherwise, if the &lt;code&gt;/app.log&lt;/code&gt; file size is greater than or equal to the previous
position, Promtail can&amp;rsquo;t detect it was truncated while not running and will
continue tailing the file from position &lt;code&gt;100&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Generally speaking, Promtail uses only the path to the file as key in the
positions file. Whenever Promtail is started, for each file path referenced in
the positions file, Promtail will read the file from the beginning if the file
size is less than the offset stored in the position file, otherwise it will
continue from the offset, regardless the file has been truncated or rolled
multiple times while Promtail was not running.&lt;/p&gt;
&lt;h2 id=&#34;loki-is-unavailable&#34;&gt;Loki is unavailable&lt;/h2&gt;
&lt;p&gt;For each tailing file, Promtail reads a line, process it through the
configured &lt;code&gt;pipeline_stages&lt;/code&gt; and push the log entry to Loki. Log entries are
batched together before getting pushed to Loki, based on the max batch duration
&lt;code&gt;client.batch-wait&lt;/code&gt; and size &lt;code&gt;client.batch-size-bytes&lt;/code&gt;, whichever comes first.&lt;/p&gt;
&lt;p&gt;In case of any error while sending a log entries batch, Promtail adopts a
&amp;ldquo;retry then discard&amp;rdquo; strategy:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Promtail retries to send log entry to the ingester up to &lt;code&gt;max_retries&lt;/code&gt; times&lt;/li&gt;
&lt;li&gt;If all retries fail, Promtail discards the batch of log entries (&lt;em&gt;which will
be lost&lt;/em&gt;) and proceeds with the next one&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can configure the &lt;code&gt;max_retries&lt;/code&gt; and the delay between two retries via the
&lt;code&gt;backoff_config&lt;/code&gt; in the Promtail config file:&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;YAML&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-yaml&#34;&gt;clients:
  - url: INGESTER-URL
    backoff_config:
      min_period: 100ms
      max_period: 10s
      max_retries: 10&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The following table shows an example of the total delay applied by the backoff algorithm
with &lt;code&gt;min_period: 100ms&lt;/code&gt; and &lt;code&gt;max_period: 10s&lt;/code&gt;:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Retry&lt;/th&gt;
              &lt;th&gt;Min delay&lt;/th&gt;
              &lt;th&gt;Max delay&lt;/th&gt;
              &lt;th&gt;Total min delay&lt;/th&gt;
              &lt;th&gt;Total max delay&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;100ms&lt;/td&gt;
              &lt;td&gt;200ms&lt;/td&gt;
              &lt;td&gt;100ms&lt;/td&gt;
              &lt;td&gt;200ms&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;200ms&lt;/td&gt;
              &lt;td&gt;400ms&lt;/td&gt;
              &lt;td&gt;300ms&lt;/td&gt;
              &lt;td&gt;600ms&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;400ms&lt;/td&gt;
              &lt;td&gt;800ms&lt;/td&gt;
              &lt;td&gt;700ms&lt;/td&gt;
              &lt;td&gt;1.4s&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;800ms&lt;/td&gt;
              &lt;td&gt;1.6s&lt;/td&gt;
              &lt;td&gt;1.5s&lt;/td&gt;
              &lt;td&gt;3s&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;5&lt;/td&gt;
              &lt;td&gt;1.6s&lt;/td&gt;
              &lt;td&gt;3.2s&lt;/td&gt;
              &lt;td&gt;3.1s&lt;/td&gt;
              &lt;td&gt;6.2s&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;6&lt;/td&gt;
              &lt;td&gt;3.2s&lt;/td&gt;
              &lt;td&gt;6.4s&lt;/td&gt;
              &lt;td&gt;6.3s&lt;/td&gt;
              &lt;td&gt;12.6s&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;7&lt;/td&gt;
              &lt;td&gt;6.4s&lt;/td&gt;
              &lt;td&gt;10s&lt;/td&gt;
              &lt;td&gt;12.7s&lt;/td&gt;
              &lt;td&gt;22.6s&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;8&lt;/td&gt;
              &lt;td&gt;6.4s&lt;/td&gt;
              &lt;td&gt;10s&lt;/td&gt;
              &lt;td&gt;19.1s&lt;/td&gt;
              &lt;td&gt;32.6s&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;9&lt;/td&gt;
              &lt;td&gt;6.4s&lt;/td&gt;
              &lt;td&gt;10s&lt;/td&gt;
              &lt;td&gt;25.5s&lt;/td&gt;
              &lt;td&gt;42.6s&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;10&lt;/td&gt;
              &lt;td&gt;6.4s&lt;/td&gt;
              &lt;td&gt;10s&lt;/td&gt;
              &lt;td&gt;31.9s&lt;/td&gt;
              &lt;td&gt;52.6s&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;11&lt;/td&gt;
              &lt;td&gt;6.4s&lt;/td&gt;
              &lt;td&gt;10s&lt;/td&gt;
              &lt;td&gt;38.3s&lt;/td&gt;
              &lt;td&gt;62.6s&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;12&lt;/td&gt;
              &lt;td&gt;6.4s&lt;/td&gt;
              &lt;td&gt;10s&lt;/td&gt;
              &lt;td&gt;44.7s&lt;/td&gt;
              &lt;td&gt;72.6s&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;13&lt;/td&gt;
              &lt;td&gt;6.4s&lt;/td&gt;
              &lt;td&gt;10s&lt;/td&gt;
              &lt;td&gt;51.1s&lt;/td&gt;
              &lt;td&gt;82.6s&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;14&lt;/td&gt;
              &lt;td&gt;6.4s&lt;/td&gt;
              &lt;td&gt;10s&lt;/td&gt;
              &lt;td&gt;57.5s&lt;/td&gt;
              &lt;td&gt;92.6s&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;15&lt;/td&gt;
              &lt;td&gt;6.4s&lt;/td&gt;
              &lt;td&gt;10s&lt;/td&gt;
              &lt;td&gt;63.9s&lt;/td&gt;
              &lt;td&gt;102.6s&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;16&lt;/td&gt;
              &lt;td&gt;6.4s&lt;/td&gt;
              &lt;td&gt;10s&lt;/td&gt;
              &lt;td&gt;70.3s&lt;/td&gt;
              &lt;td&gt;112.6s&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;17&lt;/td&gt;
              &lt;td&gt;6.4s&lt;/td&gt;
              &lt;td&gt;10s&lt;/td&gt;
              &lt;td&gt;76.7s&lt;/td&gt;
              &lt;td&gt;122.6s&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;18&lt;/td&gt;
              &lt;td&gt;6.4s&lt;/td&gt;
              &lt;td&gt;10s&lt;/td&gt;
              &lt;td&gt;83.1s&lt;/td&gt;
              &lt;td&gt;132.6s&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;19&lt;/td&gt;
              &lt;td&gt;6.4s&lt;/td&gt;
              &lt;td&gt;10s&lt;/td&gt;
              &lt;td&gt;89.5s&lt;/td&gt;
              &lt;td&gt;142.6s&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;20&lt;/td&gt;
              &lt;td&gt;6.4s&lt;/td&gt;
              &lt;td&gt;10s&lt;/td&gt;
              &lt;td&gt;95.9s&lt;/td&gt;
              &lt;td&gt;152.6s&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;log-entries-pushed-after-a-promtail-crash--panic--abruptly-termination&#34;&gt;Log entries pushed after a Promtail crash / panic / abruptly termination&lt;/h2&gt;
&lt;p&gt;When Promtail shuts down gracefully, it saves the last read offsets in the
positions file, so that on a subsequent restart it will continue tailing logs
without duplicates neither losses.&lt;/p&gt;
&lt;p&gt;In the event of a crash or abruptly termination, Promtail can&amp;rsquo;t save the last
read offsets in the positions file. When restarted, Promtail will read the
positions file saved at the last sync period and will continue tailing the files
from there. This means that if new log entries have been read and pushed to the
ingester between the last sync period and the crash, these log entries will be
sent again to the ingester on Promtail restart.&lt;/p&gt;
&lt;p&gt;If Loki is not configured to 
    &lt;a href=&#34;/docs/loki/v3.6.x/configure/#accept-out-of-order-writes&#34;&gt;accept out-of-order writes&lt;/a&gt;, Loki will reject all log lines received in
what it perceives is out of
order. If Promtail happens to
crash, it may re-send log lines that were sent prior to the crash. The default
behavior of Promtail is to assign a timestamp to logs at the time it read the
entry from the tailed file. This would result in duplicate log lines being sent
to Loki; to avoid this issue, if your tailed file has a timestamp embedded in
the log lines, a &lt;code&gt;timestamp&lt;/code&gt; stage should be added to your pipeline.&lt;/p&gt;
]]></content><description>&lt;h1 id="troubleshooting-promtail">Troubleshooting Promtail&lt;/h1>
&lt;p>This document describes known failure modes of Promtail on edge cases and the adopted trade-offs.&lt;/p>
&lt;div data-shared="promtail-deprecation.md">
&lt;div class="admonition admonition-caution">&lt;blockquote>&lt;p class="title text-uppercase">Caution&lt;/p>&lt;p>Promtail has been deprecated and is in Long-Term Support (LTS) through February 28, 2026. Promtail will reach an End-of-Life (EOL) on March 2, 2026. You can find migration resources &lt;a href="/docs/alloy/latest/set-up/migrate/from-promtail/">here&lt;/a>.&lt;/p></description></item><item><title>Using k6 for load testing</title><link>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/k6/</link><pubDate>Sat, 11 Apr 2026 00:53:11 +0000</pubDate><guid>https://grafana.com/docs/enterprise-logs/v3.6.x/send-data/k6/</guid><content><![CDATA[&lt;h1 id=&#34;using-k6-for-load-testing&#34;&gt;Using k6 for load testing&lt;/h1&gt;
&lt;p&gt;Grafana &lt;a href=&#34;/oss/k6/&#34;&gt;k6&lt;/a&gt; is a modern load-testing tool.
Its clean and approachable scripting &lt;a href=&#34;/docs/k6/latest/javascript-api/&#34;&gt;API&lt;/a&gt;
works locally or in the cloud.
Its configuration makes it flexible.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&#34;https://github.com/grafana/xk6-loki&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;xk6-loki extension&lt;/a&gt; permits pushing logs to and querying logs from a Loki instance.
It acts as a Loki client, simulating real-world load to test the scalability,
reliability, and performance of your Loki installation.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;k6 is written in Golang. &lt;a href=&#34;https://go.dev/doc/install&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Download and install&lt;/a&gt; a Go environment.&lt;/p&gt;
&lt;h2 id=&#34;installation&#34;&gt;Installation&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;xk6-loki&lt;/code&gt; is an extension to the k6 binary.
Build a custom k6 binary that includes the &lt;code&gt;xk6-loki&lt;/code&gt; extension.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Install the &lt;code&gt;xk6&lt;/code&gt; extension bundler:&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;go install go.k6.io/xk6/cmd/xk6@latest&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Check out the &lt;code&gt;grafana/xk6-loki&lt;/code&gt; repository:&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;git clone https://github.com/grafana/xk6-loki
cd xk6-loki&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Build k6 with the extension:&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;make k6&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;usage&#34;&gt;Usage&lt;/h2&gt;
&lt;p&gt;Use the custom-built k6 binary in the same way as a non-custom k6 binary:&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;./k6 run test.js&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;code&gt;test.js&lt;/code&gt; is a Javascript load test.
Refer to the &lt;a href=&#34;/docs/k6/latest/&#34;&gt;k6 documentation&lt;/a&gt; to get started.&lt;/p&gt;
&lt;h3 id=&#34;scripting-api&#34;&gt;Scripting API&lt;/h3&gt;
&lt;p&gt;The custom-built k6 binary provides a Javascript &lt;code&gt;loki&lt;/code&gt; module.&lt;/p&gt;
&lt;p&gt;Your Javascript load test imports the module:&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;js&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-js&#34;&gt;import loki from &amp;#39;k6/x/loki&amp;#39;;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Classes of this module are:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;class&lt;/th&gt;
              &lt;th&gt;description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Config&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;configuration for the &lt;code&gt;Client&lt;/code&gt; class&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Client&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;client for writing and reading logs from Loki&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;&lt;code&gt;Config&lt;/code&gt; and &lt;code&gt;Client&lt;/code&gt; must be called on the k6 init context (see
&lt;a href=&#34;/docs/k6/latest/using-k6/test-lifecycle/&#34;&gt;Test life cycle&lt;/a&gt;) outside of the
default function so the client is only configured once and shared between all
VU iterations.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;Client&lt;/code&gt; class exposes the following instance methods:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;method&lt;/th&gt;
              &lt;th&gt;description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;push()&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;shortcut for &lt;code&gt;pushParameterized(5, 800*1024, 1024*1024)&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;pushParameterized(streams, minSize, maxSize)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;execute push request (
    &lt;a href=&#34;/docs/loki/v3.6.x/reference/loki-http-api/#ingest-logs&#34;&gt;POST /loki/api/v1/push&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;instantQuery(query, limit)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;execute instant query  (
    &lt;a href=&#34;/docs/loki/v3.6.x/reference/loki-http-api/#query-logs-at-a-single-point-in-time&#34;&gt;GET /loki/api/v1/query&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;client.rangeQuery(query, duration, limit)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;execute range query  (
    &lt;a href=&#34;/docs/loki/v3.6.x/reference/loki-http-api/#query-logs-within-a-range-of-time&#34;&gt;GET /loki/api/v1/query_range&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;client.labelsQuery(duration)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;execute labels query  (
    &lt;a href=&#34;/docs/loki/v3.6.x/reference/loki-http-api/#query-labels&#34;&gt;GET /loki/api/v1/labels&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;client.labelValuesQuery(label, duration)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;execute label values query  (
    &lt;a href=&#34;/docs/loki/v3.6.x/reference/loki-http-api/#query-label-values&#34;&gt;GET /loki/api/v1/label/&amp;lt;name&amp;gt;/values&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;client.seriesQuery(matchers, duration)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;execute series query  (
    &lt;a href=&#34;/docs/loki/v3.6.x/reference/loki-http-api/#query-streams&#34;&gt;GET /loki/api/v1/series&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;&lt;strong&gt;Javascript load test example:&lt;/strong&gt;&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;js&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-js&#34;&gt;import loki from &amp;#39;k6/x/loki&amp;#39;;

const timeout = 5000; // ms
const conf = loki.Config(&amp;#34;http://localhost:3100&amp;#34;, timeout);
const client = loki.Client(conf);

export default () =&amp;gt; {
   client.pushParameterized(2, 512*1024, 1024*1024);
};&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Refer to
&lt;a href=&#34;https://github.com/grafana/xk6-loki#javascript-api&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;grafana/xk6-loki&lt;/a&gt;
for the complete &lt;code&gt;k6/x/loki&lt;/code&gt; module API reference.&lt;/p&gt;
]]></content><description>&lt;h1 id="using-k6-for-load-testing">Using k6 for load testing&lt;/h1>
&lt;p>Grafana &lt;a href="/oss/k6/">k6&lt;/a> is a modern load-testing tool.
Its clean and approachable scripting &lt;a href="/docs/k6/latest/javascript-api/">API&lt;/a>
works locally or in the cloud.
Its configuration makes it flexible.&lt;/p></description></item></channel></rss>