<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Quick Start Loki on Grafana Labs</title><link>https://grafana.com/docs/loki/v3.7.x/get-started/quick-start/</link><description>Recent content in Quick Start Loki on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/loki/v3.7.x/get-started/quick-start/index.xml" rel="self" type="application/rss+xml"/><item><title>Quickstart to run Loki locally</title><link>https://grafana.com/docs/loki/v3.7.x/get-started/quick-start/quick-start/</link><pubDate>Thu, 09 Apr 2026 02:28:18 +0000</pubDate><guid>https://grafana.com/docs/loki/v3.7.x/get-started/quick-start/quick-start/</guid><content><![CDATA[&lt;!-- INTERACTIVE page intro.md START --&gt;
&lt;h1 id=&#34;quickstart-to-run-loki-locally&#34;&gt;Quickstart to run Loki locally&lt;/h1&gt;
&lt;p&gt;If you want to experiment with Loki, you can run Loki locally using the Docker Compose file that ships with Loki. It runs Loki in the 
    &lt;a href=&#34;/docs/loki/v3.7.x/get-started/deployment-modes/#simple-scalable&#34;&gt;simple scalable deployment&lt;/a&gt; mode and includes a sample application to generate logs.&lt;/p&gt;
&lt;p&gt;The Docker Compose configuration runs the following components, each in its own container:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;flog&lt;/strong&gt;: which generates log lines.
&lt;a href=&#34;https://github.com/mingrammer/flog&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;flog&lt;/a&gt; is a log generator for common log formats.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Grafana Alloy&lt;/strong&gt;: which scrapes the log lines from flog, and pushes them to Loki through the gateway.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Gateway&lt;/strong&gt; (nginx) which receives requests and redirects them to the appropriate container based on the request&amp;rsquo;s URL.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Loki read component&lt;/strong&gt;: which runs a Query Frontend and a Querier.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Loki write component&lt;/strong&gt;: which runs a Distributor and an Ingester.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Loki backend component&lt;/strong&gt;: which runs an Index Gateway, Compactor, Ruler, Bloom Planner (experimental), Bloom Builder (experimental), and Bloom Gateway (experimental).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Minio&lt;/strong&gt;: which Loki uses to store its index and chunks.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Grafana&lt;/strong&gt;: which provides visualization of the log lines captured within Loki.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 75%;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link captioned&#34;
        href=&#34;/media/docs/loki/get-started-flog-v3.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload mb-0&#34;
          data-src=&#34;/media/docs/loki/get-started-flog-v3.png&#34;data-srcset=&#34;/media/docs/loki/get-started-flog-v3.png?w=320 320w, /media/docs/loki/get-started-flog-v3.png?w=550 550w, /media/docs/loki/get-started-flog-v3.png?w=750 750w, /media/docs/loki/get-started-flog-v3.png?w=900 900w, /media/docs/loki/get-started-flog-v3.png?w=1040 1040w, /media/docs/loki/get-started-flog-v3.png?w=1240 1240w, /media/docs/loki/get-started-flog-v3.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Getting started sample application&#34;width=&#34;912&#34;height=&#34;877&#34;title=&#34;Getting started sample application&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/loki/get-started-flog-v3.png&#34;
            alt=&#34;Getting started sample application&#34;width=&#34;912&#34;height=&#34;877&#34;title=&#34;Getting started sample application&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Getting started sample application&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;!-- INTERACTIVE page intro.md END --&gt;
&lt;!-- INTERACTIVE ignore START --&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Before you start, you need to have the following installed on your local system:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Install &lt;a href=&#34;https://docs.docker.com/install&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Install &lt;a href=&#34;https://docs.docker.com/compose/install&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker Compose&lt;/a&gt;&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/loki-quickstart&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Loki Quickstart Sandbox&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;!-- INTERACTIVE page step1.md START --&gt;
&lt;h2 id=&#34;install-loki-and-collecting-sample-logs&#34;&gt;Install Loki and collecting sample logs&lt;/h2&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 quickstart assumes you are running Linux.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;!-- INTERACTIVE ignore END --&gt;
&lt;p&gt;&lt;strong&gt;To install Loki locally, follow these steps:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create a directory called &lt;code&gt;evaluate-loki&lt;/code&gt; for the demo environment.
Make &lt;code&gt;evaluate-loki&lt;/code&gt; your current working 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;mkdir evaluate-loki
cd evaluate-loki&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Download &lt;code&gt;loki-config.yaml&lt;/code&gt;, &lt;code&gt;alloy-local-config.yaml&lt;/code&gt;, and &lt;code&gt;docker-compose.yaml&lt;/code&gt;:&lt;/p&gt;
&lt;!-- INTERACTIVE ignore START --&gt;




  &lt;div class=&#34;br-4 base-border border-color-gray-3 docs_tabs&#34;&gt;
    &lt;div x-data=&#34;app_content_tabs([&amp;#34;wget&amp;#34;,&amp;#34;curl&amp;#34;], &#39;9bbb298b28523a089b06ab72776a8da1&#39;)&#34; x-init=&#34;init()&#34;&gt;
      &lt;div class=&#34;d-flex w-100p flex-direction-row align-items-center justify-content-flex-start d-md-none&#34;&gt;
        &lt;select class=&#34;docs_tabs--select w-100p base-border-bottom border-color-gray-3&#34; @change=&#34;toggle($event.target.value)&#34;&gt;
          
          
            &lt;option value=&#34;wget&#34; :selected=&#34;active === &#39;wget&#39;&#34;&gt;wget&lt;/option&gt;
          
          
            &lt;option value=&#34;curl&#34; :selected=&#34;active === &#39;curl&#39;&#34;&gt;curl&lt;/option&gt;
          
        &lt;/select&gt; 
      &lt;/div&gt;
      &lt;nav class=&#34;docs_tabs--navigation base-border-bottom border-color-gray-3 d-none d-md-block&#34; role=&#34;tablist&#34; data-codetoggle=&#34;true&#34;&gt;
        
        
          &lt;button
            class=&#34;docs_tabs--label f-14 bg-transparent color-gray-11 py-8 px-1&#34;
            data-toggle=&#34;tab&#34;
            role=&#34;tab&#34;
            @click=&#34;toggle(&#39;wget&#39;)&#34;
            :class=&#34;{ &#39;docs_tabs--label-active&#39;: active === &#39;wget&#39; }&#34;
          &gt;
            wget
          &lt;/button&gt;
        
        
          &lt;button
            class=&#34;docs_tabs--label f-14 bg-transparent color-gray-11 py-8 px-1&#34;
            data-toggle=&#34;tab&#34;
            role=&#34;tab&#34;
            @click=&#34;toggle(&#39;curl&#39;)&#34;
            :class=&#34;{ &#39;docs_tabs--label-active&#39;: active === &#39;curl&#39; }&#34;
          &gt;
            curl
          &lt;/button&gt;
        
      &lt;/nav&gt;
      &lt;div class=&#34;docs_tabs--content-container&#34;&gt;
        
   


&lt;div
  class=&#34;docs_tabs--content py-1 px-2&#34;
  :class=&#34;active === &#39;wget&#39; ? &#39;d-block&#39; : &#39;d-none&#39;&#34;
  id=&#34;&#34;
  role=&#34;tabpanel&#34;
  aria-labelledby=&#34;&#34;
&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;wget https://raw.githubusercontent.com/grafana/loki/main/examples/getting-started/loki-config.yaml -O loki-config.yaml
wget https://raw.githubusercontent.com/grafana/loki/main/examples/getting-started/alloy-local-config.yaml -O alloy-local-config.yaml
wget https://raw.githubusercontent.com/grafana/loki/main/examples/getting-started/docker-compose.yaml -O docker-compose.yaml&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;

   


&lt;div
  class=&#34;docs_tabs--content py-1 px-2&#34;
  :class=&#34;active === &#39;curl&#39; ? &#39;d-block&#39; : &#39;d-none&#39;&#34;
  id=&#34;&#34;
  role=&#34;tabpanel&#34;
  aria-labelledby=&#34;&#34;
&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;curl https://raw.githubusercontent.com/grafana/loki/main/examples/getting-started/loki-config.yaml --output loki-config.yaml
curl https://raw.githubusercontent.com/grafana/loki/main/examples/getting-started/alloy-local-config.yaml --output alloy-local-config.yaml
curl https://raw.githubusercontent.com/grafana/loki/main/examples/getting-started/docker-compose.yaml --output docker-compose.yaml&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;

   
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;


&lt;!-- INTERACTIVE ignore END --&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Deploy the sample Docker image.&lt;/p&gt;
&lt;p&gt;With &lt;code&gt;evaluate-loki&lt;/code&gt; as the current working directory, start the demo environment using &lt;code&gt;docker compose&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;docker compose up -d&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;At the end of the command, you should see something similar to the following:&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;✔ Network evaluate-loki_loki          Created      0.1s
✔ Container evaluate-loki-minio-1     Started      0.6s
✔ Container evaluate-loki-flog-1      Started      0.6s
✔ Container evaluate-loki-backend-1   Started      0.8s
✔ Container evaluate-loki-write-1     Started      0.8s
✔ Container evaluate-loki-read-1      Started      0.8s
✔ Container evaluate-loki-gateway-1   Started      1.1s
✔ Container evaluate-loki-grafana-1   Started      1.4s
✔ Container evaluate-loki-alloy-1     Started      1.4s&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) Verify that the Loki cluster is up and running.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The read component returns &lt;code&gt;ready&lt;/code&gt; when you browse to &lt;a href=&#34;http://localhost:3101/ready&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3101/ready&lt;/a&gt;.
The message &lt;code&gt;Query Frontend not ready: not ready: number of schedulers this worker is connected to is 0&lt;/code&gt; shows until the read component is ready.&lt;/li&gt;
&lt;li&gt;The write component returns &lt;code&gt;ready&lt;/code&gt; when you browse to &lt;a href=&#34;http://localhost:3102/ready&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3102/ready&lt;/a&gt;.
The message &lt;code&gt;Ingester not ready: waiting for 15s after being ready&lt;/code&gt; shows until the write component is ready.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) Verify that Grafana Alloy is running.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You can access the Grafana Alloy UI at &lt;a href=&#34;http://localhost:12345&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:12345&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) You can check all the containers are running 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 ps -a&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;!-- INTERACTIVE page step1.md END --&gt;
&lt;!-- INTERACTIVE page step2.md START --&gt;
&lt;h2 id=&#34;view-your-logs-in-grafana&#34;&gt;View your logs in Grafana&lt;/h2&gt;
&lt;p&gt;After you have collected logs, you will want to view them.
You can view your logs using the command line interface, 
    &lt;a href=&#34;/docs/loki/v3.7.x/query/logcli/&#34;&gt;LogCLI&lt;/a&gt;, but the easiest way to view your logs is with Grafana.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Use Grafana to query the Loki data source.&lt;/p&gt;
&lt;p&gt;The test environment includes &lt;a href=&#34;/docs/grafana/latest/&#34;&gt;Grafana&lt;/a&gt;, which you can use to query and observe the sample logs generated by the flog application.&lt;/p&gt;
&lt;p&gt;You can access the Grafana cluster by browsing to &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;p&gt;The Grafana instance in this demonstration has a Loki &lt;a href=&#34;/docs/grafana/latest/datasources/loki/&#34;&gt;data source&lt;/a&gt; already configured.&lt;/p&gt;
&lt;figure
       class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
       style=&#34;max-width: 1421px;&#34;
       itemprop=&#34;associatedMedia&#34;
       itemscope=&#34;&#34;
       itemtype=&#34;http://schema.org/ImageObject&#34;
     &gt;&lt;a
           class=&#34;lightbox-link captioned&#34;
           href=&#34;/media/docs/loki/grafana-query-builder-v2.png&#34;
           itemprop=&#34;contentUrl&#34;
         &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
             class=&#34;lazyload mb-0&#34;
             data-src=&#34;/media/docs/loki/grafana-query-builder-v2.png&#34;data-srcset=&#34;/media/docs/loki/grafana-query-builder-v2.png?w=320 320w, /media/docs/loki/grafana-query-builder-v2.png?w=550 550w, /media/docs/loki/grafana-query-builder-v2.png?w=750 750w, /media/docs/loki/grafana-query-builder-v2.png?w=900 900w, /media/docs/loki/grafana-query-builder-v2.png?w=1040 1040w, /media/docs/loki/grafana-query-builder-v2.png?w=1240 1240w, /media/docs/loki/grafana-query-builder-v2.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Grafana Explore&#34;width=&#34;1421&#34;height=&#34;497&#34;title=&#34;Grafana Explore&#34;/&gt;
           &lt;noscript&gt;
             &lt;img
               src=&#34;/media/docs/loki/grafana-query-builder-v2.png&#34;
               alt=&#34;Grafana Explore&#34;width=&#34;1421&#34;height=&#34;497&#34;title=&#34;Grafana Explore&#34;/&gt;
           &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Grafana Explore&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;From the Grafana main menu, click the &lt;strong&gt;Explore&lt;/strong&gt; icon (1) to open the Explore tab.&lt;/p&gt;
&lt;p&gt;To learn more about Explore, refer to the &lt;a href=&#34;/docs/grafana/latest/explore/&#34;&gt;Explore&lt;/a&gt; documentation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;From the menu in the dashboard header, select the Loki data source (2).&lt;/p&gt;
&lt;p&gt;This displays the Loki query editor.&lt;/p&gt;
&lt;p&gt;In the query editor you use the Loki query language, 
    &lt;a href=&#34;/docs/loki/v3.7.x/query/&#34;&gt;LogQL&lt;/a&gt;, to query your logs.
To learn more about the query editor, refer to the &lt;a href=&#34;/docs/grafana/latest/datasources/loki/query-editor/&#34;&gt;query editor documentation&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The Loki query editor has two modes (3):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;/docs/grafana/latest/datasources/loki/query-editor/#builder-mode&#34;&gt;Builder mode&lt;/a&gt;, which provides a visual query designer.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;/docs/grafana/latest/datasources/loki/query-editor/#code-mode&#34;&gt;Code mode&lt;/a&gt;, which provides a feature-rich editor for writing LogQL queries.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Next we’ll walk through a few simple queries using both the builder and code views.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Code&lt;/strong&gt; (3) to work in Code mode in the query editor.&lt;/p&gt;
&lt;p&gt;Here are some sample queries to get you started using LogQL.
These queries assume that you followed the instructions to create a directory called &lt;code&gt;evaluate-loki&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you installed in a different directory, you’ll need to modify these queries to match your installation directory.&lt;/p&gt;
&lt;p&gt;After copying any of these queries into the query editor, click &lt;strong&gt;Run Query&lt;/strong&gt; (4) to execute the query.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;View all the log lines which have the container label &lt;code&gt;evaluate-loki-flog-1&lt;/code&gt;:&lt;/p&gt;
&lt;!-- INTERACTIVE copy START --&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=&amp;#34;evaluate-loki-flog-1&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- INTERACTIVE copy END --&gt;
&lt;p&gt;In Loki, this is a log stream.&lt;/p&gt;
&lt;p&gt;Loki uses 
    &lt;a href=&#34;/docs/loki/v3.7.x/get-started/labels/&#34;&gt;labels&lt;/a&gt; as metadata to describe log streams.&lt;/p&gt;
&lt;p&gt;Loki queries always start with a label selector.
In the previous query, the label selector is &lt;code&gt;{container=&amp;quot;evaluate-loki-flog-1&amp;quot;}&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To view all the log lines which have the container label &lt;code&gt;evaluate-loki-grafana-1&lt;/code&gt;:&lt;/p&gt;
&lt;!-- INTERACTIVE copy START --&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=&amp;#34;evaluate-loki-grafana-1&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- INTERACTIVE copy END --&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Find all the log lines in the &lt;code&gt;{container=&amp;quot;evaluate-loki-flog-1&amp;quot;}&lt;/code&gt; stream that contain the string &lt;code&gt;status&lt;/code&gt;:&lt;/p&gt;
&lt;!-- INTERACTIVE copy START --&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=&amp;#34;evaluate-loki-flog-1&amp;#34;} |= `status`&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- INTERACTIVE copy END --&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Find all the log lines in the &lt;code&gt;{container=&amp;quot;evaluate-loki-flog-1&amp;quot;}&lt;/code&gt; stream where the JSON field &lt;code&gt;status&lt;/code&gt; has the value &lt;code&gt;404&lt;/code&gt;:&lt;/p&gt;
&lt;!-- INTERACTIVE copy START --&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=&amp;#34;evaluate-loki-flog-1&amp;#34;} | json | status=`404`&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- INTERACTIVE copy END --&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Calculate the number of logs per second where the JSON field &lt;code&gt;status&lt;/code&gt; has the value &lt;code&gt;404&lt;/code&gt;:&lt;/p&gt;
&lt;!-- INTERACTIVE copy START --&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;sum by(container) (rate({container=&amp;#34;evaluate-loki-flog-1&amp;#34;} | json | status=`404` [$__auto]))&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- INTERACTIVE copy END --&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The final query is a metric query which returns a time series.
This makes Grafana draw a graph of the results.&lt;/p&gt;
&lt;p&gt;You can change the type of graph for a different view of the data.
Click &lt;strong&gt;Bars&lt;/strong&gt; to view a bar graph of the data.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click the &lt;strong&gt;Builder&lt;/strong&gt; tab (3) to return to builder mode in the query editor.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;In builder mode, click &lt;strong&gt;Kick start your query&lt;/strong&gt; (5).&lt;/li&gt;
&lt;li&gt;Expand the &lt;strong&gt;Log query starters&lt;/strong&gt; section.&lt;/li&gt;
&lt;li&gt;Select the first choice, &lt;strong&gt;Parse log lines with logfmt parser&lt;/strong&gt;, by clicking &lt;strong&gt;Use this query&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;On the Explore tab, click &lt;strong&gt;Label browser&lt;/strong&gt;, in the dialog select a container and click &lt;strong&gt;Show logs&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For a thorough introduction to LogQL, refer to the 
    &lt;a href=&#34;/docs/loki/v3.7.x/query/&#34;&gt;LogQL reference&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;sample-queries-code-view&#34;&gt;Sample queries (code view)&lt;/h2&gt;
&lt;p&gt;Here are some more sample queries that you can run using the Flog sample data.&lt;/p&gt;
&lt;p&gt;To see all the log lines that flog has generated, enter the LogQL query:&lt;/p&gt;
&lt;!-- INTERACTIVE copy START --&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=&amp;#34;evaluate-loki-flog-1&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- INTERACTIVE copy END --&gt;
&lt;p&gt;The flog app generates log lines for simulated HTTP requests.&lt;/p&gt;
&lt;p&gt;To see all &lt;code&gt;GET&lt;/code&gt; log lines, enter the LogQL query:&lt;/p&gt;
&lt;!-- INTERACTIVE copy START --&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=&amp;#34;evaluate-loki-flog-1&amp;#34;} |= &amp;#34;GET&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- INTERACTIVE copy END --&gt;
&lt;p&gt;To see all &lt;code&gt;POST&lt;/code&gt; methods, enter the LogQL query:&lt;/p&gt;
&lt;!-- INTERACTIVE copy START --&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=&amp;#34;evaluate-loki-flog-1&amp;#34;} |= &amp;#34;POST&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- INTERACTIVE copy END --&gt;
&lt;p&gt;To see every log line with a 401 status (unauthorized error), enter the LogQL query:&lt;/p&gt;
&lt;!-- INTERACTIVE copy START --&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=&amp;#34;evaluate-loki-flog-1&amp;#34;} | json | status=&amp;#34;401&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- INTERACTIVE copy END --&gt;
&lt;p&gt;To see every log line that doesn&amp;rsquo;t contain the text &lt;code&gt;401&lt;/code&gt;:&lt;/p&gt;
&lt;!-- INTERACTIVE copy START --&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=&amp;#34;evaluate-loki-flog-1&amp;#34;} != &amp;#34;401&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- INTERACTIVE copy END --&gt;
&lt;p&gt;For more examples, refer to the 
    &lt;a href=&#34;/docs/loki/v3.7.x/query/query_examples/&#34;&gt;query documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;loki-data-source-in-grafana&#34;&gt;Loki data source in Grafana&lt;/h2&gt;
&lt;p&gt;In this example, the Loki data source is already configured in Grafana. This can be seen within the &lt;code&gt;docker-compose.yaml&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;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;  grafana:
    image: grafana/grafana:latest
    environment:
      - GF_PATHS_PROVISIONING=/etc/grafana/provisioning
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
    depends_on:
      - gateway
    entrypoint:
      - sh
      - -euc
      - |
        mkdir -p /etc/grafana/provisioning/datasources
        cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/grafana/provisioning/datasources/ds.yaml
        apiVersion: 1
        datasources:
          - name: Loki
            type: loki
            access: proxy
            url: http://gateway:3100
            jsonData:
              httpHeaderName1: &amp;#34;X-Scope-OrgID&amp;#34;
            secureJsonData:
              httpHeaderValue1: &amp;#34;tenant1&amp;#34;
        EOF
        /run.sh&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Within the entrypoint section, the Loki data source is configured with the following details:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Name: Loki&lt;/code&gt; (name of the data source)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Type: loki&lt;/code&gt; (type of data source)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Access: proxy&lt;/code&gt; (access type)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;URL: http://gateway:3100&lt;/code&gt; (URL of the Loki data source. Loki uses an nginx gateway to direct traffic to the appropriate component)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;jsonData.httpHeaderName1: &amp;quot;X-Scope-OrgID&amp;quot;&lt;/code&gt; (header name for the organization ID)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;secureJsonData.httpHeaderValue1: &amp;quot;tenant1&amp;quot;&lt;/code&gt; (header value for the organization ID)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is important to note when Loki is configured in any other mode other than monolithic deployment, you are required to pass a tenant ID in the header. Without this, queries will return an authorization error.&lt;/p&gt;
&lt;!-- INTERACTIVE page step2.md END --&gt;
&lt;!-- INTERACTIVE page finish.md START --&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;You have completed the Loki Quickstart demo. So where to go next?&lt;/p&gt;

&lt;p&gt;If you would like to run a demonstration environment 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;.
It&amp;rsquo;s 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.
You can also push the data from the environment to &lt;a href=&#34;/cloud/&#34;&gt;Grafana Cloud&lt;/a&gt;.&lt;/p&gt;
&lt;!-- INTERACTIVE page finish.md END --&gt;
]]></content><description>&lt;!-- INTERACTIVE page intro.md START -->
&lt;h1 id="quickstart-to-run-loki-locally">Quickstart to run Loki locally&lt;/h1>
&lt;p>If you want to experiment with Loki, you can run Loki locally using the Docker Compose file that ships with Loki. It runs Loki in the
&lt;a href="/docs/loki/v3.7.x/get-started/deployment-modes/#simple-scalable">simple scalable deployment&lt;/a> mode and includes a sample application to generate logs.&lt;/p></description></item><item><title>Loki Tutorial</title><link>https://grafana.com/docs/loki/v3.7.x/get-started/quick-start/tutorial/</link><pubDate>Thu, 09 Apr 2026 02:28:18 +0000</pubDate><guid>https://grafana.com/docs/loki/v3.7.x/get-started/quick-start/tutorial/</guid><content><![CDATA[&lt;!-- INTERACTIVE page intro.md START --&gt;
&lt;h1 id=&#34;loki-tutorial&#34;&gt;Loki Tutorial&lt;/h1&gt;
&lt;p&gt;This quickstart guide will walk you through deploying Loki in single binary mode (also known as 
    &lt;a href=&#34;/docs/loki/v3.7.x/get-started/deployment-modes/#monolithic-mode&#34;&gt;monolithic mode&lt;/a&gt;) using Docker Compose. Grafana Loki is only one component of the Grafana observability stack for logs. In this tutorial we will refer to this stack as the &lt;strong&gt;Loki stack&lt;/strong&gt;.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 100%;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link captioned&#34;
        href=&#34;/media/docs/loki/getting-started-loki-stack-3.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload mb-0&#34;
          data-src=&#34;/media/docs/loki/getting-started-loki-stack-3.png&#34;data-srcset=&#34;/media/docs/loki/getting-started-loki-stack-3.png?w=320 320w, /media/docs/loki/getting-started-loki-stack-3.png?w=550 550w, /media/docs/loki/getting-started-loki-stack-3.png?w=750 750w, /media/docs/loki/getting-started-loki-stack-3.png?w=900 900w, /media/docs/loki/getting-started-loki-stack-3.png?w=1040 1040w, /media/docs/loki/getting-started-loki-stack-3.png?w=1240 1240w, /media/docs/loki/getting-started-loki-stack-3.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Loki stack&#34;width=&#34;1200&#34;height=&#34;520&#34;title=&#34;Loki stack&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/loki/getting-started-loki-stack-3.png&#34;
            alt=&#34;Loki stack&#34;width=&#34;1200&#34;height=&#34;520&#34;title=&#34;Loki stack&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Loki stack&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;The Loki stack consists of the following components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Alloy&lt;/strong&gt;: &lt;a href=&#34;/docs/alloy/latest/&#34;&gt;Grafana Alloy&lt;/a&gt; is an open source telemetry collector for metrics, logs, traces, and continuous profiles. In this quickstart guide Grafana Alloy has been configured to tail logs from all Docker containers and forward them to Loki.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Loki&lt;/strong&gt;: A log aggregation system to store the collected logs. For more information on what Loki is, see the 
    &lt;a href=&#34;/docs/loki/v3.7.x/get-started/overview/&#34;&gt;Loki overview&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Grafana&lt;/strong&gt;: &lt;a href=&#34;/docs/grafana/latest/&#34;&gt;Grafana&lt;/a&gt; is an open-source platform for monitoring and observability. Grafana will be used to query and visualize the logs stored in Loki.&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- INTERACTIVE ignore START --&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Before you start, you need to have the following installed on your local system:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Install &lt;a href=&#34;https://docs.docker.com/install&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Install &lt;a href=&#34;https://docs.docker.com/compose/install&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker Compose&lt;/a&gt;&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/loki-getting-started-tutorial&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Loki Quickstart Sandbox&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;!-- INTERACTIVE page intro.md END --&gt;
&lt;!-- INTERACTIVE page step1.md START --&gt;
&lt;h2 id=&#34;deploy-the-loki-stack&#34;&gt;Deploy the Loki stack&lt;/h2&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 quickstart assumes you are running Linux or MacOS. Windows users can follow the same steps using &lt;a href=&#34;https://learn.microsoft.com/en-us/windows/wsl/install&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Windows Subsystem for Linux&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;!-- INTERACTIVE ignore END --&gt;
&lt;p&gt;&lt;strong&gt;To deploy the Loki stack locally, follow these steps:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Clone the Loki fundamentals repository and check out the getting-started branch:&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/loki-fundamentals.git -b getting-started&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Change to the &lt;code&gt;loki-fundamentals&lt;/code&gt; 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;cd loki-fundamentals&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;With &lt;code&gt;loki-fundamentals&lt;/code&gt; as the current working directory deploy Loki, Alloy, and Grafana 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 up -d&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;After running the command, you should see a similar output:&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  0.3s 
 ✔ Container loki-fundamentals-loki-1     Started  0.3s 
 ✔ Container loki-fundamentals-alloy-1    Started  0.4s&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;With the Loki stack running, you can now verify each component is up and running:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Alloy&lt;/strong&gt;: Open a browser and navigate to &lt;a href=&#34;http://localhost:12345/graph&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:12345/graph&lt;/a&gt;. You should see the Alloy UI.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Grafana&lt;/strong&gt;: Open a browser and navigate to &lt;a href=&#34;http://localhost:3000&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000&lt;/a&gt;. You should see the Grafana home page.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Loki&lt;/strong&gt;: Open a browser and navigate to &lt;a href=&#34;http://localhost:3100/metrics&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3100/metrics&lt;/a&gt;. You should see the Loki metrics page.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;!-- INTERACTIVE page step1.md END --&gt;
&lt;!-- INTERACTIVE page step2.md START --&gt;
&lt;p&gt;Since Grafana Alloy is configured to tail logs from all Docker containers, Loki should already be receiving logs. The best place to verify log collection is using the Grafana Logs Drilldown feature. To do this, navigate to &lt;a href=&#34;http://localhost:3000/drilldown&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/drilldown&lt;/a&gt;. Select &lt;strong&gt;Logs&lt;/strong&gt;. You should see the Grafana Logs Drilldown page.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 100%;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link captioned&#34;
        href=&#34;/media/docs/loki/get-started-drill-down.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload mb-0&#34;
          data-src=&#34;/media/docs/loki/get-started-drill-down.png&#34;data-srcset=&#34;/media/docs/loki/get-started-drill-down.png?w=320 320w, /media/docs/loki/get-started-drill-down.png?w=550 550w, /media/docs/loki/get-started-drill-down.png?w=750 750w, /media/docs/loki/get-started-drill-down.png?w=900 900w, /media/docs/loki/get-started-drill-down.png?w=1040 1040w, /media/docs/loki/get-started-drill-down.png?w=1240 1240w, /media/docs/loki/get-started-drill-down.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Grafana Logs Drilldown&#34;width=&#34;2408&#34;height=&#34;1674&#34;title=&#34;Grafana Logs Drilldown&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/loki/get-started-drill-down.png&#34;
            alt=&#34;Grafana Logs Drilldown&#34;width=&#34;2408&#34;height=&#34;1674&#34;title=&#34;Grafana Logs Drilldown&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Grafana Logs Drilldown&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;If you have only the getting started demo deployed in your Docker environment, you should see three containers and their logs; &lt;code&gt;loki-fundamentals-alloy-1&lt;/code&gt;, &lt;code&gt;loki-fundamentals-grafana-1&lt;/code&gt; and &lt;code&gt;loki-fundamentals-loki-1&lt;/code&gt;.  In the &lt;code&gt;loki-fundamentals-loki-1&lt;/code&gt; container, click &lt;strong&gt;Show Logs&lt;/strong&gt;  to drill down into the logs for that container.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 100%;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link captioned&#34;
        href=&#34;/media/docs/loki/get-started-drill-down-container.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload mb-0&#34;
          data-src=&#34;/media/docs/loki/get-started-drill-down-container.png&#34;data-srcset=&#34;/media/docs/loki/get-started-drill-down-container.png?w=320 320w, /media/docs/loki/get-started-drill-down-container.png?w=550 550w, /media/docs/loki/get-started-drill-down-container.png?w=750 750w, /media/docs/loki/get-started-drill-down-container.png?w=900 900w, /media/docs/loki/get-started-drill-down-container.png?w=1040 1040w, /media/docs/loki/get-started-drill-down-container.png?w=1240 1240w, /media/docs/loki/get-started-drill-down-container.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Grafana Drilldown Service View&#34;width=&#34;2368&#34;height=&#34;1700&#34;title=&#34;Grafana Drilldown Service View&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/loki/get-started-drill-down-container.png&#34;
            alt=&#34;Grafana Drilldown Service View&#34;width=&#34;2368&#34;height=&#34;1700&#34;title=&#34;Grafana Drilldown Service View&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Grafana Drilldown Service View&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;We will not cover the rest of the Grafana Logs Drilldown features in this quickstart guide. For more information on how to use the Grafana Logs Drilldown feature, refer to &lt;a href=&#34;/docs/grafana/latest/explore/simplified-exploration/logs/get-started/&#34;&gt;Get started with Grafana Logs Drilldown&lt;/a&gt;.&lt;/p&gt;
&lt;!-- INTERACTIVE page step2.md END --&gt;
&lt;!-- INTERACTIVE page step3.md START --&gt;
&lt;h2 id=&#34;collect-logs-from-a-sample-application&#34;&gt;Collect logs from a sample application&lt;/h2&gt;
&lt;p&gt;Currently, the Loki stack is collecting logs about itself. To provide a more realistic example, you can deploy a sample application that generates logs. The sample application is called &lt;strong&gt;The Carnivorous Greenhouse&lt;/strong&gt;, a microservices application that allows users to login and simulate a greenhouse with carnivorous plants to monitor. The application consists of seven 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 PostgreSQL database that stores user and plant data.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The architecture of the application is shown below:&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 100%;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link captioned&#34;
        href=&#34;/media/docs/loki/get-started-architecture.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload mb-0&#34;
          data-src=&#34;/media/docs/loki/get-started-architecture.png&#34;data-srcset=&#34;/media/docs/loki/get-started-architecture.png?w=320 320w, /media/docs/loki/get-started-architecture.png?w=550 550w, /media/docs/loki/get-started-architecture.png?w=750 750w, /media/docs/loki/get-started-architecture.png?w=900 900w, /media/docs/loki/get-started-architecture.png?w=1040 1040w, /media/docs/loki/get-started-architecture.png?w=1240 1240w, /media/docs/loki/get-started-architecture.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Sample Microservice Architecture&#34;width=&#34;1200&#34;height=&#34;900&#34;title=&#34;Sample Microservice Architecture&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/loki/get-started-architecture.png&#34;
            alt=&#34;Sample Microservice Architecture&#34;width=&#34;1200&#34;height=&#34;900&#34;title=&#34;Sample Microservice Architecture&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Sample Microservice Architecture&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;To deploy the sample application, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;With &lt;code&gt;loki-fundamentals&lt;/code&gt; as the current working directory, deploy the sample application 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 greenhouse/docker-compose-micro.yml up -d --build  &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;This may take a few minutes to complete since the images for the sample application need to be built. Go grab a coffee and come back.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;Once the command completes, you should see a similar output:&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 greenhouse-websocket_service-1   Started   0.7s 
  ✔ Container greenhouse-db-1                  Started   0.7s 
  ✔ Container greenhouse-user_service-1        Started   0.8s 
  ✔ Container greenhouse-bug_service-1         Started   0.8s 
  ✔ Container greenhouse-plant_service-1       Started   0.8s 
  ✔ Container greenhouse-simulation_service-1  Started   0.7s 
  ✔ Container greenhouse-main_app-1            Started   0.7s&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To verify the sample application is running, open a browser and navigate to &lt;a href=&#34;http://localhost:5005&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:5005&lt;/a&gt;. You should see the login page for the Carnivorous Greenhouse application.&lt;/p&gt;
&lt;p&gt;Now that the sample application is running, run some actions in the application to generate logs. Here is a list of actions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Create a user:&lt;/strong&gt; Click &lt;strong&gt;Sign Up&lt;/strong&gt; and create a new user. Add a username and password and click &lt;strong&gt;Sign Up&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Login:&lt;/strong&gt; Use the username and password you created to login. Add the username and password and click &lt;strong&gt;Login&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Create a plant:&lt;/strong&gt; Once logged in, give your plant a name, select a plant type and click &lt;strong&gt;Add Plant&lt;/strong&gt;. Do this a few times if you like.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Your greenhouse should look something like this:&lt;/p&gt;
&lt;figure
      class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
      style=&#34;max-width: 100%;&#34;
      itemprop=&#34;associatedMedia&#34;
      itemscope=&#34;&#34;
      itemtype=&#34;http://schema.org/ImageObject&#34;
    &gt;&lt;a
          class=&#34;lightbox-link captioned&#34;
          href=&#34;/media/docs/loki/get-started-greenhouse.png&#34;
          itemprop=&#34;contentUrl&#34;
        &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
            class=&#34;lazyload mb-0&#34;
            data-src=&#34;/media/docs/loki/get-started-greenhouse.png&#34;data-srcset=&#34;/media/docs/loki/get-started-greenhouse.png?w=320 320w, /media/docs/loki/get-started-greenhouse.png?w=550 550w, /media/docs/loki/get-started-greenhouse.png?w=750 750w, /media/docs/loki/get-started-greenhouse.png?w=900 900w, /media/docs/loki/get-started-greenhouse.png?w=1040 1040w, /media/docs/loki/get-started-greenhouse.png?w=1240 1240w, /media/docs/loki/get-started-greenhouse.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Greenhouse Dashboard&#34;width=&#34;1952&#34;height=&#34;1536&#34;title=&#34;Greenhouse Dashboard&#34;/&gt;
          &lt;noscript&gt;
            &lt;img
              src=&#34;/media/docs/loki/get-started-greenhouse.png&#34;
              alt=&#34;Greenhouse Dashboard&#34;width=&#34;1952&#34;height=&#34;1536&#34;title=&#34;Greenhouse Dashboard&#34;/&gt;
          &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Greenhouse Dashboard&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;Now that you have generated some logs, you can return to the Grafana Logs Drilldown page &lt;a href=&#34;http://localhost:3000/drilldown&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/drilldown&lt;/a&gt;. You should see seven new services such as &lt;code&gt;greenhouse-main_app-1&lt;/code&gt;, &lt;code&gt;greenhouse-plant_service-1&lt;/code&gt;, &lt;code&gt;greenhouse-user_service-1&lt;/code&gt;, etc.&lt;/p&gt;
&lt;!-- INTERACTIVE page step3.md END --&gt;
&lt;!-- INTERACTIVE page step4.md START --&gt;
&lt;h2 id=&#34;querying-logs&#34;&gt;Querying logs&lt;/h2&gt;
&lt;p&gt;At this point, you have viewed logs using the Grafana Logs Drilldown feature. In many cases this will provide you with all the information you need. However, we can also manually query Loki to ask more advanced questions about the logs. This can be done via &lt;strong&gt;Grafana Explore&lt;/strong&gt;.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Open a browser and navigate to &lt;a href=&#34;http://localhost:3000&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000&lt;/a&gt; to open Grafana.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;From the Grafana main menu, click the &lt;strong&gt;Explore&lt;/strong&gt; icon (1) to open the Explore tab.&lt;/p&gt;
&lt;p&gt;To learn more about Explore, refer to the &lt;a href=&#34;/docs/grafana/latest/explore/&#34;&gt;Explore&lt;/a&gt; documentation.&lt;/p&gt;
&lt;figure
       class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
       style=&#34;max-width: 1421px;&#34;
       itemprop=&#34;associatedMedia&#34;
       itemscope=&#34;&#34;
       itemtype=&#34;http://schema.org/ImageObject&#34;
     &gt;&lt;a
           class=&#34;lightbox-link captioned&#34;
           href=&#34;/media/docs/loki/grafana-query-builder-v2.png&#34;
           itemprop=&#34;contentUrl&#34;
         &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
             class=&#34;lazyload mb-0&#34;
             data-src=&#34;/media/docs/loki/grafana-query-builder-v2.png&#34;data-srcset=&#34;/media/docs/loki/grafana-query-builder-v2.png?w=320 320w, /media/docs/loki/grafana-query-builder-v2.png?w=550 550w, /media/docs/loki/grafana-query-builder-v2.png?w=750 750w, /media/docs/loki/grafana-query-builder-v2.png?w=900 900w, /media/docs/loki/grafana-query-builder-v2.png?w=1040 1040w, /media/docs/loki/grafana-query-builder-v2.png?w=1240 1240w, /media/docs/loki/grafana-query-builder-v2.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Grafana Explore&#34;width=&#34;1421&#34;height=&#34;497&#34;title=&#34;Grafana Explore&#34;/&gt;
           &lt;noscript&gt;
             &lt;img
               src=&#34;/media/docs/loki/grafana-query-builder-v2.png&#34;
               alt=&#34;Grafana Explore&#34;width=&#34;1421&#34;height=&#34;497&#34;title=&#34;Grafana Explore&#34;/&gt;
           &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Grafana Explore&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;From the menu in the dashboard header, select the Loki data source (2).&lt;/p&gt;
&lt;p&gt;This displays the Loki query editor.&lt;/p&gt;
&lt;p&gt;In the query editor you use the Loki query language, 
    &lt;a href=&#34;/docs/loki/v3.7.x/query/&#34;&gt;LogQL&lt;/a&gt;, to query your logs.
To learn more about the query editor, refer to the &lt;a href=&#34;/docs/grafana/latest/datasources/loki/query-editor/&#34;&gt;query editor documentation&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The Loki query editor has two modes (3):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;/docs/grafana/latest/datasources/loki/query-editor/#builder-mode&#34;&gt;Builder mode&lt;/a&gt;, which provides a visual query designer.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;/docs/grafana/latest/datasources/loki/query-editor/#code-mode&#34;&gt;Code mode&lt;/a&gt;, which provides a feature-rich editor for writing LogQL queries.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Next we’ll walk through a few queries using the code view.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Code&lt;/strong&gt; (3) to work in Code mode in the query editor.&lt;/p&gt;
&lt;p&gt;Here are some sample queries to get you started using LogQL. After copying any of these queries into the query editor, click &lt;strong&gt;Run Query&lt;/strong&gt; (4) to execute the query.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;View all the log lines which have the &lt;code&gt;container&lt;/code&gt; label value &lt;code&gt;greenhouse-main_app-1&lt;/code&gt;:&lt;/p&gt;
&lt;!-- INTERACTIVE copy START --&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;logql&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-logql&#34;&gt;{container=&amp;#34;greenhouse-main_app-1&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- INTERACTIVE copy END --&gt;
&lt;p&gt;In Loki, this is a log stream.&lt;/p&gt;
&lt;p&gt;Loki uses 
    &lt;a href=&#34;/docs/loki/v3.7.x/get-started/labels/&#34;&gt;labels&lt;/a&gt; as metadata to describe log streams.&lt;/p&gt;
&lt;p&gt;Loki queries always start with a label selector.
In the previous query, the label selector is &lt;code&gt;{container=&amp;quot;greenhouse-main_app-1&amp;quot;}&lt;/code&gt;.&lt;/p&gt;
&lt;!-- INTERACTIVE copy END --&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Find all the log lines in the &lt;code&gt;{container=&amp;quot;greenhouse-main_app-1&amp;quot;}&lt;/code&gt; stream that contain the string &lt;code&gt;POST&lt;/code&gt;:&lt;/p&gt;
&lt;!-- INTERACTIVE copy START --&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;logql&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-logql&#34;&gt;{container=&amp;#34;greenhouse-main_app-1&amp;#34;} |= &amp;#34;POST&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- INTERACTIVE copy END --&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;!-- INTERACTIVE page step4.md END --&gt;
&lt;!-- INTERACTIVE page step5.md START --&gt;
&lt;h3 id=&#34;extracting-attributes-from-logs&#34;&gt;Extracting attributes from logs&lt;/h3&gt;
&lt;p&gt;Loki by design does not force log lines into a specific schema format. Whether you are using JSON, key-value pairs, plain text, Logfmt, or any other format, Loki ingests these logs lines as a stream of characters. The sample application we are using stores logs in &lt;a href=&#34;https://brandur.org/logfmt&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Logfmt&lt;/a&gt; format:&lt;/p&gt;
&lt;!-- INTERACTIVE copy START --&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;ts=2025-02-21 16:09:42,176 level=INFO line=97 msg=&amp;#34;192.168.65.1 - - [21/Feb/2025 16:09:42] &amp;#34;GET /static/style.css HTTP/1.1&amp;#34; 304 -&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;To break this down:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;ts=2025-02-21 16:09:42,176&lt;/code&gt; is the timestamp of the log line.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;level=INFO&lt;/code&gt; is the log level.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;line=97&lt;/code&gt; is the line number in the code.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;msg=&amp;quot;192.168.65.1 - - [21/Feb/2025 16:09:42] &amp;quot;GET /static/style.css HTTP/1.1&amp;quot; 304 -&amp;quot;&lt;/code&gt; is the log message.&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- INTERACTIVE copy END --&gt;
&lt;p&gt;When querying Loki, you can pipe the result of the label selector through a parser. This extracts attributes from the log line for further processing. For example, lets pipe &lt;code&gt;{container=&amp;quot;greenhouse-main_app-1&amp;quot;}&lt;/code&gt; through the &lt;code&gt;logfmt&lt;/code&gt; parser to extract the &lt;code&gt;level&lt;/code&gt; and &lt;code&gt;line&lt;/code&gt; attributes:&lt;/p&gt;
&lt;!-- INTERACTIVE copy START --&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;logql&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-logql&#34;&gt;{container=&amp;#34;greenhouse-main_app-1&amp;#34;} | logfmt&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- INTERACTIVE copy END --&gt;
&lt;p&gt;When you now expand a log line in the query result, you will see the extracted attributes.&lt;/p&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;Before we move on to the next section, let&amp;rsquo;s generate some error logs. To do this, enable the bug service in the sample application. This is done by setting the &lt;code&gt;Toggle Error Mode&lt;/code&gt; to &lt;code&gt;On&lt;/code&gt; in the Carnivorous Greenhouse application. This will cause the bug service to randomly cause services to fail.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;advanced-and-metrics-queries&#34;&gt;Advanced and Metrics Queries&lt;/h3&gt;
&lt;p&gt;With Error Mode enabled the bug service will start causing services to fail, in these next few LogQL examples we will track down some of these errors.  Lets start by parsing the logs to extract the &lt;code&gt;level&lt;/code&gt; attribute and then filter for logs with a &lt;code&gt;level&lt;/code&gt; of &lt;code&gt;ERROR&lt;/code&gt;:&lt;/p&gt;
&lt;!-- INTERACTIVE copy START --&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;logql&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-logql&#34;&gt;{container=&amp;#34;greenhouse-plant_service-1&amp;#34;} | logfmt | level=&amp;#34;ERROR&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- INTERACTIVE copy END --&gt;
&lt;p&gt;This query will return all the logs from the &lt;code&gt;greenhouse-plant_service-1&lt;/code&gt; container that have a &lt;code&gt;level&lt;/code&gt; attribute of &lt;code&gt;ERROR&lt;/code&gt;. You can further refine this query by filtering for a specific code line:&lt;/p&gt;
&lt;!-- INTERACTIVE copy START --&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;logql&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-logql&#34;&gt;{container=&amp;#34;greenhouse-plant_service-1&amp;#34;} | logfmt | level=&amp;#34;ERROR&amp;#34;, line=&amp;#34;58&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- INTERACTIVE copy END --&gt;
&lt;p&gt;This query will return all the logs from the &lt;code&gt;greenhouse-plant_service-1&lt;/code&gt; container that have a &lt;code&gt;level&lt;/code&gt; attribute of &lt;code&gt;ERROR&lt;/code&gt; and a &lt;code&gt;line&lt;/code&gt; attribute of &lt;code&gt;58&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;LogQL also supports metrics queries. Metrics are useful for abstracting the raw log data aggregating attributes into numeric values. This allows you to utilise more visualization options in Grafana as well as generate alerts on your logs.&lt;/p&gt;
&lt;p&gt;For example, you can use a metric query to count the number of logs per second that have a specific attribute:&lt;/p&gt;
&lt;!-- INTERACTIVE copy START --&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;logql&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-logql&#34;&gt;sum(rate({container=&amp;#34;greenhouse-plant_service-1&amp;#34;} | logfmt | level=&amp;#34;ERROR&amp;#34; [$__auto]))&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- INTERACTIVE copy END --&gt;
&lt;p&gt;It worth changing the visualization from &lt;code&gt;lines&lt;/code&gt; to &lt;code&gt;bars&lt;/code&gt; to visualize the error rate over time since the error count is quite low.&lt;/p&gt;
&lt;p&gt;Another example is to get the top 10 services producing the highest rate of errors:&lt;/p&gt;
&lt;!-- INTERACTIVE copy START --&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;logql&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-logql&#34;&gt;topk(10,sum(rate({level=&amp;#34;error&amp;#34;} | logfmt [5m])) by (service_name))&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- INTERACTIVE copy END --&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;&lt;code&gt;service_name&lt;/code&gt; is a label created by Loki when no service name is provided in the log line. It will use the container name as the service name. A list of all automatically generated labels can be found in &lt;a href=&#34;/docs/loki/latest/get-started/labels/#default-labels-for-all-users&#34;&gt;Labels&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;Finally, lets take a look at the total log throughput of each container in our production environment:&lt;/p&gt;
&lt;!-- INTERACTIVE copy START --&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;logql&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-logql&#34;&gt;sum by (service_name) (rate({env=&amp;#34;production&amp;#34;} | logfmt [$__auto]))&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!-- INTERACTIVE copy END --&gt;
&lt;p&gt;This is made possible by the &lt;code&gt;service_name&lt;/code&gt; label and the &lt;code&gt;env&lt;/code&gt; label that we have added to our log lines. Note that &lt;code&gt;env&lt;/code&gt; is a static label that we added to all log lines as they are processed by Alloy.&lt;/p&gt;
&lt;!-- INTERACTIVE page step5.md END --&gt;
&lt;!-- INTERACTIVE page step6.md START --&gt;
&lt;h2 id=&#34;a-look-under-the-hood&#34;&gt;A look under the hood&lt;/h2&gt;
&lt;p&gt;At this point you will have a running Loki stack and a sample application generating logs. You have also queried Loki using Grafana Logs Drilldown and Grafana Explore.
In this next section we will take a look under the hood to understand how the Loki stack has been configured to collect logs, the Loki configuration file, and how the Loki data source has been configured in Grafana.&lt;/p&gt;
&lt;h3 id=&#34;grafana-alloy-configuration&#34;&gt;Grafana Alloy configuration&lt;/h3&gt;
&lt;p&gt;Grafana Alloy is collecting logs from all the Docker containers and forwarding them to Loki.
It needs a configuration file to know which logs to collect and where to forward them to. Within the &lt;code&gt;loki-fundamentals&lt;/code&gt; directory, you will find a file called &lt;code&gt;config.alloy&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;Alloy&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-alloy&#34;&gt;// This component is responsible for discovering new containers within the Docker environment
discovery.docker &amp;#34;getting_started&amp;#34; {
	host             = &amp;#34;unix:///var/run/docker.sock&amp;#34;
	refresh_interval = &amp;#34;5s&amp;#34;
}

// This component is responsible for relabeling the discovered containers
discovery.relabel &amp;#34;getting_started&amp;#34; {
	targets = []

	rule {
		source_labels = [&amp;#34;__meta_docker_container_name&amp;#34;]
		regex         = &amp;#34;/(.*)&amp;#34;
		target_label  = &amp;#34;container&amp;#34;
	}
}

// This component is responsible for collecting logs from the discovered containers
loki.source.docker &amp;#34;getting_started&amp;#34; {
	host             = &amp;#34;unix:///var/run/docker.sock&amp;#34;
	targets          = discovery.docker.getting_started.targets
	forward_to       = [loki.process.getting_started.receiver]
	relabel_rules    = discovery.relabel.getting_started.rules
	refresh_interval = &amp;#34;5s&amp;#34;
}

// This component is responsible for processing the logs (In this case adding static labels)
loki.process &amp;#34;getting_started&amp;#34; {
    stage.static_labels {
    values = {
      env = &amp;#34;production&amp;#34;,
    }
}
    forward_to = [loki.write.getting_started.receiver]
}

// This component is responsible for writing the logs to Loki
loki.write &amp;#34;getting_started&amp;#34; {
	endpoint {
		url  = &amp;#34;http://loki:3100/loki/api/v1/push&amp;#34;
	}
}

// Enables the ability to view logs in the Alloy UI in realtime
livedebugging {
  enabled = true
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This configuration file can be viewed visually via the Alloy UI at &lt;a href=&#34;http://localhost:12345/graph&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:12345/graph&lt;/a&gt;.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 100%;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link captioned&#34;
        href=&#34;/media/docs/loki/getting-started-alloy-ui.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload mb-0&#34;
          data-src=&#34;/media/docs/loki/getting-started-alloy-ui.png&#34;data-srcset=&#34;/media/docs/loki/getting-started-alloy-ui.png?w=320 320w, /media/docs/loki/getting-started-alloy-ui.png?w=550 550w, /media/docs/loki/getting-started-alloy-ui.png?w=750 750w, /media/docs/loki/getting-started-alloy-ui.png?w=900 900w, /media/docs/loki/getting-started-alloy-ui.png?w=1040 1040w, /media/docs/loki/getting-started-alloy-ui.png?w=1240 1240w, /media/docs/loki/getting-started-alloy-ui.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Alloy UI&#34;width=&#34;3002&#34;height=&#34;1626&#34;title=&#34;Alloy UI&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/loki/getting-started-alloy-ui.png&#34;
            alt=&#34;Alloy UI&#34;width=&#34;3002&#34;height=&#34;1626&#34;title=&#34;Alloy UI&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;figcaption class=&#34;w-100p caption text-gray-13  &#34;&gt;Alloy UI&lt;/figcaption&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;In this view you can see the components of the Alloy configuration file and how they are connected:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;discovery.docker&lt;/strong&gt;: This component queries the metadata of the Docker environment via the Docker socket and discovers new containers, as well as providing metadata about the containers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;discovery.relabel&lt;/strong&gt;: This component converts a metadata (&lt;code&gt;__meta_docker_container_name&lt;/code&gt;) label into a Loki label (&lt;code&gt;container&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;loki.source.docker&lt;/strong&gt;: This component collects logs from the discovered containers and forwards them to the next component. It requests the metadata from the &lt;code&gt;discovery.docker&lt;/code&gt; component and applies the relabeling rules from the &lt;code&gt;discovery.relabel&lt;/code&gt; component.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;loki.process&lt;/strong&gt;: This component provides stages for log transformation and extraction. In this case it adds a static label &lt;code&gt;env=production&lt;/code&gt; to all logs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;loki.write&lt;/strong&gt;: This component writes the logs to Loki. It forwards the logs to the Loki endpoint &lt;code&gt;http://loki:3100/loki/api/v1/push&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;view-logs-in-realtime&#34;&gt;View Logs in realtime&lt;/h3&gt;
&lt;p&gt;Grafana Alloy provides a built-in real time log viewer. This allows you to view current log entries and how they are being transformed via specific components of the pipeline.
To view live debugging mode open a browser tab and navigate to: &lt;a href=&#34;http://localhost:12345/debug/loki.process.getting_started&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:12345/debug/loki.process.getting_started&lt;/a&gt;.&lt;/p&gt;
&lt;!-- INTERACTIVE page step6.md END --&gt;
&lt;!-- INTERACTIVE page step7.md START --&gt;
&lt;h2 id=&#34;loki-configuration&#34;&gt;Loki Configuration&lt;/h2&gt;
&lt;p&gt;Grafana Loki requires a configuration file to define how it should run. Within the &lt;code&gt;loki-fundamentals&lt;/code&gt; directory, you will find a file called &lt;code&gt;loki-config.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;auth_enabled: false

server:
  http_listen_port: 3100
  grpc_listen_port: 9096
  log_level: info
  grpc_server_max_concurrent_streams: 1000

common:
  instance_addr: 127.0.0.1
  path_prefix: /tmp/loki
  storage:
    filesystem:
      chunks_directory: /tmp/loki/chunks
      rules_directory: /tmp/loki/rules
  replication_factor: 1
  ring:
    kvstore:
      store: inmemory

query_range:
  results_cache:
    cache:
      embedded_cache:
        enabled: true
        max_size_mb: 100

limits_config:
  metric_aggregation_enabled: true
  allow_structured_metadata: true
  volume_enabled: true
  retention_period: 24h   # 24h

schema_config:
  configs:
    - from: 2020-10-24
      store: tsdb
      object_store: filesystem
      schema: v13
      index:
        prefix: index_
        period: 24h

pattern_ingester:
  enabled: true
  metric_aggregation:
    loki_address: localhost:3100

ruler:
  enable_alertmanager_discovery: true
  enable_api: true
  
frontend:
  encoding: protobuf

compactor:
  working_directory: /tmp/loki/retention
  delete_request_store: filesystem
  retention_enabled: true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;To summarize the configuration file:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;auth_enabled&lt;/strong&gt;: This is set to &lt;code&gt;false&lt;/code&gt;, meaning Loki does not need a 
    &lt;a href=&#34;/docs/loki/v3.7.x/operations/multi-tenancy/&#34;&gt;tenant ID&lt;/a&gt; for ingest or query. Note that this is not recommended for production environments. When deploying the Loki Helm chart, this is set to &lt;code&gt;true&lt;/code&gt; by default.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;server&lt;/strong&gt;: Defines the ports Loki listens on, the log level, and the maximum number of concurrent gRPC streams.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;common&lt;/strong&gt;:  Defines the common configuration for Loki. This includes the instance address, storage configuration, replication factor, and ring configuration.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;query_range&lt;/strong&gt;: This is configured to tell Loki to use inbuilt caching for query results. In production environments of Loki this is handled by a separate cache service such as memcached.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;limits_config&lt;/strong&gt;: Defines the global limits for all Loki tenants. This includes enabling specific features such as metric aggregation and structured metadata. Limits can be defined on a per tenant basis, however this is considered an advanced configuration and for most use cases the global limits are sufficient.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;schema_config&lt;/strong&gt;: Defines the schema configuration for Loki. This includes the schema version, the object store, and the index configuration.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;pattern_ingester&lt;/strong&gt;: Enables pattern ingesters which are used to discover log patterns. Mostly used by Grafana Logs Drilldown.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ruler&lt;/strong&gt;: Enables the ruler component of Loki. This is used to create alerts based on log queries.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;frontend&lt;/strong&gt;: Defines the encoding format for the frontend. In this case it is set to &lt;code&gt;protobuf&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;compactor&lt;/strong&gt;: Defines the compactor configuration. Used to compact the index and manage chunk retention.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The above configuration file is a basic configuration file for Loki. For more advanced configuration options, refer to the 
    &lt;a href=&#34;/docs/loki/v3.7.x/configuration/&#34;&gt;Loki Configuration&lt;/a&gt; documentation.&lt;/p&gt;
&lt;!-- INTERACTIVE page step7.md END --&gt;
&lt;!-- INTERACTIVE page step8.md START --&gt;
&lt;h3 id=&#34;grafana-loki-data-source&#34;&gt;Grafana Loki Data source&lt;/h3&gt;
&lt;p&gt;The final piece of the puzzle is the Grafana Loki data source. This is used by Grafana to connect to Loki and query the logs. Grafana has multiple ways to define a data source;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Direct&lt;/strong&gt;: This is where you define the data source in the Grafana UI.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Provisioning&lt;/strong&gt;: This is where you define the data source in a configuration file and have Grafana automatically create the data source.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;API&lt;/strong&gt;: This is where you use the Grafana API to create the data source.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this case we are using the provisioning method. Instead of mounting the Grafana configuration directory, we have defined the data source in this portion of the &lt;code&gt;docker-compose.yml&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;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;  grafana:
    image: grafana/grafana:latest
    environment:
      - GF_FEATURE_TOGGLES_ENABLE=grafanaManagedRecordingRules
      - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_AUTH_BASIC_ENABLED=false
    ports:
      - 3000:3000/tcp
    entrypoint:
      - sh
      - -euc
      - |
         mkdir -p /etc/grafana/provisioning/datasources
         cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/grafana/provisioning/datasources/ds.yaml
         apiVersion: 1
         datasources:
         - name: Loki
           type: loki
           access: proxy
           orgId: 1
           url: &amp;#39;http://loki:3100&amp;#39;
           basicAuth: false
           isDefault: true
           version: 1
           editable: true 
         EOF
         /run.sh
    networks:
      - loki&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Within the entrypoint section of the &lt;code&gt;docker-compose.yml&lt;/code&gt; file, we have defined a file called &lt;code&gt;run.sh&lt;/code&gt; this runs on startup and creates the data source configuration file &lt;code&gt;ds.yaml&lt;/code&gt; in the Grafana provisioning directory.
This file defines the Loki data source and tells Grafana to use it. Since Loki is running in the same Docker network as Grafana, we can use the service name &lt;code&gt;loki&lt;/code&gt; as the URL.&lt;/p&gt;
&lt;!-- INTERACTIVE page step8.md END --&gt;
&lt;!-- INTERACTIVE page finish.md START --&gt;
&lt;h2 id=&#34;what-next&#34;&gt;What next?&lt;/h2&gt;

&lt;p&gt;You have completed the Loki Quickstart demo. So where to go next? Here are a few suggestions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Deploy:&lt;/strong&gt; Loki can be deployed in multiple ways. For production use cases we recommend deploying Loki via the 
    &lt;a href=&#34;/docs/loki/v3.7.x/setup/install/helm/&#34;&gt;Helm chart&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Send Logs:&lt;/strong&gt; In this example we used Grafana Alloy to collect and send logs to Loki. However there are many other methods you can use depending upon your needs. For more information see 
    &lt;a href=&#34;/docs/loki/v3.7.x/send-data/&#34;&gt;send data&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Query Logs:&lt;/strong&gt; LogQL is an extensive query language for logs and contains many tools to improve log retrival and generate insights. For more information see the 
    &lt;a href=&#34;/docs/loki/v3.7.x/query/&#34;&gt;Query section&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Alert:&lt;/strong&gt; Lastly you can use the ruler component of Loki to create alerts based on log queries. For more information see 
    &lt;a href=&#34;/docs/loki/v3.7.x/alert/&#34;&gt;Alerting&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;complete-metrics-logs-traces-and-profiling-example&#34;&gt;Complete metrics, logs, traces, and profiling example&lt;/h3&gt;
&lt;p&gt;If you would like to run a demonstration environment 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;.
It&amp;rsquo;s 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.
You can also push the data from the environment to &lt;a href=&#34;/cloud/&#34;&gt;Grafana Cloud&lt;/a&gt;.&lt;/p&gt;
&lt;!-- INTERACTIVE page finish.md END --&gt;]]></content><description>&lt;!-- INTERACTIVE page intro.md START -->
&lt;h1 id="loki-tutorial">Loki Tutorial&lt;/h1>
&lt;p>This quickstart guide will walk you through deploying Loki in single binary mode (also known as
&lt;a href="/docs/loki/v3.7.x/get-started/deployment-modes/#monolithic-mode">monolithic mode&lt;/a>) using Docker Compose. Grafana Loki is only one component of the Grafana observability stack for logs. In this tutorial we will refer to this stack as the &lt;strong>Loki stack&lt;/strong>.&lt;/p></description></item></channel></rss>