<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Fluent Bit on Grafana Labs</title><link>https://grafana.com/docs/loki/v3.7.x/send-data/fluentbit/</link><description>Recent content in Fluent Bit on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/loki/v3.7.x/send-data/fluentbit/index.xml" rel="self" type="application/rss+xml"/><item><title>Sending logs to Loki using Fluent Bit tutorial</title><link>https://grafana.com/docs/loki/v3.7.x/send-data/fluentbit/fluent-bit-loki-tutorial/</link><pubDate>Thu, 09 Apr 2026 02:28:18 +0000</pubDate><guid>https://grafana.com/docs/loki/v3.7.x/send-data/fluentbit/fluent-bit-loki-tutorial/</guid><content><![CDATA[&lt;!-- INTERACTIVE page intro.md START --&gt;
&lt;h1 id=&#34;sending-logs-to-loki-using-fluent-bit-tutorial&#34;&gt;Sending logs to Loki using Fluent Bit tutorial&lt;/h1&gt;
&lt;p&gt;In this tutorial, you will learn how to send logs to Loki using Fluent Bit. Fluent Bit is a lightweight and fast log processor and forwarder that can collect, process, and deliver logs to various destinations. We will use the official Fluent Bit Loki output plugin to send logs to Loki.&lt;/p&gt;
&lt;!-- INTERACTIVE ignore START --&gt;
&lt;h2 id=&#34;dependencies&#34;&gt;Dependencies&lt;/h2&gt;
&lt;p&gt;Before you begin, ensure you have the following to run the demo:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Docker&lt;/li&gt;
&lt;li&gt;Docker Compose&lt;/li&gt;
&lt;/ul&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;Alternatively, you can try out this example in our interactive learning environment: &lt;a href=&#34;https://killercoda.com/grafana-labs/course/loki/fluentbit-loki-tutorial&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Sending logs to Loki using Fluent Bit tutorial&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s a fully configured environment with all the dependencies already installed.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/loki/loki-ile.svg&#34;
  alt=&#34;Interactive&#34;/&gt;&lt;/p&gt;
&lt;p&gt;Provide feedback, report bugs, and raise issues in the &lt;a href=&#34;https://github.com/grafana/killercoda&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Grafana Killercoda repository&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;!-- INTERACTIVE ignore END --&gt;
&lt;h2 id=&#34;scenario&#34;&gt;Scenario&lt;/h2&gt;
&lt;p&gt;In this scenario, we have a microservices application called the Carnivorous Greenhouse. This application consists of the following services:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;User Service:&lt;/strong&gt; Manages user data and authentication for the application. Such as creating users and logging in.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Plant Service:&lt;/strong&gt; Manages the creation of new plants and updates other services when a new plant is created.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Simulation Service:&lt;/strong&gt; Generates sensor data for each plant.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Websocket Service:&lt;/strong&gt; Manages the websocket connections for the application.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bug Service:&lt;/strong&gt; A service that when enabled, randomly causes services to fail and generate additional logs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Main App:&lt;/strong&gt; The main application that ties all the services together.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Database:&lt;/strong&gt; A database that stores user and plant data.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each service has been instrumented with the Fluent Bit logging framework to generate logs. If you would like to learn more about how the Carnivorous Greenhouse application was instrumented with Fluent Bit, refer to the &lt;a href=&#34;https://github.com/grafana/loki-fundamentals/blob/fluentbit-official/greenhouse/loggingfw.py&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Carnivorous Greenhouse repository&lt;/a&gt;.&lt;/p&gt;
&lt;!-- INTERACTIVE page intro.md END --&gt;
&lt;!-- INTERACTIVE page step1.md START --&gt;
&lt;h2 id=&#34;step-1-environment-setup&#34;&gt;Step 1: Environment setup&lt;/h2&gt;
&lt;p&gt;In this step, we will set up our environment by cloning the repository that contains our demo application and spinning up our observability stack using Docker Compose.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;To get started, clone the repository that contains our demo application:&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 -b fluentbit-official  https://github.com/grafana/loki-fundamentals.git&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Next we will spin up our observability stack using Docker Compose:&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 compose -f loki-fundamentals/docker-compose.yml up -d&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This will spin up the following services:&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;✔ Container loki-fundamentals-grafana-1       Started                                                        
✔ Container loki-fundamentals-loki-1          Started                        
✔ Container loki-fundamentals-fluent-bit-1    Started&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Once we have finished configuring the Fluent Bit agent and sending logs to Loki, we will be able to view the logs in Grafana. To check if Grafana is up and running, navigate to the following URL: &lt;a href=&#34;http://localhost:3000&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000&lt;/a&gt;&lt;/p&gt;
&lt;!-- INTERACTIVE page step1.md END --&gt;
&lt;!-- INTERACTIVE page step2.md START --&gt;
&lt;h2 id=&#34;step-2-configure-fluent-bit-to-send-logs-to-loki&#34;&gt;Step 2: Configure Fluent Bit to send logs to Loki&lt;/h2&gt;
&lt;p&gt;To configure Fluent Bit to receive logs from our application, we need to provide a configuration file. This configuration file will define the components and their relationships. We will build the entire observability pipeline within this configuration file.&lt;/p&gt;
&lt;h3 id=&#34;open-your-code-editor-and-locate-the-fluent-bitconf-file&#34;&gt;Open your code editor and locate the &lt;code&gt;fluent-bit.conf&lt;/code&gt; file&lt;/h3&gt;
&lt;p&gt;Fluent Bit requires a configuration file to define the components and their relationships. The configuration file is written using Fluent Bit configuration syntax. We will build the entire observability pipeline within this configuration file. To start, we will open the &lt;code&gt;fluent-bit.conf&lt;/code&gt; file in the code editor:&lt;/p&gt;

&lt;!-- INTERACTIVE ignore START --&gt;
&lt;ol&gt;
&lt;li&gt;Open the &lt;code&gt;loki-fundamentals&lt;/code&gt; directory in a code editor of your choice.&lt;/li&gt;
&lt;li&gt;Locate the &lt;code&gt;fluent-bit.conf&lt;/code&gt; file in the &lt;code&gt;loki-fundamentals&lt;/code&gt; directory (Top level directory).&lt;/li&gt;
&lt;li&gt;Click on the &lt;code&gt;fluent-bit.conf&lt;/code&gt; file to open it in the code editor.&lt;/li&gt;
&lt;/ol&gt;
&lt;!-- INTERACTIVE ignore END --&gt;
&lt;p&gt;You will copy all of the configuration snippets into the &lt;code&gt;fluent-bit.conf&lt;/code&gt; file.&lt;/p&gt;
&lt;h3 id=&#34;receiving-fluent-bit-protocol-logs&#34;&gt;Receiving Fluent Bit protocol logs&lt;/h3&gt;
&lt;p&gt;The first step is to configure Fluent Bit to receive logs from the Carnivorous Greenhouse application. Since the application is instrumented with Fluent Bit logging framework, it will send logs using the forward protocol (unique to Fluent Bit). We will use the &lt;code&gt;forward&lt;/code&gt; input plugin to receive logs from the application.&lt;/p&gt;
&lt;p&gt;Now add the following configuration to the &lt;code&gt;fluent-bit.conf&lt;/code&gt; 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;conf&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-conf&#34;&gt;[INPUT]
    Name              forward
    Listen            0.0.0.0
    Port              24224&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In this configuration:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Name&lt;/code&gt;: The name of the input plugin. In this case, we are using the &lt;code&gt;forward&lt;/code&gt; input plugin.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Listen&lt;/code&gt;: The IP address to listen on. In this case, we are listening on all IP addresses.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Port&lt;/code&gt;: The port to listen on. In this case, we are listening on port &lt;code&gt;24224&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For more information on the &lt;code&gt;forward&lt;/code&gt; input plugin, see the &lt;a href=&#34;https://docs.fluentbit.io/manual/pipeline/inputs/forward&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Fluent Bit Forward documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;export-logs-to-loki-using-the-official-loki-output-plugin&#34;&gt;Export logs to Loki using the official Loki output plugin&lt;/h3&gt;
&lt;p&gt;Lastly, we will configure Fluent Bit to export logs to Loki using the official Loki output plugin. The Loki output plugin allows you to send logs or events to a Loki service. It supports data enrichment with Kubernetes labels, custom label keys, and structured metadata.&lt;/p&gt;
&lt;p&gt;Add the following configuration to the &lt;code&gt;fluent-bit.conf&lt;/code&gt; 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;conf&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-conf&#34;&gt;[OUTPUT]
    name   loki
    match  service.**
    host   loki
    port   3100
    labels agent=fluent-bit
    label_map_path /fluent-bit/etc/conf/logmap.json&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In this configuration:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;name&lt;/code&gt;: The name of the output plugin. In this case, we are using the &lt;code&gt;loki&lt;/code&gt; output plugin.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;match&lt;/code&gt;: The tag to match. In this case, we are matching all logs with the tag &lt;code&gt;service.**&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;host&lt;/code&gt;: The hostname of the Loki service. In this case, we are using the hostname &lt;code&gt;loki&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;port&lt;/code&gt;: The port of the Loki service. In this case, we are using port &lt;code&gt;3100&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;labels&lt;/code&gt;: Additional labels to add to the logs. In this case, we are adding the label &lt;code&gt;agent=fluent-bit&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;label_map_path&lt;/code&gt;: The path to the label map file. In this case, we are using the file &lt;code&gt;logmap.json&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For more information on the &lt;code&gt;loki&lt;/code&gt; output plugin, see the &lt;a href=&#34;https://docs.fluentbit.io/manual/pipeline/outputs/loki&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Fluent Bit Loki documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h4 id=&#34;logmapjson-file&#34;&gt;&lt;code&gt;logmap.json&lt;/code&gt; file&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;logmap.json&lt;/code&gt; file is used to map the log fields to the Loki labels. In this tutorial we have pre-filled the &lt;code&gt;logmap.json&lt;/code&gt; file with the following 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;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;service&amp;#34;: &amp;#34;service_name&amp;#34;,
&amp;#34;instance_id&amp;#34;: &amp;#34;instance_id&amp;#34;
 }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This configuration maps the &lt;code&gt;service&lt;/code&gt; field to the Loki label &lt;code&gt;service_name&lt;/code&gt; and the &lt;code&gt;instance_id&lt;/code&gt; field to the Loki label &lt;code&gt;instance_id&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;reload-the-fluent-bit-configuration&#34;&gt;Reload the Fluent Bit configuration&lt;/h3&gt;
&lt;p&gt;After adding the configuration to the &lt;code&gt;fluent-bit.conf&lt;/code&gt; file, you will need to reload the Fluent Bit configuration. To reload the configuration, 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;docker restart loki-fundamentals-fluent-bit-1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;To verify that the configuration has been loaded successfully, you can check the Fluent Bit logs 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 logs loki-fundamentals-fluent-bit-1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;stuck-need-help&#34;&gt;Stuck? Need help?&lt;/h2&gt;
&lt;p&gt;If you get stuck or need help creating the configuration, you can copy and replace the entire &lt;code&gt;config.alloy&lt;/code&gt; using the completed configuration 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;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;cp loki-fundamentals/completed/fluent-bit.conf loki-fundamentals/fluent-bit.conf
docker restart loki-fundamentals-fluent-bit-1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- INTERACTIVE page step2.md END --&gt;
&lt;!-- INTERACTIVE page step3.md START --&gt;
&lt;h2 id=&#34;step-3-start-the-carnivorous-greenhouse&#34;&gt;Step 3: Start the Carnivorous Greenhouse&lt;/h2&gt;
&lt;p&gt;In this step, we will start the Carnivorous Greenhouse application. To start the application, run the following command:&lt;/p&gt;
&lt;!-- INTERACTIVE ignore START --&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;This docker-compose file relies on the &lt;code&gt;loki-fundamentals_loki&lt;/code&gt; Docker network. If you have not started the observability stack, you will need to start it first.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;!-- INTERACTIVE ignore END --&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 compose -f loki-fundamentals/greenhouse/docker-compose-micro.yml up -d --build &lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This will start the following services:&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; ✔ Container greenhouse-db-1                 Started                                                         
 ✔ Container greenhouse-websocket_service-1  Started 
 ✔ Container greenhouse-bug_service-1        Started
 ✔ Container greenhouse-user_service-1       Started
 ✔ Container greenhouse-plant_service-1      Started
 ✔ Container greenhouse-simulation_service-1 Started
 ✔ Container greenhouse-main_app-1           Started&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Once started, you can access the Carnivorous Greenhouse application at &lt;a href=&#34;http://localhost:5005&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:5005&lt;/a&gt;. Generate some logs by interacting with the application in the following ways:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a user.&lt;/li&gt;
&lt;li&gt;Log in.&lt;/li&gt;
&lt;li&gt;Create a few plants to monitor.&lt;/li&gt;
&lt;li&gt;Enable bug mode to activate the bug service. This will cause services to fail and generate additional logs.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Finally to view the logs in Loki, navigate to the Loki Logs Explore view in Grafana at &lt;a href=&#34;http://localhost:3000/a/grafana-lokiexplore-app/explore&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/a/grafana-lokiexplore-app/explore&lt;/a&gt;.&lt;/p&gt;
&lt;!-- INTERACTIVE page step3.md END --&gt;
&lt;!-- INTERACTIVE page finish.md START --&gt;
&lt;h2 id=&#34;summary&#34;&gt;Summary&lt;/h2&gt;
&lt;p&gt;In this tutorial, you learned how to send logs to Loki using Fluent Bit. You configured Fluent Bit to receive logs from the Carnivorous Greenhouse application and export logs to Loki using the official Loki output plugin. Where to next?&lt;/p&gt;

&lt;h2 id=&#34;further-reading&#34;&gt;Further reading&lt;/h2&gt;
&lt;p&gt;For more information on Fluent Bit, refer to the following resources:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://docs.fluentbit.io/manual/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Fluent Bit documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;/docs/loki/latest/send-data/fluentbit/&#34;&gt;Other examples of Fluent Bit configurations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;complete-metrics-logs-traces-and-profiling-example&#34;&gt;Complete metrics, logs, traces, and profiling example&lt;/h2&gt;
&lt;p&gt;If you would like to use a demo that includes Mimir, Loki, Tempo, and Grafana, you can use &lt;a href=&#34;https://github.com/grafana/intro-to-mlt&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Introduction to Metrics, Logs, Traces, and Profiling in Grafana&lt;/a&gt;. &lt;code&gt;Intro-to-mltp&lt;/code&gt; provides a self-contained environment for learning about Mimir, Loki, Tempo, and Grafana.&lt;/p&gt;
&lt;p&gt;The project includes detailed explanations of each component and annotated configurations for a single-instance deployment. Data from &lt;code&gt;intro-to-mltp&lt;/code&gt; can also be pushed to Grafana Cloud.&lt;/p&gt;
&lt;!-- INTERACTIVE page finish.md END --&gt;
]]></content><description>&lt;!-- INTERACTIVE page intro.md START -->
&lt;h1 id="sending-logs-to-loki-using-fluent-bit-tutorial">Sending logs to Loki using Fluent Bit tutorial&lt;/h1>
&lt;p>In this tutorial, you will learn how to send logs to Loki using Fluent Bit. Fluent Bit is a lightweight and fast log processor and forwarder that can collect, process, and deliver logs to various destinations. We will use the official Fluent Bit Loki output plugin to send logs to Loki.&lt;/p></description></item><item><title>Fluent Bit community plugin</title><link>https://grafana.com/docs/loki/v3.7.x/send-data/fluentbit/community-plugin/</link><pubDate>Thu, 09 Apr 2026 02:28:18 +0000</pubDate><guid>https://grafana.com/docs/loki/v3.7.x/send-data/fluentbit/community-plugin/</guid><content><![CDATA[&lt;h1 id=&#34;fluent-bit-community-plugin&#34;&gt;Fluent Bit community plugin&lt;/h1&gt;


&lt;div class=&#34;admonition admonition-warning&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Warning&lt;/p&gt;&lt;p&gt;We recommend using the official 
    &lt;a href=&#34;/docs/loki/v3.7.x/send-data/fluentbit/fluent-bit-plugin/&#34;&gt;Fluent Bit Loki plugin&lt;/a&gt;. The official plugin is more feature-rich and has better support for features such as structured metadata. The community plugin is still available for use, but it&amp;rsquo;s no longer actively maintained.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;The Fluent Bit community plugin by Grafana Labs (&lt;code&gt;grafana-loki&lt;/code&gt;) provided an alternative way to send logs to Loki. Although very similar to the 
    &lt;a href=&#34;/docs/loki/v3.7.x/send-data/fluentbit/fluent-bit-plugin/&#34;&gt;official plugin&lt;/a&gt; there are some differences in the configuration options. This page provides instructions for how to install, configure, and use the Fluent Bit community plugin to send logs to Loki. Although the plugin is no longer actively maintained, this documentation is still available for reference.&lt;/p&gt;
&lt;iframe width=&#34;560&#34; height=&#34;315&#34; src=&#39;https://www.youtube.com/embed/s43IBSVyTpQ&#39; title=&#34;YouTube video player&#34; frameborder=&#34;0&#34; allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; allowfullscreen&gt;&lt;/iframe&gt;
&lt;h2 id=&#34;usage&#34;&gt;Usage&lt;/h2&gt;
&lt;h3 id=&#34;docker&#34;&gt;Docker&lt;/h3&gt;
&lt;p&gt;You can run a Fluent Bit container with Loki output plugin pre-installed using our &lt;a href=&#34;https://hub.docker.com/r/grafana/fluent-bit-plugin-loki&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker Hub&lt;/a&gt; image:&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:/var/log \
    -e LOG_PATH=&amp;#34;/var/log/*.log&amp;#34; -e LOKI_URL=&amp;#34;http://localhost:3100/loki/api/v1/push&amp;#34; \
    grafana/fluent-bit-plugin-loki:latest&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Or, an alternative is to run the fluent-bit container using &lt;a href=&#34;https://hub.docker.com/r/fluent/fluent-bit&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker Hub&lt;/a&gt; image:&lt;/p&gt;
&lt;h3 id=&#34;docker-container-logs&#34;&gt;Docker container logs&lt;/h3&gt;
&lt;p&gt;To ship logs from Docker containers to Grafana Cloud using Fluent Bit, you can use the Fluent Bit Docker image and configure it to forward logs directly to Grafana Loki. Below is a step-by-step guide on setting up Fluent Bit for this purpose.&lt;/p&gt;
&lt;h4 id=&#34;prerequisites&#34;&gt;Prerequisites&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Docker is installed on your machine.&lt;/li&gt;
&lt;li&gt;Running instance of Loki OSS.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;configuration&#34;&gt;Configuration&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create a Fluent Bit configuration file named &lt;code&gt;fluent-bit.conf&lt;/code&gt; with the following content, which defines the input from Docker container logs and sets up the output to send logs to your Grafana Cloud 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;ini&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-ini&#34;&gt;[SERVICE]
    Flush        1
    Log_Level    info

[INPUT]
    Name     tail
    Path     /var/lib/docker/containers/*/*.log
    Parser   docker
    Tag      docker.*

[OUTPUT]
    Name         grafana-loki
    Match        *
    Url          http://localhost:3100/loki/api/v1/push
    Labels       {job=&amp;#34;fluentbit&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;kubernetes&#34;&gt;Kubernetes&lt;/h3&gt;
&lt;p&gt;You can run Fluent Bit as a &lt;a href=&#34;https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;daemonset&lt;/a&gt; to collect all your Kubernetes workload logs.&lt;/p&gt;
&lt;p&gt;To do so you can use the &lt;a href=&#34;https://github.com/fluent/helm-charts&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Fluent Bit Helm chart&lt;/a&gt; with the following &lt;code&gt;values.yaml&lt;/code&gt; changing the value of &lt;code&gt;FLUENT_LOKI_URL&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;image:
  # Here we use the Docker image which has the plugin installed
  repository: grafana/fluent-bit-plugin-loki
  tag: main-e2ed1c0

args:
  - &amp;#34;-e&amp;#34;
  - &amp;#34;/fluent-bit/bin/out_grafana_loki.so&amp;#34;
  - --workdir=/fluent-bit/etc
  - --config=/fluent-bit/etc/conf/fluent-bit.conf

env:
  # Note that for security reasons you should fetch the credentials through a Kubernetes Secret https://kubernetes.io/docs/concepts/configuration/secret/ . You may use the envFrom for this.
  - name: FLUENT_LOKI_URL
    value: https://user:pass@your-loki.endpoint/loki/api/v1/push

config:
  inputs: |
    [INPUT]
        Name tail
        Tag kube.*
        Path /var/log/containers/*.log
        # Be aware that local clusters like docker-desktop or kind use the docker log format and not the cri (https://docs.fluentbit.io/manual/installation/kubernetes#container-runtime-interface-cri-parser)
        multiline.parser docker, cri
        Mem_Buf_Limit 5MB
        Skip_Long_Lines On

  outputs: |
    [Output]
        Name grafana-loki
        Match kube.*
        Url ${FLUENT_LOKI_URL}
        Labels {job=&amp;#34;fluent-bit&amp;#34;}
        LabelKeys level,app # this sets the values for actual Loki streams and the other labels are converted to structured_metadata https://grafana.com/docs/loki/&amp;lt;LOKI_VERSION&amp;gt;/get-started/labels/structured-metadata/
        BatchWait 1
        BatchSize 1001024
        LineFormat json
        LogLevel info
        AutoKubernetesLabels true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&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 fluent https://fluent.github.io/helm-charts
helm repo update
helm install fluent-bit fluent/fluent-bit -f values.yaml&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;By default it will collect all containers logs and extract labels from Kubernetes API (&lt;code&gt;container_name&lt;/code&gt;, &lt;code&gt;namespace&lt;/code&gt;, etc.).&lt;/p&gt;
&lt;p&gt;If you also want to host your Loki instance inside the cluster install the 
    &lt;a href=&#34;/docs/loki/v3.7.x/setup/install/helm/&#34;&gt;official Loki Helm chart&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;aws-elastic-container-service-ecs&#34;&gt;AWS Elastic Container Service (ECS)&lt;/h3&gt;
&lt;p&gt;You can use the fluent-bit Loki Docker image as a Firelens log router in AWS ECS.
For more information about this see the &lt;a href=&#34;https://docs.aws.amazon.com/AmazonECS/latest/developerguide/firelens-using-fluentbit.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;AWS ECS documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;local&#34;&gt;Local&lt;/h3&gt;
&lt;p&gt;First, you need to follow the &lt;a href=&#34;https://github.com/grafana/loki/blob/main/clients/cmd/fluent-bit/README.md&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;instructions&lt;/a&gt; in order to build the plugin dynamic library.&lt;/p&gt;
&lt;p&gt;Assuming you have Fluent Bit installed in your &lt;code&gt;$PATH&lt;/code&gt; you can run the plugin 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;fluent-bit -e /path/to/built/out_grafana_loki.so -c fluent-bit.conf&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can also adapt your plugins.conf, removing the need to change the command line options:&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;conf&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-conf&#34;&gt;[PLUGINS]
    Path /path/to/built/out_grafana_loki.so&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;configuration-options&#34;&gt;Configuration options&lt;/h2&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;Key&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Url&lt;/td&gt;
              &lt;td&gt;Url of Loki server API endpoint.&lt;/td&gt;
              &lt;td&gt;http://localhost:3100/loki/api/v1/push&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;TenantID&lt;/td&gt;
              &lt;td&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 &lt;code&gt;X-Scope-OrgID&lt;/code&gt; header is sent.&lt;/td&gt;
              &lt;td&gt;&amp;quot;&amp;quot;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;BatchWait&lt;/td&gt;
              &lt;td&gt;Time to wait before send a log batch to Loki, full or not.&lt;/td&gt;
              &lt;td&gt;1s&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;BatchSize&lt;/td&gt;
              &lt;td&gt;Log batch size to send a log batch to Loki (unit: Bytes).&lt;/td&gt;
              &lt;td&gt;10 KiB (10 * 1024 Bytes)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Timeout&lt;/td&gt;
              &lt;td&gt;Maximum time to wait for Loki server to respond to a request.&lt;/td&gt;
              &lt;td&gt;10s&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;MinBackoff&lt;/td&gt;
              &lt;td&gt;Initial backoff time between retries.&lt;/td&gt;
              &lt;td&gt;500ms&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;MaxBackoff&lt;/td&gt;
              &lt;td&gt;Maximum backoff time between retries.&lt;/td&gt;
              &lt;td&gt;5m&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;MaxRetries&lt;/td&gt;
              &lt;td&gt;Maximum number of retries when sending batches. Setting it to &lt;code&gt;0&lt;/code&gt; will retry indefinitely.&lt;/td&gt;
              &lt;td&gt;10&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Labels&lt;/td&gt;
              &lt;td&gt;Labels for API requests.&lt;/td&gt;
              &lt;td&gt;{job=&amp;ldquo;fluent-bit&amp;rdquo;}&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;LogLevel&lt;/td&gt;
              &lt;td&gt;LogLevel for plugin logger.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;info&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;RemoveKeys&lt;/td&gt;
              &lt;td&gt;Specify removing keys.&lt;/td&gt;
              &lt;td&gt;none&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;AutoKubernetesLabels&lt;/td&gt;
              &lt;td&gt;If set to &lt;code&gt;true&lt;/code&gt;, it will add all Kubernetes labels to Loki labels.&lt;/td&gt;
              &lt;td&gt;false&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;LabelKeys&lt;/td&gt;
              &lt;td&gt;Comma separated list of keys to use as stream labels. All other keys will be placed into the log line. LabelKeys is deactivated when using &lt;code&gt;LabelMapPath&lt;/code&gt; label mapping configuration.&lt;/td&gt;
              &lt;td&gt;none&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;LineFormat&lt;/td&gt;
              &lt;td&gt;Format to use when flattening the record to a log line. Valid values are &lt;code&gt;json&lt;/code&gt; or &lt;code&gt;key_value&lt;/code&gt;. If set to &lt;code&gt;json&lt;/code&gt; the log line sent to Loki will be the fluentd record (excluding any keys extracted out as labels) dumped as json. If set to &lt;code&gt;key_value&lt;/code&gt;, the log line will be each item in the record concatenated together (separated by a single space) in the format &amp;lt;key&amp;gt;=&amp;lt;value&amp;gt;.&lt;/td&gt;
              &lt;td&gt;json&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;DropSingleKey&lt;/td&gt;
              &lt;td&gt;If set to true and after extracting label_keys a record only has a single key remaining, the log line sent to Loki will just be the value of the record key.&lt;/td&gt;
              &lt;td&gt;true&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;LabelMapPath&lt;/td&gt;
              &lt;td&gt;Path to a json file defining how to transform nested records.&lt;/td&gt;
              &lt;td&gt;none&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Buffer&lt;/td&gt;
              &lt;td&gt;Enable buffering mechanism.&lt;/td&gt;
              &lt;td&gt;false&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;BufferType&lt;/td&gt;
              &lt;td&gt;Specify the buffering mechanism to use (currently only &lt;code&gt;dque&lt;/code&gt; is implemented).&lt;/td&gt;
              &lt;td&gt;dque&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;DqueDir&lt;/td&gt;
              &lt;td&gt;Path to the directory for queued logs.&lt;/td&gt;
              &lt;td&gt;/tmp/flb-storage/loki&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;DqueSegmentSize&lt;/td&gt;
              &lt;td&gt;Segment size in terms of number of records per segment.&lt;/td&gt;
              &lt;td&gt;500&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;DqueSync&lt;/td&gt;
              &lt;td&gt;Whether to fsync each queue change. Specify no fsync with &lt;code&gt;normal&lt;/code&gt;, and fsync with &lt;code&gt;full&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;normal&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;DqueName&lt;/td&gt;
              &lt;td&gt;Queue name, must be unique per output.&lt;/td&gt;
              &lt;td&gt;dque&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;labels&#34;&gt;Labels&lt;/h3&gt;
&lt;p&gt;Labels, for example &lt;code&gt;{container_name=&amp;quot;nginx&amp;quot;, cluster=&amp;quot;us-west1&amp;quot;}&lt;/code&gt;, are used to 
    &lt;a href=&#34;/docs/loki/v3.7.x/query/&#34;&gt;query logs&lt;/a&gt;.  Labels are usually metadata about the workload producing the log stream (&lt;code&gt;instance&lt;/code&gt;, &lt;code&gt;container_name&lt;/code&gt;, &lt;code&gt;region&lt;/code&gt;, &lt;code&gt;cluster&lt;/code&gt;, &lt;code&gt;level&lt;/code&gt;). In Loki labels are indexed, so you should be cautious when choosing them. High cardinality label values can have drastic impact on query performance.&lt;/p&gt;
&lt;p&gt;You can use the config parameters &lt;code&gt;Labels&lt;/code&gt;, &lt;code&gt;RemoveKeys&lt;/code&gt; , &lt;code&gt;LabelKeys&lt;/code&gt; and &lt;code&gt;LabelMapPath&lt;/code&gt; to instruct the output plugin how to perform labels extraction from your log entries or to add static labels to all log entries.&lt;/p&gt;
&lt;h3 id=&#34;autokuberneteslabels&#34;&gt;AutoKubernetesLabels&lt;/h3&gt;
&lt;p&gt;If set to &lt;code&gt;true&lt;/code&gt;, &lt;code&gt;AutoKubernetesLabels&lt;/code&gt; will add all Kubernetes labels to Loki labels automatically and ignore parameters &lt;code&gt;LabelKeys&lt;/code&gt;, &lt;code&gt;LabelMapPath&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;labelmappath&#34;&gt;LabelMapPath&lt;/h3&gt;
&lt;p&gt;When using the &lt;code&gt;Parser&lt;/code&gt; and &lt;code&gt;Filter&lt;/code&gt; plugins Fluent Bit can extract and add data to the current record/log data. While Loki labels are key value pairs, record data can be nested structures.
You can pass a JSON file that defines how to extract labels from each record. Each JSON key from the file will be matched with the log record to find label values. Values from the configuration are used as label names.&lt;/p&gt;
&lt;p&gt;Considering the record 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;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;kubernetes&amp;#34;: {
    &amp;#34;container_name&amp;#34;: &amp;#34;myapp&amp;#34;,
    &amp;#34;pod_name&amp;#34;: &amp;#34;myapp-xxx&amp;#34;,
    &amp;#34;namespace_name&amp;#34;: &amp;#34;prod&amp;#34;,
    &amp;#34;labels&amp;#34; : {
        &amp;#34;team&amp;#34;: &amp;#34;x-men&amp;#34;
    }
  },
  &amp;#34;HOSTNAME&amp;#34;: &amp;#34;docker-desktop&amp;#34;,
  &amp;#34;log&amp;#34; : &amp;#34;a log line&amp;#34;,
  &amp;#34;time&amp;#34;: &amp;#34;20190926T152206Z&amp;#34;
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;and a LabelMap file as follows :&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;kubernetes&amp;#34;: {
    &amp;#34;container_name&amp;#34;: &amp;#34;container&amp;#34;,
    &amp;#34;pod_name&amp;#34;: &amp;#34;pod&amp;#34;,
    &amp;#34;namespace_name&amp;#34;: &amp;#34;namespace&amp;#34;,
    &amp;#34;labels&amp;#34; : {
        &amp;#34;team&amp;#34;: &amp;#34;team&amp;#34;
    }
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The labels extracted will be &lt;code&gt;{team=&amp;quot;x-men&amp;quot;, container=&amp;quot;myapp&amp;quot;, pod=&amp;quot;myapp-xxx&amp;quot;, namespace=&amp;quot;prod&amp;quot;}&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you don&amp;rsquo;t want the &lt;code&gt;kubernetes&lt;/code&gt; and &lt;code&gt;HOSTNAME&lt;/code&gt; fields to appear in the log line you can use the &lt;code&gt;RemoveKeys&lt;/code&gt; configuration field. For example, &lt;code&gt;RemoveKeys kubernetes,HOSTNAME&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;buffering&#34;&gt;Buffering&lt;/h3&gt;
&lt;p&gt;Buffering refers to the ability to store the records somewhere, and while they are processed and delivered, still be able to continue storing more records. The Loki output plugin can be blocked by the Loki client because of its design:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If the BatchSize is over the limit, the output plugin pauses receiving new records until the pending batch is successfully sent to the server&lt;/li&gt;
&lt;li&gt;If the Loki server is unreachable (retry 429s, 500s and connection-level errors), the output plugin blocks new records until the Loki server is available again, and the pending batch is successfully sent to the server or as long as the maximum number of attempts has been reached within configured back-off mechanism&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The blocking state with some of the input plugins is not acceptable, because it can have an undesirable side effect on the part that generates the logs. Fluent Bit implements a buffering mechanism that is based on parallel processing. Therefore, it cannot send logs in order. There are two ways of handling the out-of-order logs:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Configure Loki to 
    &lt;a href=&#34;/docs/loki/v3.7.x/configure/#accept-out-of-order-writes&#34;&gt;accept out-of-order writes&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Configure the Loki output plugin to use the buffering mechanism based on &lt;a href=&#34;https://github.com/joncrlsn/dque&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;dque&lt;/code&gt;&lt;/a&gt;, which is compatible with the Loki server strict time ordering:&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;properties&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-properties&#34;&gt;[Output]
    Name grafana-loki
    Match *
    Url http://localhost:3100/loki/api/v1/push
    Buffer true
    DqueSegmentSize 8096
    DqueDir /tmp/flb-storage/buffer
    DqueName loki.0&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;configuration-examples&#34;&gt;Configuration examples&lt;/h3&gt;
&lt;p&gt;To configure the Loki output plugin add this section to your luent-bit.conf 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;properties&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-properties&#34;&gt;[Output]
    Name grafana-loki
    Match *
    Url http://localhost:3100/loki/api/v1/push
    BatchWait 1s
    BatchSize 30720
    # (30KiB)
    Labels {test=&amp;#34;fluent-bit-go&amp;#34;, lang=&amp;#34;Golang&amp;#34;}
    RemoveKeys key1,key2
    LabelKeys key3,key4
    LineFormat key_value&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&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;properties&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-properties&#34;&gt;[Output]
    Name grafana-loki
    Match *
    Url http://localhost:3100/loki/api/v1/push
    BatchWait 1s
    BatchSize 30720 # (30KiB)
    AutoKubernetesLabels true
    RemoveKeys key1,key2&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;A full &lt;a href=&#34;https://github.com/grafana/loki/blob/main/clients/cmd/fluent-bit/fluent-bit.conf&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;example configuration file&lt;/a&gt; is also available in the Loki repository.&lt;/p&gt;
&lt;h3 id=&#34;running-multiple-plugin-instances&#34;&gt;Running multiple plugin instances&lt;/h3&gt;
&lt;p&gt;You can run multiple plugin instances in the same fluent-bit process, for example if you want to push to different Loki servers or route logs into different Loki tenant IDs. To do so, add additional &lt;code&gt;[Output]&lt;/code&gt; sections.&lt;/p&gt;
]]></content><description>&lt;h1 id="fluent-bit-community-plugin">Fluent Bit community plugin&lt;/h1>
&lt;div class="admonition admonition-warning">&lt;blockquote>&lt;p class="title text-uppercase">Warning&lt;/p>&lt;p>We recommend using the official
&lt;a href="/docs/loki/v3.7.x/send-data/fluentbit/fluent-bit-plugin/">Fluent Bit Loki plugin&lt;/a>. The official plugin is more feature-rich and has better support for features such as structured metadata. The community plugin is still available for use, but it&amp;rsquo;s no longer actively maintained.&lt;/p></description></item><item><title>Fluent Bit Loki output plugin</title><link>https://grafana.com/docs/loki/v3.7.x/send-data/fluentbit/fluent-bit-plugin/</link><pubDate>Thu, 09 Apr 2026 02:28:18 +0000</pubDate><guid>https://grafana.com/docs/loki/v3.7.x/send-data/fluentbit/fluent-bit-plugin/</guid><content><![CDATA[&lt;h1 id=&#34;fluent-bit-loki-output-plugin&#34;&gt;Fluent Bit Loki output plugin&lt;/h1&gt;
&lt;p&gt;&lt;a href=&#34;https://fluentbit.io/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Fluent Bit&lt;/a&gt; is a fast and lightweight logs and metrics processor and forwarder that can be configured with the &lt;a href=&#34;https://docs.fluentbit.io/manual/pipeline/outputs/loki&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Fluent-bit Loki output plugin&lt;/a&gt; to ship logs to Loki.&lt;/p&gt;
&lt;p&gt;You can define which log files you want to collect using the &lt;a href=&#34;https://docs.fluentbit.io/manual/pipeline/inputs/tail&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;Tail&lt;/code&gt;&lt;/a&gt; or &lt;a href=&#34;https://docs.fluentbit.io/manual/pipeline/inputs/standard-input&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;Stdin&lt;/code&gt;&lt;/a&gt; data pipeline input. Additionally, Fluent Bit supports multiple &lt;code&gt;Filter&lt;/code&gt; and &lt;code&gt;Parser&lt;/code&gt; plugins (&lt;code&gt;Kubernetes&lt;/code&gt;, &lt;code&gt;JSON&lt;/code&gt;, etc.) to structure and alter log lines.&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;There are two Fluent Bit plugins for Loki: the officially maintained plugin &lt;code&gt;loki&lt;/code&gt; and the &lt;code&gt;grafana-loki&lt;/code&gt; plugin. We recommend using the &lt;code&gt;loki&lt;/code&gt; plugin described within this page as it&amp;rsquo;s officially maintained by the Fluent Bit project.&lt;/p&gt;
&lt;p&gt;For more information, see the &lt;a href=&#34;https://docs.fluentbit.io/manual/pipeline/outputs/loki&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Fluent Bit Loki output plugin documentation&lt;/a&gt;.  Note that the &lt;code&gt;grafana-loki&lt;/code&gt; plugin is no longer actively maintained.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;configuration&#34;&gt;Configuration&lt;/h2&gt;
&lt;p&gt;All configuration options for the Fluent Bit Loki output plugin are documented in the &lt;a href=&#34;https://docs.fluentbit.io/manual/pipeline/outputs/loki#configuration-parameters&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Fluent Bit Loki output plugin documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here is a generic example for connecting Fluent Bit to Loki hosted on Grafana Cloud:&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;conf&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-conf&#34;&gt;    [OUTPUT]
        Name        loki
        Match       *
        Host        YourHostname.company.com
        port        443
        tls         on
        tls.verify  on
        http_user   XXX
        http_passwd XXX&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Replace &lt;code&gt;Host&lt;/code&gt;, &lt;code&gt;http_user&lt;/code&gt;, and &lt;code&gt;http_passwd&lt;/code&gt; with your Grafana Cloud Loki endpoint and credentials.&lt;/p&gt;
&lt;h2 id=&#34;usage-examples&#34;&gt;Usage examples&lt;/h2&gt;
&lt;p&gt;Here are some examples of how to use Fluent Bit to send logs to Loki.&lt;/p&gt;
&lt;h3 id=&#34;tail-docker-logs&#34;&gt;Tail Docker logs&lt;/h3&gt;
&lt;p&gt;Here is an example to run Fluent Bit in a Docker container, collect Docker logs, and send them 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;docker run -v /var/lib/docker/containers:/var/lib/docker/containers fluent/fluent-bit:latest /fluent-bit/bin/fluent-bit -i tail -p Path=&amp;#34;/var/lib/docker/containers/*/*.log&amp;#34; -p Parser=docker -p Tag=&amp;#34;docker.*&amp;#34;  -o loki -p host=loki -p port=3100 -p labels=&amp;#34;agent=fluend-bit,env=docker&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In this example, we are using the &lt;code&gt;tail&lt;/code&gt; input plugin to collect Docker logs and the &lt;code&gt;loki&lt;/code&gt; output plugin to send logs to Loki. Note it is recommended to use a configuration file to define the input and output plugins. The &lt;code&gt;-p&lt;/code&gt; flag is used to pass configuration parameters to the plugins.&lt;/p&gt;
&lt;h4 id=&#34;configuration-file-alternative-to-command-line-arguments&#34;&gt;Configuration file (Alternative to command line arguments)&lt;/h4&gt;
&lt;p&gt;Create a configuration file &lt;code&gt;fluent-bit.conf&lt;/code&gt; with the following content:&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;conf&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-conf&#34;&gt;[INPUT]
    Name   tail
    Path   /var/lib/docker/containers/*/*.log
    Parser docker
    Tag    docker.*

[OUTPUT]
    Name   loki
    Match  *
    Host   loki
    Port   3100
    Labels agent=fluend-bit,env=docker&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Run Fluent Bit with the configuration 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;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/lib/docker/containers:/var/lib/docker/containers -v $(pwd)/fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf fluent/fluent-bit:latest /fluent-bit/bin/fluent-bit -c /fluent-bit/etc/fluent-bit.conf&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;collect-docker-events&#34;&gt;Collect Docker events&lt;/h3&gt;
&lt;p&gt;Here is an example to run Fluent Bit in a Docker container, collect docker events, and send them 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;docker run -v /var/run/docker.sock:/var/run/docker.sock fluent/fluent-bit:latest /fluent-bit/bin/fluent-bit -i docker_events -o loki -p host=loki -p port=3100 -p labels=&amp;#34;agent=fluend-bit,env=docker&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In this example, we are using the &lt;code&gt;docker_events&lt;/code&gt; input plugin to collect Docker events and the &lt;code&gt;loki&lt;/code&gt; output plugin to send logs to Loki. Note it is recommended to use a configuration file to define the input and output plugins. The &lt;code&gt;-p&lt;/code&gt; flag is used to pass configuration parameters to the plugins.&lt;/p&gt;
&lt;h4 id=&#34;configuration-file-alternative-to-command-line-arguments-1&#34;&gt;Configuration file (Alternative to command line arguments)&lt;/h4&gt;
&lt;p&gt;Create a configuration file &lt;code&gt;fluent-bit.conf&lt;/code&gt; with the following content:&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;conf&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-conf&#34;&gt;[INPUT]
    Name   docker_events

[OUTPUT]
    Name   loki
    Match  *
    Host   loki
    Port   3100
    Labels agent=fluent-bit,env=docker&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Run Fluent Bit with the configuration 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;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/run/docker.sock:/var/run/docker.sock -v $(pwd)/fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf fluent/fluent-bit:latest /fluent-bit/bin/fluent-bit -c /fluent-bit/etc/fluent-bit.conf&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;collect-kubernetes-logs&#34;&gt;Collect Kubernetes logs&lt;/h3&gt;
&lt;p&gt;The recommended way to collect logs from Kubernetes with Fluent Bit is to use the Helm chart provided by the Fluent Bit project. The Helm chart is available at &lt;a href=&#34;https://github.com/fluent/helm-charts&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;https://github.com/fluent/helm-charts&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here is an example of how to deploy the Fluent Bit Helm chart to collect logs from Kubernetes and send them to Loki:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Add the Fluent Bit Helm 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 add fluent https://fluent.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;Create a &lt;code&gt;values.yaml&lt;/code&gt; file with the following content:&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:
    outputs: |
        [OUTPUT]
            Name        loki
            Match       *
            Host        YourHost.Company.net
            port        443
            tls         on
            tls.verify  on
            http_user   XXX
            http_passwd XXX
            Labels agent=fluend-bit

Note we are only updating the `outputs` section of the Fluent Bit configuration. This is to replace the default output plugin with the Loki output plugin. If you need to update other parts of the Fluent Bit configuration refer to the [Fluent Bit values file reference](https://github.com/fluent/helm-charts/blob/main/charts/fluent-bit/values.yaml).&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Deploy the Fluent Bit Helm chart:&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 install fluent-bit fluent/fluent-bit -f values.yaml&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;next-steps&#34;&gt;Next steps&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/loki/v3.7.x/send-data/fluentbit/fluent-bit-loki-tutorial/&#34;&gt;Sending logs to Loki using Fluent Bit tutorial&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="fluent-bit-loki-output-plugin">Fluent Bit Loki output plugin&lt;/h1>
&lt;p>&lt;a href="https://fluentbit.io/" target="_blank" rel="noopener noreferrer">Fluent Bit&lt;/a> is a fast and lightweight logs and metrics processor and forwarder that can be configured with the &lt;a href="https://docs.fluentbit.io/manual/pipeline/outputs/loki" target="_blank" rel="noopener noreferrer">Fluent-bit Loki output plugin&lt;/a> to ship logs to Loki.&lt;/p></description></item></channel></rss>