<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Monitor metrics and logs with Grafana Alloy on Grafana Labs</title><link>https://grafana.com/docs/alloy/v1.15/monitor/</link><description>Recent content in Monitor metrics and logs with Grafana Alloy on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/alloy/v1.15/monitor/index.xml" rel="self" type="application/rss+xml"/><item><title>Monitor Docker containers with Grafana Alloy</title><link>https://grafana.com/docs/alloy/v1.15/monitor/monitor-docker-containers/</link><pubDate>Mon, 30 Mar 2026 15:47:22 +0000</pubDate><guid>https://grafana.com/docs/alloy/v1.15/monitor/monitor-docker-containers/</guid><content><![CDATA[&lt;h1 id=&#34;monitor-docker-containers-with-grafana-alloy&#34;&gt;Monitor Docker containers with Grafana Alloy&lt;/h1&gt;
&lt;p&gt;Docker containers provide statistics and logs.
The &lt;code&gt;docker stats&lt;/code&gt; and &lt;code&gt;docker logs&lt;/code&gt; commands display metrics and logs in a terminal as a fixed snapshot.
With Alloy, you can collect your metrics and logs, forward them to a Grafana stack, and create dashboards to monitor your Docker containers.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&#34;https://github.com/grafana/alloy-scenarios/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;alloy-scenarios&lt;/code&gt;&lt;/a&gt; repository contains complete examples of Alloy deployments.
Clone the repository and use the examples to understand how Alloy collects, processes, and exports telemetry signals.&lt;/p&gt;
&lt;p&gt;In this example scenario, Alloy collects Docker container metrics and logs and forwards them to a Loki destination.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Ensure you have the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.docker.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://git-scm.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Git&lt;/a&gt;&lt;/li&gt;
&lt;/ul&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;You need administrator privileges to run &lt;code&gt;docker&lt;/code&gt; commands.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;clone-and-deploy-the-example&#34;&gt;Clone and deploy the example&lt;/h2&gt;
&lt;p&gt;Follow these steps to clone the repository and deploy the monitoring example:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Clone the Alloy scenarios repository:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&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-shell&#34;&gt;git clone https://github.com/grafana/alloy-scenarios.git&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Start Docker to deploy the Grafana stack:&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;shell&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-shell&#34;&gt;cd alloy-scenarios/docker-monitoring
docker compose up -d&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Verify the status of the Docker containers:&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;shell&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-shell&#34;&gt;docker ps&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) Stop Docker to shut down the Grafana stack when you finish exploring this example:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&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-shell&#34;&gt;docker compose down&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;monitor-and-visualize-your-data&#34;&gt;Monitor and visualize your data&lt;/h2&gt;
&lt;p&gt;Use Grafana to monitor deployment health and visualize data.&lt;/p&gt;
&lt;h3 id=&#34;monitor-alloy&#34;&gt;Monitor Alloy&lt;/h3&gt;
&lt;p&gt;To monitor the health of your Alloy deployment, open your browser and go to &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;/p&gt;
&lt;p&gt;For more information about the Alloy UI, refer to &lt;a href=&#34;/docs/alloy/latest/troubleshoot/debug/&#34;&gt;Debug Grafana Alloy&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;visualize-your-data&#34;&gt;Visualize your data&lt;/h3&gt;
&lt;p&gt;To explore metrics, open your browser and go to &lt;a href=&#34;http://localhost:3000/explore/metrics&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/explore/metrics&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To use the Grafana Logs Drilldown, open your browser and go to &lt;a href=&#34;http://localhost:3000/a/grafana-lokiexplore-app&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/a/grafana-lokiexplore-app&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To create a &lt;a href=&#34;/docs/grafana/latest/getting-started/build-first-dashboard/#create-a-dashboard&#34;&gt;dashboard&lt;/a&gt; for visualizing metrics and logs, open your browser and go to &lt;a href=&#34;http://localhost:3000/dashboards&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/dashboards&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;understand-the-alloy-configuration&#34;&gt;Understand the Alloy configuration&lt;/h2&gt;
&lt;p&gt;This example uses a &lt;code&gt;config.alloy&lt;/code&gt; file to configure Alloy components for metrics and logging.
You can find this file in the cloned repository at &lt;code&gt;alloy-scenarios/docker-monitoring/&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;configure-metrics&#34;&gt;Configure metrics&lt;/h3&gt;
&lt;p&gt;The metrics configuration in this example requires three components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;prometheus.exporter.cadvisor&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;prometheus.scrape&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;prometheus.remote_write&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;prometheusexportercadvisor&#34;&gt;&lt;code&gt;prometheus.exporter.cadvisor&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/prometheus/prometheus.exporter.cadvisor/&#34;&gt;&lt;code&gt;prometheus.exporter.cadvisor&lt;/code&gt;&lt;/a&gt; component exposes Docker container metrics.
In this example, the component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;docker_host&lt;/code&gt;: Defines the Docker endpoint.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;storage_duration&lt;/code&gt;: Sets the time data is stored in memory.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This component provides the &lt;code&gt;prometheus.exporter.cadvisor.example.targets&lt;/code&gt; target for &lt;code&gt;prometheus.scrape&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;prometheus.exporter.cadvisor &amp;#34;example&amp;#34; {
  docker_host = &amp;#34;unix:///var/run/docker.sock&amp;#34;

  storage_duration = &amp;#34;5m&amp;#34;
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;prometheusscrape&#34;&gt;&lt;code&gt;prometheus.scrape&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/prometheus/prometheus.scrape/&#34;&gt;&lt;code&gt;prometheus.scrape&lt;/code&gt;&lt;/a&gt; component scrapes cAdvisor metrics and forwards them to a receiver.
In this example, the component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;targets&lt;/code&gt;: The target to scrape metrics from.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;forward_to&lt;/code&gt;: The destination to forward metrics to.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;scrape_interval&lt;/code&gt;: The frequency of scraping the target.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;prometheus.scrape &amp;#34;scraper&amp;#34; {
  targets    = prometheus.exporter.cadvisor.example.targets
  forward_to = [ prometheus.remote_write.demo.receiver ]

  scrape_interval = &amp;#34;10s&amp;#34;
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;prometheusremote_write&#34;&gt;&lt;code&gt;prometheus.remote_write&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/prometheus/prometheus.remote_write/&#34;&gt;&lt;code&gt;prometheus.remote_write&lt;/code&gt;&lt;/a&gt; component sends metrics to a Prometheus server.
In this example, the component requires the following argument:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;url&lt;/code&gt;: Defines the full URL endpoint to send metrics to.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This component provides the &lt;code&gt;prometheus.remote_write.demo.receiver&lt;/code&gt; destination for &lt;code&gt;prometheus.scrape&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;prometheus.remote_write &amp;#34;demo&amp;#34; {
  endpoint {
    url = &amp;#34;http://prometheus:9090/api/v1/write&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;configure-logging&#34;&gt;Configure logging&lt;/h3&gt;
&lt;p&gt;The logging configuration in this example requires four components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;discovery.docker&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;discovery.relabel&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;loki.source.docker&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;loki.write&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;discoverydocker&#34;&gt;&lt;code&gt;discovery.docker&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/discovery/discovery.docker/&#34;&gt;&lt;code&gt;discovery.docker&lt;/code&gt;&lt;/a&gt; component discovers Docker containers and extracts metadata.
In this example, the component requires the following argument:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;host&lt;/code&gt;: Defines the address of the Docker daemon.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;discovery.docker &amp;#34;linux&amp;#34; {
  host = &amp;#34;unix:///var/run/docker.sock&amp;#34;
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;discoveryrelabel&#34;&gt;&lt;code&gt;discovery.relabel&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/discovery/discovery.relabel/&#34;&gt;&lt;code&gt;discovery.relabel&lt;/code&gt;&lt;/a&gt; component defines a relabeling rule to create a service name from the container name.
In this example, the component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;targets&lt;/code&gt;: The targets to relabel.
In this example, the &lt;code&gt;discovery.relabel&lt;/code&gt; component is used only for its exported &lt;code&gt;relabel_rules&lt;/code&gt; in the &lt;code&gt;loki.source.docker&lt;/code&gt; component.
No targets are modified, so the &lt;code&gt;targets&lt;/code&gt; argument is an empty array.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;source_labels&lt;/code&gt;: The list of labels to select for relabeling.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;regex&lt;/code&gt;: A regular expression that matches any string after &lt;code&gt;/&lt;/code&gt;.
Docker container names often appear with a leading slash (/) in Prometheus automatic discovery labels.
This expression keeps the container name.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;target_label&lt;/code&gt;: The label written to the target.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;discovery.relabel &amp;#34;logs_integrations_docker&amp;#34; {
  targets = []

  rule {
    source_labels = [&amp;#34;__meta_docker_container_name&amp;#34;]
    regex = &amp;#34;/(.*)&amp;#34;
    target_label = &amp;#34;service_name&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;lokisourcedocker&#34;&gt;&lt;code&gt;loki.source.docker&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/loki/loki.source.docker/&#34;&gt;&lt;code&gt;loki.source.docker&lt;/code&gt;&lt;/a&gt; component collects logs from Docker containers.
In this example, the component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;host&lt;/code&gt;: The address of the Docker daemon.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;targets&lt;/code&gt;: The list of containers to read logs from.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;labels&lt;/code&gt;: The default set of labels to apply to entries.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;relabel_rules&lt;/code&gt;: The relabeling rules to apply to log entries.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;forward_to&lt;/code&gt;: The list of receivers to send log entries to.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;loki.source.docker &amp;#34;default&amp;#34; {
  host       = &amp;#34;unix:///var/run/docker.sock&amp;#34;
  targets    = discovery.docker.linux.targets
  labels     = {&amp;#34;platform&amp;#34; = &amp;#34;docker&amp;#34;}
  relabel_rules = discovery.relabel.logs_integrations_docker.rules
  forward_to = [loki.write.local.receiver]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;lokiwrite&#34;&gt;&lt;code&gt;loki.write&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/loki/loki.write/&#34;&gt;&lt;code&gt;loki.write&lt;/code&gt;&lt;/a&gt; component writes logs to a Loki destination.
In this example, the component requires the following argument:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;url&lt;/code&gt;: Defines the full URL endpoint in Loki to send logs to.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;loki.write &amp;#34;local&amp;#34; {
  endpoint {
    url = &amp;#34;http://loki:3100/loki/api/v1/push&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="monitor-docker-containers-with-grafana-alloy">Monitor Docker containers with Grafana Alloy&lt;/h1>
&lt;p>Docker containers provide statistics and logs.
The &lt;code>docker stats&lt;/code> and &lt;code>docker logs&lt;/code> commands display metrics and logs in a terminal as a fixed snapshot.
With Alloy, you can collect your metrics and logs, forward them to a Grafana stack, and create dashboards to monitor your Docker containers.&lt;/p></description></item><item><title>Monitor Linux servers with Grafana Alloy</title><link>https://grafana.com/docs/alloy/v1.15/monitor/monitor-linux/</link><pubDate>Mon, 30 Mar 2026 15:47:22 +0000</pubDate><guid>https://grafana.com/docs/alloy/v1.15/monitor/monitor-linux/</guid><content><![CDATA[&lt;h1 id=&#34;monitor-linux-servers-with-grafana-alloy&#34;&gt;Monitor Linux servers with Grafana Alloy&lt;/h1&gt;
&lt;p&gt;The Linux operating system generates a wide range of metrics and logs that you can use to monitor the health and performance of your hardware and operating system.
With Alloy, you can collect your metrics and logs, forward them to a Grafana stack, and create dashboards to monitor your Linux servers.&lt;/p&gt;
&lt;p&gt;This scenario demonstrates how to use Alloy to monitor Linux system metrics and logs using a complete example configuration.
You&amp;rsquo;ll deploy a containerized monitoring stack that includes Alloy, Prometheus, Loki, and Grafana.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&#34;https://github.com/grafana/alloy-scenarios/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;alloy-scenarios&lt;/code&gt;&lt;/a&gt; repository contains complete examples of Alloy deployments.
Clone the repository and use the examples to understand how Alloy collects, processes, and exports telemetry signals.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Before you begin, ensure you have the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.docker.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker&lt;/a&gt; and Docker Compose installed&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://git-scm.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Git&lt;/a&gt; for cloning the repository&lt;/li&gt;
&lt;li&gt;A Linux host or Linux running in a virtual machine&lt;/li&gt;
&lt;li&gt;Administrator privileges to run Docker commands&lt;/li&gt;
&lt;li&gt;Available ports: 3000 (Grafana), 9090 (Prometheus), 3100 (Loki), and 12345 (Alloy UI)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;clone-and-deploy-the-scenario&#34;&gt;Clone and deploy the scenario&lt;/h2&gt;
&lt;p&gt;This scenario runs Alloy in a container alongside Grafana, Prometheus, and Loki, creating a self-contained monitoring stack.
The Alloy container acts as a demonstration system to show monitoring capabilities.&lt;/p&gt;
&lt;p&gt;In a production environment, you would typically install Alloy directly on each Linux server you want to monitor.&lt;/p&gt;
&lt;p&gt;Follow these steps to clone the repository and deploy the monitoring scenario:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Clone the Alloy scenarios repository:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&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-shell&#34;&gt;git clone https://github.com/grafana/alloy-scenarios.git&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Start Docker to deploy the Grafana stack:&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;shell&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-shell&#34;&gt;cd alloy-scenarios/linux
docker compose up -d&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Verify the status of the Docker containers:&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;shell&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-shell&#34;&gt;docker ps&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) Stop Docker to shut down the Grafana stack when you finish exploring this scenario:&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;shell&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-shell&#34;&gt;docker compose down&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;monitor-and-visualize-your-data&#34;&gt;Monitor and visualize your data&lt;/h2&gt;
&lt;p&gt;After deploying the monitoring stack, you can use the Alloy UI to monitor deployment health and Grafana to visualize your collected data.&lt;/p&gt;
&lt;h3 id=&#34;monitor-alloy&#34;&gt;Monitor Alloy&lt;/h3&gt;
&lt;p&gt;To monitor the health of your Alloy deployment, open your browser and go to &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;/p&gt;
&lt;p&gt;For more information about the Alloy UI, refer to &lt;a href=&#34;/docs/alloy/latest/troubleshoot/debug/&#34;&gt;Debug Grafana Alloy&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;visualize-your-data&#34;&gt;Visualize your data&lt;/h3&gt;
&lt;p&gt;To explore metrics, open your browser and go to &lt;a href=&#34;http://localhost:3000/explore/metrics&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/explore/metrics&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To use the Grafana Logs Drilldown, open your browser and go to &lt;a href=&#34;http://localhost:3000/a/grafana-lokiexplore-app&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/a/grafana-lokiexplore-app&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To create a &lt;a href=&#34;/docs/grafana/latest/getting-started/build-first-dashboard/#create-a-dashboard&#34;&gt;dashboard&lt;/a&gt; for visualizing metrics and logs:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open your browser and go to &lt;a href=&#34;http://localhost:3000/dashboards&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/dashboards&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Download the JSON file for the preconfigured &lt;a href=&#34;/api/dashboards/1860/revisions/37/download&#34;&gt;Linux node dashboard&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Go to &lt;strong&gt;Dashboards&lt;/strong&gt; &amp;gt; &lt;strong&gt;Import&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Upload the JSON file.&lt;/li&gt;
&lt;li&gt;Select the Prometheus data source and click &lt;strong&gt;Import&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This community dashboard provides comprehensive system metrics including CPU, memory, disk, and network usage.&lt;/p&gt;
&lt;h2 id=&#34;understand-the-alloy-configuration&#34;&gt;Understand the Alloy configuration&lt;/h2&gt;
&lt;p&gt;This scenario uses a &lt;code&gt;config.alloy&lt;/code&gt; file to configure Alloy components for metrics and logging.
You can find this file in the cloned repository at &lt;code&gt;alloy-scenarios/linux/&lt;/code&gt;.
The configuration demonstrates how to collect Linux system metrics and logs, then forward them to Prometheus and Loki for storage and visualization.&lt;/p&gt;
&lt;h3 id=&#34;configure-metrics&#34;&gt;Configure metrics&lt;/h3&gt;
&lt;p&gt;The metrics configuration in this scenario requires four components that work together to collect, process, and forward system metrics.
The components are configured in this order to create a data pipeline:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;prometheus.exporter.unix&lt;/code&gt; - collects system metrics&lt;/li&gt;
&lt;li&gt;&lt;code&gt;discovery.relabel&lt;/code&gt; - adds standard labels to metrics&lt;/li&gt;
&lt;li&gt;&lt;code&gt;prometheus.scrape&lt;/code&gt; - scrapes metrics from the exporter&lt;/li&gt;
&lt;li&gt;&lt;code&gt;prometheus.remote_write&lt;/code&gt; - sends metrics to Prometheus for storage&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;prometheusexporterunix&#34;&gt;&lt;code&gt;prometheus.exporter.unix&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/prometheus/prometheus.exporter.unix/&#34;&gt;&lt;code&gt;prometheus.exporter.unix&lt;/code&gt;&lt;/a&gt; component exposes hardware and Linux kernel metrics.
This component is the primary data source that collects system performance metrics from your Linux server.&lt;/p&gt;
&lt;p&gt;The component configuration includes several important sections:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;disable_collectors&lt;/code&gt;: Disables specific collectors to reduce unnecessary overhead&lt;/li&gt;
&lt;li&gt;&lt;code&gt;enable_collectors&lt;/code&gt;: Enables the &lt;code&gt;meminfo&lt;/code&gt; collector for memory information&lt;/li&gt;
&lt;li&gt;&lt;code&gt;filesystem&lt;/code&gt;: Configures filesystem monitoring options&lt;/li&gt;
&lt;li&gt;&lt;code&gt;netclass&lt;/code&gt; and &lt;code&gt;netdev&lt;/code&gt;: Configure network interface monitoring&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;prometheus.exporter.unix &amp;#34;integrations_node_exporter&amp;#34; {
  disable_collectors = [&amp;#34;ipvs&amp;#34;, &amp;#34;btrfs&amp;#34;, &amp;#34;infiniband&amp;#34;, &amp;#34;xfs&amp;#34;, &amp;#34;zfs&amp;#34;]
  enable_collectors = [&amp;#34;meminfo&amp;#34;]

  filesystem {
    fs_types_exclude     = &amp;#34;^(autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|tmpfs|fusectl|hugetlbfs|iso9660|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs)$&amp;#34;
    mount_points_exclude = &amp;#34;^/(dev|proc|run/credentials/.&amp;#43;|sys|var/lib/docker/.&amp;#43;)($|/)&amp;#34;
    mount_timeout        = &amp;#34;5s&amp;#34;
  }

  netclass {
    ignored_devices = &amp;#34;^(veth.*|cali.*|[a-f0-9]{15})$&amp;#34;
  }

  netdev {
    device_exclude = &amp;#34;^(veth.*|cali.*|[a-f0-9]{15})$&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This component provides the &lt;code&gt;prometheus.exporter.unix.integrations_node_exporter.targets&lt;/code&gt; output that feeds into the &lt;code&gt;discovery.relabel&lt;/code&gt; component.&lt;/p&gt;
&lt;h4 id=&#34;discoveryrelabel-instance-and-job-labels&#34;&gt;&lt;code&gt;discovery.relabel&lt;/code&gt; instance and job labels&lt;/h4&gt;
&lt;p&gt;The first 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/discovery/discovery.relabel/&#34;&gt;&lt;code&gt;discovery.relabel&lt;/code&gt;&lt;/a&gt; component in this configuration replaces the instance and job labels from the &lt;code&gt;node_exporter&lt;/code&gt; with standardized values.
This ensures consistent labeling across all metrics for easier querying and dashboard creation.&lt;/p&gt;
&lt;p&gt;In this example, this component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;targets&lt;/code&gt;: The targets to relabel.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;source_labels&lt;/code&gt;: The list of labels to select for relabeling. The rules extract the instance and job labels.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;replacement&lt;/code&gt;: The value that replaces the source label. The rules set the target labels to &lt;code&gt;constants.hostname&lt;/code&gt;, and &lt;code&gt;integrations/node_exporter&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;discovery.relabel &amp;#34;integrations_node_exporter&amp;#34; {
  targets = prometheus.exporter.unix.integrations_node_exporter.targets

  rule {
    target_label = &amp;#34;instance&amp;#34;
    replacement  = constants.hostname
  }

  rule {
    target_label = &amp;#34;job&amp;#34;
    replacement = &amp;#34;integrations/node_exporter&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This component provides the &lt;code&gt;discovery.relabel.integrations_node_exporter.output&lt;/code&gt; target list that feeds into the &lt;code&gt;prometheus.scrape&lt;/code&gt; component.&lt;/p&gt;
&lt;h4 id=&#34;discoveryrelabel-for-systemd-journal-logs&#34;&gt;&lt;code&gt;discovery.relabel&lt;/code&gt; for systemd journal logs&lt;/h4&gt;
&lt;p&gt;This 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/discovery/discovery.relabel/&#34;&gt;&lt;code&gt;discovery.relabel&lt;/code&gt;&lt;/a&gt; component defines the relabeling rules for the systemd journal logs.
In this example, this component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;targets&lt;/code&gt;: The targets to relabel.
No targets are modified, so the &lt;code&gt;targets&lt;/code&gt; argument is an empty array.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;source_labels&lt;/code&gt;: The list of labels to select for relabeling. The rules extract the systemd unit, ID, transport, and log priority.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;target_label&lt;/code&gt;: The label written to the target. The rules set the target labels to &lt;code&gt;unit&lt;/code&gt;, &lt;code&gt;boot_id&lt;/code&gt;, &lt;code&gt;transport&lt;/code&gt;, and &lt;code&gt;level&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;discovery.relabel &amp;#34;logs_integrations_integrations_node_exporter_journal_scrape&amp;#34; {
  targets = []

  rule {
    source_labels = [&amp;#34;__journal__systemd_unit&amp;#34;]
    target_label  = &amp;#34;unit&amp;#34;
  }

  rule {
    source_labels = [&amp;#34;__journal__boot_id&amp;#34;]
    target_label  = &amp;#34;boot_id&amp;#34;
  }

  rule {
    source_labels = [&amp;#34;__journal__transport&amp;#34;]
    target_label  = &amp;#34;transport&amp;#34;
  }

  rule {
    source_labels = [&amp;#34;__journal_priority_keyword&amp;#34;]
    target_label  = &amp;#34;level&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This component provides the &lt;code&gt;discovery.relabel.logs_integrations_integrations_node_exporter_journal_scrape.rules&lt;/code&gt; relabeling rules that feed into the &lt;code&gt;loki.source.journal&lt;/code&gt; component.&lt;/p&gt;
&lt;h4 id=&#34;prometheusscrape&#34;&gt;&lt;code&gt;prometheus.scrape&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/prometheus/prometheus.scrape/&#34;&gt;&lt;code&gt;prometheus.scrape&lt;/code&gt;&lt;/a&gt; component scrapes &lt;code&gt;node_exporter&lt;/code&gt; metrics and forwards them to a receiver.
This component consumes the labeled targets from the &lt;code&gt;discovery.relabel.integrations_node_exporter.output&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In this example, the component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;targets&lt;/code&gt;: The target to scrape metrics from. Use the targets with labels from the &lt;code&gt;discovery.relabel&lt;/code&gt; component.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;forward_to&lt;/code&gt;: The destination to forward metrics to. Send the scraped metrics to the relabeling component.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;scrape_interval&lt;/code&gt;: The frequency of scraping the target.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;prometheus.scrape &amp;#34;integrations_node_exporter&amp;#34; {
  scrape_interval = &amp;#34;15s&amp;#34;
  targets    = discovery.relabel.integrations_node_exporter.output
  forward_to = [prometheus.remote_write.local.receiver]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This component provides scraped metrics that feed into the &lt;code&gt;prometheus.remote_write.local.receiver&lt;/code&gt; for storage in Prometheus.&lt;/p&gt;
&lt;h4 id=&#34;prometheusremote_write&#34;&gt;&lt;code&gt;prometheus.remote_write&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/prometheus/prometheus.remote_write/&#34;&gt;&lt;code&gt;prometheus.remote_write&lt;/code&gt;&lt;/a&gt; component sends metrics to a Prometheus server.
In this example, the component requires the following argument:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;url&lt;/code&gt;: Defines the full URL endpoint to send metrics to.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;prometheus.remote_write &amp;#34;local&amp;#34; {
  endpoint {
    url = &amp;#34;http://prometheus:9090/api/v1/write&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This component provides the &lt;code&gt;prometheus.remote_write.local.receiver&lt;/code&gt; destination that receives metrics from the &lt;code&gt;prometheus.scrape&lt;/code&gt; component.&lt;/p&gt;
&lt;h3 id=&#34;configure-logging&#34;&gt;Configure logging&lt;/h3&gt;
&lt;p&gt;The logging configuration in this scenario collects logs from both systemd journal and standard log files.
This dual approach ensures comprehensive log coverage for most Linux systems.
The configuration requires four main components that work together to discover, collect, and forward logs to Loki:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;loki.source.journal&lt;/code&gt; - collects logs from systemd journal&lt;/li&gt;
&lt;li&gt;&lt;code&gt;local.file_match&lt;/code&gt; - discovers standard log files using glob patterns&lt;/li&gt;
&lt;li&gt;&lt;code&gt;loki.source.file&lt;/code&gt; - reads logs from discovered files&lt;/li&gt;
&lt;li&gt;&lt;code&gt;loki.write&lt;/code&gt; - sends all collected logs to Loki for storage&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;lokisourcejournal&#34;&gt;&lt;code&gt;loki.source.journal&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/loki/loki.source.journal/&#34;&gt;&lt;code&gt;loki.source.journal&lt;/code&gt;&lt;/a&gt; component collects logs from the systemd journal and forwards them to a Loki receiver.
This component consumes the relabeling rules from &lt;code&gt;discovery.relabel.logs_integrations_integrations_node_exporter_journal_scrape.rules&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In this example, the component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;max_age&lt;/code&gt;: Only collect logs from the last 24 hours.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;relabel_rules&lt;/code&gt;: Relabeling rules to apply on log entries.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;forward_to&lt;/code&gt;: Send logs to the local Loki instance.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;loki.source.journal &amp;#34;logs_integrations_integrations_node_exporter_journal_scrape&amp;#34; {
  max_age       = &amp;#34;24h0m0s&amp;#34;
  relabel_rules = discovery.relabel.logs_integrations_integrations_node_exporter_journal_scrape.rules
  forward_to    = [loki.write.local.receiver]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This component provides systemd journal log entries that feed into the &lt;code&gt;loki.write.local.receiver&lt;/code&gt; for storage in Loki.&lt;/p&gt;
&lt;h4 id=&#34;localfile_match&#34;&gt;&lt;code&gt;local.file_match&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/local/local.file_match/&#34;&gt;&lt;code&gt;local.file_match&lt;/code&gt;&lt;/a&gt; component discovers files on the local filesystem using glob patterns.
In this example, the component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;path_targets&lt;/code&gt;: Targets to expand:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__address__&lt;/code&gt;: Targets the localhost for log collection.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;__path__&lt;/code&gt;: Collect standard system logs.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;instance&lt;/code&gt;: Add an instance label with hostname.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;job&lt;/code&gt;: Add a job label for logs.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;local.file_match &amp;#34;logs_integrations_integrations_node_exporter_direct_scrape&amp;#34; {
  path_targets = [{
    __address__ = &amp;#34;localhost&amp;#34;,
    __path__    = &amp;#34;/var/log/{syslog,messages,*.log}&amp;#34;,
    instance    = constants.hostname,
    job         = &amp;#34;integrations/node_exporter&amp;#34;,
  }]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This component provides the &lt;code&gt;local.file_match.logs_integrations_integrations_node_exporter_direct_scrape.targets&lt;/code&gt; file list that feeds into the &lt;code&gt;loki.source.file&lt;/code&gt; component.&lt;/p&gt;
&lt;h4 id=&#34;lokisourcefile&#34;&gt;&lt;code&gt;loki.source.file&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/loki/loki.source.file/&#34;&gt;&lt;code&gt;loki.source.file&lt;/code&gt;&lt;/a&gt; component reads log entries from files and forwards them to other Loki components.
This component consumes the file targets from &lt;code&gt;local.file_match.logs_integrations_integrations_node_exporter_direct_scrape.targets&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In this example, the component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;targets&lt;/code&gt;: The list of files to read logs from.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;forward_to&lt;/code&gt;: The list of receivers to send log entries to.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;loki.source.file &amp;#34;logs_integrations_integrations_node_exporter_direct_scrape&amp;#34; {
  targets    = local.file_match.logs_integrations_integrations_node_exporter_direct_scrape.targets
  forward_to = [loki.write.local.receiver]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This component provides file-based log entries that feed into the &lt;code&gt;loki.write.local.receiver&lt;/code&gt; for storage in Loki.&lt;/p&gt;
&lt;h4 id=&#34;lokiwrite&#34;&gt;&lt;code&gt;loki.write&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/loki/loki.write/&#34;&gt;&lt;code&gt;loki.write&lt;/code&gt;&lt;/a&gt; component writes logs to a Loki destination.
In this example, the component requires the following argument:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;url&lt;/code&gt;: Defines the full URL endpoint in Loki to send logs to.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;loki.write &amp;#34;local&amp;#34; {
  endpoint {
    url = &amp;#34;http://loki:3100/loki/api/v1/push&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This component provides the &lt;code&gt;loki.write.local.receiver&lt;/code&gt; destination that receives log entries from both &lt;code&gt;loki.source.journal&lt;/code&gt; and &lt;code&gt;loki.source.file&lt;/code&gt; components.&lt;/p&gt;
&lt;h3 id=&#34;configure-livedebugging&#34;&gt;Configure &lt;code&gt;livedebugging&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;livedebugging&lt;/code&gt; feature streams real-time data from your components directly to the Alloy UI.
This capability helps you troubleshoot configuration issues and monitor component behavior in real-time.&lt;/p&gt;
&lt;h4 id=&#34;livedebugging&#34;&gt;&lt;code&gt;livedebugging&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;livedebugging&lt;/code&gt; is disabled by default.
Enable it explicitly through the &lt;code&gt;livedebugging&lt;/code&gt; configuration block to make debugging data visible in the Alloy UI.
You can use an empty configuration for this block and Alloy uses the default values.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;livedebugging{}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;For more information about using this feature for troubleshooting, refer to the &lt;a href=&#34;/docs/alloy/latest/troubleshoot/debug/#live-debugging-page&#34;&gt;Troubleshooting documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;next-steps&#34;&gt;Next steps&lt;/h2&gt;
&lt;p&gt;Now that you&amp;rsquo;ve successfully deployed and configured Alloy to monitor Linux systems, you can:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;/docs/alloy/latest/tutorials/&#34;&gt;Configure Alloy to collect metrics from applications&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;/docs/grafana/latest/alerting/&#34;&gt;Set up alerting rules in Grafana&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/&#34;&gt;Explore advanced Alloy component configurations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;/docs/alloy/latest/set-up/&#34;&gt;Deploy Alloy in production environments&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;/docs/alloy/latest/configure/&#34;&gt;Monitor multiple Linux servers with a centralized configuration&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For additional examples and configurations, refer to the &lt;a href=&#34;https://github.com/grafana/alloy-scenarios&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;alloy-scenarios repository&lt;/a&gt;.&lt;/p&gt;
]]></content><description>&lt;h1 id="monitor-linux-servers-with-grafana-alloy">Monitor Linux servers with Grafana Alloy&lt;/h1>
&lt;p>The Linux operating system generates a wide range of metrics and logs that you can use to monitor the health and performance of your hardware and operating system.
With Alloy, you can collect your metrics and logs, forward them to a Grafana stack, and create dashboards to monitor your Linux servers.&lt;/p></description></item><item><title>Monitor Microsoft Windows servers and desktops with Grafana Alloy</title><link>https://grafana.com/docs/alloy/v1.15/monitor/monitor-windows/</link><pubDate>Mon, 30 Mar 2026 15:47:22 +0000</pubDate><guid>https://grafana.com/docs/alloy/v1.15/monitor/monitor-windows/</guid><content><![CDATA[&lt;h1 id=&#34;monitor-microsoft-windows-servers-and-desktops-with-grafana-alloy&#34;&gt;Monitor Microsoft Windows servers and desktops with Grafana Alloy&lt;/h1&gt;
&lt;p&gt;Microsoft Windows provides tools like Performance Monitor and Event Viewer to track system performance metrics and event logs.
With Alloy, you can collect your performance metrics and event logs, forward them to a Grafana stack, and create dashboards to monitor your Windows performance and events.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&#34;https://github.com/grafana/alloy-scenarios/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;alloy-scenarios&lt;/code&gt;&lt;/a&gt; repository contains complete examples of Alloy deployments.
Clone the repository and use the examples to understand how Alloy collects, processes, and exports telemetry signals.&lt;/p&gt;
&lt;p&gt;In this example scenario, Alloy collects Windows performance metrics and event logs and forwards them to a Loki destination.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Ensure you have the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.docker.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://git-scm.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Git&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;A Windows Server or Desktop. This scenario monitors a computer running Windows.&lt;/li&gt;
&lt;li&gt;Windows administrator access. You need administrator access to install Alloy and configure it to collect metrics and logs.&lt;/li&gt;
&lt;/ul&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;You need administrator privileges to run &lt;code&gt;docker&lt;/code&gt; commands.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;clone-and-deploy-the-example&#34;&gt;Clone and deploy the example&lt;/h2&gt;
&lt;p&gt;Follow these steps to clone the scenarios repository and deploy the monitoring example:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Clone the Alloy scenarios repository.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&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-shell&#34;&gt;git clone https://github.com/grafana/alloy-scenarios.git&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Start Docker to deploy the Grafana stack.&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;shell&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-shell&#34;&gt;cd alloy-scenarios/windows
docker compose up -d&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Verify the status of the Docker containers:&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;shell&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-shell&#34;&gt;docker ps&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;
    &lt;a href=&#34;/docs/alloy/v1.15/set-up/install/windows/&#34;&gt;Install Alloy&lt;/a&gt; on Windows.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Replace the default &lt;code&gt;config.alloy&lt;/code&gt; file with the preconfigured &lt;code&gt;config.alloy&lt;/code&gt; file included in the &lt;code&gt;alloy-scenarios/windows&lt;/code&gt; directory.
For detailed steps explaining how to stop and start the Alloy service, refer to 
    &lt;a href=&#34;/docs/alloy/v1.15/configure/windows/&#34;&gt;Configure Alloy on Windows&lt;/a&gt;.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Stop the Alloy service.&lt;/li&gt;
&lt;li&gt;Replace the &lt;code&gt;config.alloy&lt;/code&gt; file in &lt;code&gt;C:\Program Files\GrafanaLabs\Alloy&lt;/code&gt; with the &lt;code&gt;config.alloy&lt;/code&gt; file from the &lt;code&gt;alloy-scenarios/windows&lt;/code&gt; directory.&lt;/li&gt;
&lt;li&gt;Start the Alloy service.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) To access the Alloy UI from a remote computer, add &lt;code&gt;--server.http.listen-addr=0.0.0.0:12345&lt;/code&gt; to the Alloy runtime arguments.
For detailed steps explaining how to update this command-line argument, refer to 
    &lt;a href=&#34;/docs/alloy/v1.15/configure/windows/#expose-the-ui-to-other-machines&#34;&gt;Expose the UI to other machines&lt;/a&gt;.
This step makes the Alloy UI available at &lt;code&gt;http://&amp;lt;WINDOWS_IP_ADDRESS&amp;gt;:12345&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) Stop Docker to shut down the Grafana stack when you finish exploring this example.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&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-shell&#34;&gt;docker compose down&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;monitor-and-visualize-your-data&#34;&gt;Monitor and visualize your data&lt;/h2&gt;
&lt;p&gt;Use Grafana to monitor your deployment&amp;rsquo;s health and visualize your data.&lt;/p&gt;
&lt;h3 id=&#34;monitor-alloy&#34;&gt;Monitor Alloy&lt;/h3&gt;
&lt;p&gt;To monitor the health of your Alloy deployment, open your browser and go to &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;/p&gt;
&lt;p&gt;For more information about the Alloy UI, refer to &lt;a href=&#34;/docs/alloy/latest/troubleshoot/debug/&#34;&gt;Debug Grafana Alloy&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;visualize-your-data&#34;&gt;Visualize your data&lt;/h3&gt;
&lt;p&gt;To explore metrics, open your browser and go to &lt;a href=&#34;http://localhost:3000/explore/metrics&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/explore/metrics&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To use the Grafana Logs Drilldown, open your browser and go to &lt;a href=&#34;http://localhost:3000/a/grafana-lokiexplore-app&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/a/grafana-lokiexplore-app&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To create a &lt;a href=&#34;/docs/grafana/latest/getting-started/build-first-dashboard/#create-a-dashboard&#34;&gt;dashboard&lt;/a&gt; to visualize metrics and logs, open your browser and go to &lt;a href=&#34;http://localhost:3000/dashboards&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/dashboards&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;understand-the-alloy-configuration&#34;&gt;Understand the Alloy configuration&lt;/h2&gt;
&lt;p&gt;This example uses a &lt;code&gt;config.alloy&lt;/code&gt; file to configure the Alloy components for metrics and logging.
You can find the &lt;code&gt;config.alloy&lt;/code&gt; file in the cloned repository at &lt;code&gt;alloy-scenarios/windows/&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The configuration includes &lt;code&gt;livedebugging&lt;/code&gt; to stream real-time data to the Alloy UI.&lt;/p&gt;
&lt;h3 id=&#34;configure-metrics&#34;&gt;Configure metrics&lt;/h3&gt;
&lt;p&gt;The metrics configuration in this example requires three components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;prometheus.exporter.windows&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;prometheus.scrape&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;prometheus.remote_write&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;prometheusexporterwindows&#34;&gt;&lt;code&gt;prometheus.exporter.windows&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/prometheus/prometheus.exporter.windows/&#34;&gt;&lt;code&gt;prometheus.exporter.windows&lt;/code&gt;&lt;/a&gt; component exposes hardware and OS metrics for Windows-based systems.
In this example, the component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;enabled_collectors&lt;/code&gt;: The list of collectors to enable.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;prometheus.exporter.windows &amp;#34;default&amp;#34; {
  enabled_collectors = [&amp;#34;cpu&amp;#34;,&amp;#34;cs&amp;#34;,&amp;#34;logical_disk&amp;#34;,&amp;#34;net&amp;#34;,&amp;#34;os&amp;#34;,&amp;#34;service&amp;#34;,&amp;#34;system&amp;#34;, &amp;#34;memory&amp;#34;, &amp;#34;scheduled_task&amp;#34;, &amp;#34;tcp&amp;#34;]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;prometheusscrape&#34;&gt;&lt;code&gt;prometheus.scrape&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/prometheus/prometheus.scrape/&#34;&gt;&lt;code&gt;prometheus.scrape&lt;/code&gt;&lt;/a&gt; component scrapes Windows metrics and forwards them to a receiver.
In this example, the component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;targets&lt;/code&gt;: The target to scrape metrics from.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;forward_to&lt;/code&gt;: The destination to forward metrics to.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;prometheus.scrape &amp;#34;example&amp;#34; {
  targets    = prometheus.exporter.windows.default.targets
  forward_to = [prometheus.remote_write.demo.receiver]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;prometheusremote_write&#34;&gt;&lt;code&gt;prometheus.remote_write&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/prometheus/prometheus.remote_write/&#34;&gt;&lt;code&gt;prometheus.remote_write&lt;/code&gt;&lt;/a&gt; component sends metrics to a Prometheus server.
In this example, the component requires the following argument:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;url&lt;/code&gt;: Defines the full URL endpoint to send metrics to.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;prometheus.remote_write &amp;#34;demo&amp;#34; {
  endpoint {
    url = &amp;#34;http://localhost:9090/api/v1/write&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;configure-logging&#34;&gt;Configure logging&lt;/h3&gt;
&lt;p&gt;The logging configuration in this example requires three components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;loki.source.windowsevent&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;loki.process&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;loki.write&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;lokisourcewindowsevent&#34;&gt;&lt;code&gt;loki.source.windowsevent&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/loki/loki.source.windowsevent/&#34;&gt;&lt;code&gt;loki.source.windowsevent&lt;/code&gt;&lt;/a&gt; component reads events from Windows Event Logs and forwards them to other Loki components.
In this example, the component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;eventlog_name&lt;/code&gt;: The event log to read from.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;use_incoming_timestamp&lt;/code&gt;: Assigns the current timestamp to the log.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;forward_to&lt;/code&gt;: The list of receivers to send log entries to.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;loki.source.windowsevent &amp;#34;application&amp;#34;  {
    eventlog_name = &amp;#34;Application&amp;#34;
    use_incoming_timestamp = true
    forward_to = [loki.process.endpoint.receiver]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;loki.source.windowsevent &amp;#34;System&amp;#34;  {
    eventlog_name = &amp;#34;System&amp;#34;
    use_incoming_timestamp = true
    forward_to = [loki.process.endpoint.receiver]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;lokiprocess&#34;&gt;&lt;code&gt;loki.process&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/loki/loki.process/&#34;&gt;&lt;code&gt;loki.process&lt;/code&gt;&lt;/a&gt; component receives log entries from other Loki components, applies one or more processing stages, and forwards the results to the list of receivers.
In this example, the component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;forward_to&lt;/code&gt;: The list of receivers to send log entries to.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;expressions&lt;/code&gt;: The key-value pairs that define the name of the data extracted and the value that it&amp;rsquo;s populated with.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;values&lt;/code&gt;: The key-value pairs that define the label to set and how to look them up.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;source&lt;/code&gt;: Name from extracted values map to use for the timestamp.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;overwrite_existing&lt;/code&gt;: Overwrite the existing extracted data fields.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;loki.process &amp;#34;endpoint&amp;#34; {
  forward_to = [loki.write.endpoint.receiver]
  stage.json {
      expressions = {
          message = &amp;#34;&amp;#34;,
          Overwritten = &amp;#34;&amp;#34;,
          source = &amp;#34;&amp;#34;,
          computer = &amp;#34;&amp;#34;,
          eventRecordID = &amp;#34;&amp;#34;,
          channel = &amp;#34;&amp;#34;,
          component_id = &amp;#34;&amp;#34;,
          execution_processId = &amp;#34;&amp;#34;,
          execution_processName = &amp;#34;&amp;#34;,
      }
  }

  stage.structured_metadata {
      values = {
          &amp;#34;eventRecordID&amp;#34; = &amp;#34;&amp;#34;,
          &amp;#34;channel&amp;#34; = &amp;#34;&amp;#34;,
          &amp;#34;component_id&amp;#34; = &amp;#34;&amp;#34;,
          &amp;#34;execution_processId&amp;#34; = &amp;#34;&amp;#34;,
          &amp;#34;execution_processName&amp;#34; = &amp;#34;&amp;#34;,
      }
  }

  stage.eventlogmessage {
      source = &amp;#34;message&amp;#34;
      overwrite_existing = true
  }

  stage.labels {
      values = {
          &amp;#34;service_name&amp;#34; = &amp;#34;source&amp;#34;,
      }
  }

  stage.output {
    source = &amp;#34;message&amp;#34;
  }

}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;lokiwrite&#34;&gt;&lt;code&gt;loki.write&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/loki/loki.write/&#34;&gt;&lt;code&gt;loki.write&lt;/code&gt;&lt;/a&gt; component writes the logs out to a Loki destination.
In this example, the component requires the following argument:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;url&lt;/code&gt;: Defines the full URL endpoint in Loki to send logs to.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;loki.write &amp;#34;endpoint&amp;#34; {
    endpoint {
        url =&amp;#34;http://localhost:3100/loki/api/v1/push&amp;#34;
    }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;configure-livedebugging&#34;&gt;Configure &lt;code&gt;livedebugging&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;Livedebugging streams real-time data from components directly to the Alloy UI.
Refer to the &lt;a href=&#34;/docs/alloy/latest/troubleshoot/debug/#live-debugging-page&#34;&gt;Troubleshooting documentation&lt;/a&gt; for more details about this feature.&lt;/p&gt;
&lt;h4 id=&#34;livedebugging&#34;&gt;&lt;code&gt;livedebugging&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;livedebugging&lt;/code&gt; is disabled by default.
Enable it explicitly through the &lt;code&gt;livedebugging&lt;/code&gt; configuration block to make debugging data visible in the Alloy UI.&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;livedebugging {
  enabled = true
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="monitor-microsoft-windows-servers-and-desktops-with-grafana-alloy">Monitor Microsoft Windows servers and desktops with Grafana Alloy&lt;/h1>
&lt;p>Microsoft Windows provides tools like Performance Monitor and Event Viewer to track system performance metrics and event logs.
With Alloy, you can collect your performance metrics and event logs, forward them to a Grafana stack, and create dashboards to monitor your Windows performance and events.&lt;/p></description></item><item><title>Monitor logs from a local file with Grafana Alloy</title><link>https://grafana.com/docs/alloy/v1.15/monitor/monitor-logs-from-file/</link><pubDate>Mon, 30 Mar 2026 15:47:22 +0000</pubDate><guid>https://grafana.com/docs/alloy/v1.15/monitor/monitor-logs-from-file/</guid><content><![CDATA[&lt;h1 id=&#34;monitor-logs-from-a-local-file-with-grafana-alloy&#34;&gt;Monitor logs from a local file with Grafana Alloy&lt;/h1&gt;
&lt;p&gt;Log files record events, activities, and usage patterns within a system, application, or network.
These files are essential for monitoring, troubleshooting, and understanding system behavior.
With Alloy, you can collect your logs, forward them to a Grafana stack, and create dashboards to monitor your system behavior.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&#34;https://github.com/grafana/alloy-scenarios/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;alloy-scenarios&lt;/code&gt;&lt;/a&gt; repository contains complete examples of Alloy deployments.
Clone the repository and use the examples to understand how Alloy collects, processes, and exports telemetry signals.&lt;/p&gt;
&lt;p&gt;In this example scenario, Alloy collects logs from a local file and forwards them to a Loki destination.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Ensure you have the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.docker.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://git-scm.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Git&lt;/a&gt;&lt;/li&gt;
&lt;/ul&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;You need administrator privileges to run &lt;code&gt;docker&lt;/code&gt; commands.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;clone-and-deploy-the-example&#34;&gt;Clone and deploy the example&lt;/h2&gt;
&lt;p&gt;Follow these steps to clone the scenarios repository and deploy the monitoring example:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Clone the Alloy scenarios repository.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&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-shell&#34;&gt;git clone https://github.com/grafana/alloy-scenarios.git&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Start Docker to deploy the Grafana stack.&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;shell&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-shell&#34;&gt;cd alloy-scenarios/logs-file
docker compose up -d&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Verify the status of the Docker containers:&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;shell&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-shell&#34;&gt;docker ps&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) Stop Docker to shut down the Grafana stack when you finish exploring this example.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&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-shell&#34;&gt;docker compose down&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;monitor-and-visualize-your-data&#34;&gt;Monitor and visualize your data&lt;/h2&gt;
&lt;p&gt;Use Grafana to monitor your deployment&amp;rsquo;s health and visualize your data.&lt;/p&gt;
&lt;h3 id=&#34;monitor-alloy&#34;&gt;Monitor Alloy&lt;/h3&gt;
&lt;p&gt;To monitor the health of your Alloy deployment, open your browser and go to &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;/p&gt;
&lt;p&gt;For more information about the Alloy UI, refer to &lt;a href=&#34;/docs/alloy/latest/troubleshoot/debug/&#34;&gt;Debug Grafana Alloy&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;visualize-your-data&#34;&gt;Visualize your data&lt;/h3&gt;
&lt;p&gt;To use the Grafana Logs Drilldown, open your browser and go to &lt;a href=&#34;http://localhost:3000/a/grafana-lokiexplore-app&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/a/grafana-lokiexplore-app&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To create a &lt;a href=&#34;/docs/grafana/latest/getting-started/build-first-dashboard/#create-a-dashboard&#34;&gt;dashboard&lt;/a&gt; for visualizing metrics and logs, open your browser and go to &lt;a href=&#34;http://localhost:3000/dashboards&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/dashboards&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;understand-the-alloy-configuration&#34;&gt;Understand the Alloy configuration&lt;/h2&gt;
&lt;p&gt;This example uses a &lt;code&gt;config.alloy&lt;/code&gt; file to configure the Alloy components for logging.
You can find this file in the cloned repository at &lt;code&gt;alloy-scenarios/logs-file/&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The configuration includes &lt;code&gt;livedebugging&lt;/code&gt; to stream real-time data to the Alloy UI.&lt;/p&gt;
&lt;h3 id=&#34;configure-livedebugging&#34;&gt;Configure &lt;code&gt;livedebugging&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;livedebugging&lt;/code&gt; streams real-time data from your components directly to the Alloy UI.
Refer to the &lt;a href=&#34;/docs/alloy/latest/troubleshoot/debug/#live-debugging-page&#34;&gt;Troubleshooting documentation&lt;/a&gt; for more details about this feature.&lt;/p&gt;
&lt;h4 id=&#34;livedebugging&#34;&gt;&lt;code&gt;livedebugging&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;By default, &lt;code&gt;livedebugging&lt;/code&gt; is disabled.
Enable it explicitly through the &lt;code&gt;livedebugging&lt;/code&gt; configuration block to make debugging data visible in the Alloy UI.&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;livedebugging {
  enabled = true
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;configure-logging&#34;&gt;Configure logging&lt;/h3&gt;
&lt;p&gt;The logging configuration in this example requires three components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;local.file_match&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;loki.source.file&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;loki.write&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;localfile_match&#34;&gt;&lt;code&gt;local.file_match&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/local/local.file_match/&#34;&gt;&lt;code&gt;local.file_match&lt;/code&gt;&lt;/a&gt; component discovers files on the local filesystem using glob patterns.
In this example, the component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;path_targets&lt;/code&gt;: Targets to expand. Looks for glob patterns on the &lt;code&gt;__path__&lt;/code&gt; key.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;sync_period&lt;/code&gt;: How often to sync the filesystem and targets. When files are added or removed, the list of targets is automatically updated based on this configuration. When files are removed, the stored position is removed in the next filesystem sync.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;local.file_match &amp;#34;local_files&amp;#34; {
    path_targets = [{&amp;#34;__path__&amp;#34; = &amp;#34;/temp/logs/*.log&amp;#34;, &amp;#34;job&amp;#34; = &amp;#34;python&amp;#34;, &amp;#34;hostname&amp;#34; = constants.hostname}]
    sync_period  = &amp;#34;5s&amp;#34;
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;lokisourcefile&#34;&gt;&lt;code&gt;loki.source.file&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/loki/loki.source.file/&#34;&gt;&lt;code&gt;loki.source.file&lt;/code&gt;&lt;/a&gt; component reads log entries from files and forwards them to other Loki components.
In this example, the component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;targets&lt;/code&gt;: The list of files to read logs from.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;forward_to&lt;/code&gt;: The list of receivers to send log entries to.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;tail_from_end&lt;/code&gt;: Whether a log file is tailed from the end if a stored position isn&amp;rsquo;t found.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;loki.source.file &amp;#34;log_scrape&amp;#34; {
    targets    = local.file_match.local_files.targets
    forward_to = [loki.write.local.receiver]
    tail_from_end = true
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;lokiwrite&#34;&gt;&lt;code&gt;loki.write&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/loki/loki.write/&#34;&gt;&lt;code&gt;loki.write&lt;/code&gt;&lt;/a&gt; component writes logs to a Loki destination.
In this example, the component requires the following argument:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;url&lt;/code&gt;: Defines the full URL endpoint in Loki to send logs to.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;loki.write &amp;#34;local&amp;#34; {
  endpoint {
    url = &amp;#34;http://loki:3100/loki/api/v1/push&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="monitor-logs-from-a-local-file-with-grafana-alloy">Monitor logs from a local file with Grafana Alloy&lt;/h1>
&lt;p>Log files record events, activities, and usage patterns within a system, application, or network.
These files are essential for monitoring, troubleshooting, and understanding system behavior.
With Alloy, you can collect your logs, forward them to a Grafana stack, and create dashboards to monitor your system behavior.&lt;/p></description></item><item><title>Monitor TCP logs with Grafana Alloy</title><link>https://grafana.com/docs/alloy/v1.15/monitor/monitor-logs-over-tcp/</link><pubDate>Mon, 30 Mar 2026 15:47:22 +0000</pubDate><guid>https://grafana.com/docs/alloy/v1.15/monitor/monitor-logs-over-tcp/</guid><content><![CDATA[&lt;h1 id=&#34;monitor-tcp-logs-with-grafana-alloy&#34;&gt;Monitor TCP logs with Grafana Alloy&lt;/h1&gt;
&lt;p&gt;Writing logs over a network using raw TCP is a widely used method for transmitting log data between systems.
This method provides a direct, connection-oriented way to send logs from a client, such as an application or logging agent, to a remote server, such as a log aggregator or central logging system.
With Alloy, you can collect your logs, forward them to a Grafana stack, and create dashboards to monitor your system behavior.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&#34;https://github.com/grafana/alloy-scenarios/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;alloy-scenarios&lt;/code&gt;&lt;/a&gt; repository contains complete working examples of Alloy deployments.
Clone the repository and use the example deployments to understand how Alloy collects, processes, and exports telemetry signals.&lt;/p&gt;
&lt;p&gt;In this example scenario, Alloy uses a TCP endpoint to collect logs written by an application as a JSON payload and forwards them to a Loki destination.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Ensure you have the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.docker.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://git-scm.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Git&lt;/a&gt;&lt;/li&gt;
&lt;/ul&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;You need administrator privileges to run &lt;code&gt;docker&lt;/code&gt; commands.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;clone-and-deploy-the-example&#34;&gt;Clone and deploy the example&lt;/h2&gt;
&lt;p&gt;Follow these steps to clone the scenarios repository and deploy the monitoring example:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Clone the Alloy scenarios repository:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&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-shell&#34;&gt;git clone https://github.com/grafana/alloy-scenarios.git&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Start Docker to deploy the Grafana stack:&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;shell&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-shell&#34;&gt;cd alloy-scenarios/logs-tcp
docker compose up -d&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Verify the status of the Docker containers:&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;shell&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-shell&#34;&gt;docker ps&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) Stop Docker to shut down the Grafana stack when you finish exploring this example:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&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-shell&#34;&gt;docker compose down&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;monitor-and-visualize-your-data&#34;&gt;Monitor and visualize your data&lt;/h2&gt;
&lt;p&gt;Use Grafana to monitor your deployment&amp;rsquo;s health and visualize your data.&lt;/p&gt;
&lt;h3 id=&#34;monitor-alloy&#34;&gt;Monitor Alloy&lt;/h3&gt;
&lt;p&gt;To monitor the health of your Alloy deployment, open your browser and go to &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;/p&gt;
&lt;p&gt;For more information about the Alloy UI, refer to &lt;a href=&#34;/docs/alloy/latest/troubleshoot/debug/&#34;&gt;Debug Grafana Alloy&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;visualize-your-data&#34;&gt;Visualize your data&lt;/h3&gt;
&lt;p&gt;To use the Grafana Logs Drilldown, open your browser and go to &lt;a href=&#34;http://localhost:3000/a/grafana-lokiexplore-app&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/a/grafana-lokiexplore-app&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To create a &lt;a href=&#34;/docs/grafana/latest/getting-started/build-first-dashboard/#create-a-dashboard&#34;&gt;dashboard&lt;/a&gt; to visualize your metrics and logs, open your browser and go to &lt;a href=&#34;http://localhost:3000/dashboards&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/dashboards&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;understand-the-alloy-configuration&#34;&gt;Understand the Alloy configuration&lt;/h2&gt;
&lt;p&gt;This example uses a &lt;code&gt;config.alloy&lt;/code&gt; file to configure the Alloy components for logging.
You can find the &lt;code&gt;config.alloy&lt;/code&gt; file in the cloned repository at &lt;code&gt;alloy-scenarios/logs-tcp/&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The configuration includes &lt;code&gt;livedebugging&lt;/code&gt; to stream real-time data to the Alloy UI.&lt;/p&gt;
&lt;h3 id=&#34;configure-livedebugging&#34;&gt;Configure &lt;code&gt;livedebugging&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;livedebugging&lt;/code&gt; streams real-time data from your components directly to the Alloy UI.
Refer to the &lt;a href=&#34;/docs/alloy/latest/troubleshoot/debug/#live-debugging-page&#34;&gt;Troubleshooting documentation&lt;/a&gt; for more details about this feature.&lt;/p&gt;
&lt;h4 id=&#34;livedebugging&#34;&gt;&lt;code&gt;livedebugging&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;livedebugging&lt;/code&gt; is disabled by default.
Enable it explicitly through the &lt;code&gt;livedebugging&lt;/code&gt; configuration block to make debugging data visible in the Alloy UI.&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;livedebugging {
  enabled = true
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;configure-logging&#34;&gt;Configure logging&lt;/h3&gt;
&lt;p&gt;The logging configuration in this example requires three components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;loki.source.api&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;loki.process&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;loki-write&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;lokisourceapi&#34;&gt;&lt;code&gt;loki.source.api&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/loki/loki.source.api/&#34;&gt;&lt;code&gt;loki.source.api&lt;/code&gt;&lt;/a&gt; component receives log entries over HTTP and forwards them to other Loki components.
In this example, the component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;listen_address&lt;/code&gt;: The network address the server listens to for new connections. Setting this argument to &lt;code&gt;0.0.0.0&lt;/code&gt; tells the server to listen on all IP addresses.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;listen_port&lt;/code&gt;: The port the server listens to for new connections.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;forward_to&lt;/code&gt;: The list of receivers to send log entries to.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;loki.source.api &amp;#34;loki_push_api&amp;#34; {
    http {
        listen_address = &amp;#34;0.0.0.0&amp;#34;
        listen_port = 9999
    }
    forward_to = [
        loki.process.labels.receiver,
    ]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;lokiprocess&#34;&gt;&lt;code&gt;loki.process&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/loki/loki.process/&#34;&gt;&lt;code&gt;loki.process&lt;/code&gt;&lt;/a&gt; component receives log entries from other Loki components, applies processing stages, and forwards the results to the list of receivers.
In this example, the component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;expressions&lt;/code&gt;: Key-value pairs defining the name of the data extracted and the value it&amp;rsquo;s populated with.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;values&lt;/code&gt;: Key-value pairs defining the label to set and how to look them up.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;forward_to&lt;/code&gt;: The list of receivers to send log entries to.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;loki.process &amp;#34;labels&amp;#34; {
    stage.json {
      expressions = { &amp;#34;extracted_service&amp;#34; = &amp;#34;service_name&amp;#34;, 
                      &amp;#34;extracted_code_line&amp;#34; = &amp;#34;code_line&amp;#34;, 
                      &amp;#34;extracted_server&amp;#34; = &amp;#34;server_id&amp;#34;, 
                    }
    }

  stage.labels {
    values = {
      &amp;#34;service_name&amp;#34; = &amp;#34;extracted_service&amp;#34;,
    }
  }

  stage.structured_metadata {
    values = {
      &amp;#34;code_line&amp;#34; = &amp;#34;extracted_code_line&amp;#34;,
      &amp;#34;server&amp;#34; = &amp;#34;extracted_server&amp;#34;,
      }
    }

  forward_to = [loki.write.local.receiver]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;loki-write&#34;&gt;&lt;code&gt;loki-write&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/loki/loki.write/&#34;&gt;&lt;code&gt;loki.write&lt;/code&gt;&lt;/a&gt; component writes the logs to a Loki destination.
In this example, the component requires the following argument:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;url&lt;/code&gt;: Defines the full URL endpoint in Loki to send logs to.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;loki.write &amp;#34;local&amp;#34; {
  endpoint {
    url = &amp;#34;http://loki:3100/loki/api/v1/push&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="monitor-tcp-logs-with-grafana-alloy">Monitor TCP logs with Grafana Alloy&lt;/h1>
&lt;p>Writing logs over a network using raw TCP is a widely used method for transmitting log data between systems.
This method provides a direct, connection-oriented way to send logs from a client, such as an application or logging agent, to a remote server, such as a log aggregator or central logging system.
With Alloy, you can collect your logs, forward them to a Grafana stack, and create dashboards to monitor your system behavior.&lt;/p></description></item><item><title>Monitor RFC5424-compliant syslog messages with Grafana Alloy</title><link>https://grafana.com/docs/alloy/v1.15/monitor/monitor-syslog-messages/</link><pubDate>Mon, 30 Mar 2026 15:47:22 +0000</pubDate><guid>https://grafana.com/docs/alloy/v1.15/monitor/monitor-syslog-messages/</guid><content><![CDATA[&lt;h1 id=&#34;monitor-rfc5424-compliant-syslog-messages-with-grafana-alloy&#34;&gt;Monitor RFC5424-compliant syslog messages with Grafana Alloy&lt;/h1&gt;
&lt;p&gt;RFC5424-compliant syslog messages follow a well-defined, standardized structure for logging.
These logs include fields such as priority, timestamp, hostname, application name, process ID, message ID, structured data, and the actual message.
With Alloy, you can collect your logs, forward them to a Grafana stack, and create dashboards to monitor your system behavior.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&#34;https://github.com/grafana/alloy-scenarios/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;alloy-scenarios&lt;/code&gt;&lt;/a&gt; repository contains complete examples of Alloy deployments.
Clone the repository and use the examples to understand how Alloy collects, processes, and exports telemetry signals.&lt;/p&gt;
&lt;p&gt;In this example scenario, Alloy listens for syslog messages over TCP or UDP connections and forwards them to a Loki destination.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Ensure you have the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.docker.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://git-scm.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Git&lt;/a&gt;&lt;/li&gt;
&lt;/ul&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;You need administrator privileges to run &lt;code&gt;docker&lt;/code&gt; commands.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;clone-and-deploy-the-example&#34;&gt;Clone and deploy the example&lt;/h2&gt;
&lt;p&gt;Follow these steps to clone the scenarios repository and deploy the monitoring example:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Clone the Alloy scenarios repository.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&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-shell&#34;&gt;git clone https://github.com/grafana/alloy-scenarios.git&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Start Docker to deploy the Grafana stack.&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;shell&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-shell&#34;&gt;cd alloy-scenarios/syslog
docker compose up -d&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Verify the status of the Docker containers:&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;shell&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-shell&#34;&gt;docker ps&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) Stop Docker to shut down the Grafana stack when you finish exploring this example.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&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-shell&#34;&gt;docker compose down&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;monitor-and-visualize-your-data&#34;&gt;Monitor and visualize your data&lt;/h2&gt;
&lt;p&gt;Use Grafana to monitor your deployment&amp;rsquo;s health and visualize your data.&lt;/p&gt;
&lt;h3 id=&#34;monitor-alloy&#34;&gt;Monitor Alloy&lt;/h3&gt;
&lt;p&gt;To monitor the health of your Alloy deployment, open your browser and go to &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;/p&gt;
&lt;p&gt;For more information about the Alloy UI, refer to &lt;a href=&#34;/docs/alloy/latest/troubleshoot/debug/&#34;&gt;Debug Grafana Alloy&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;visualize-your-data&#34;&gt;Visualize your data&lt;/h3&gt;
&lt;p&gt;To use the Grafana Logs Drilldown, open your browser and go to &lt;a href=&#34;http://localhost:3000/a/grafana-lokiexplore-app&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/a/grafana-lokiexplore-app&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To create a &lt;a href=&#34;/docs/grafana/latest/getting-started/build-first-dashboard/#create-a-dashboard&#34;&gt;dashboard&lt;/a&gt; to visualize metrics and logs, open your browser and go to &lt;a href=&#34;http://localhost:3000/dashboards&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/dashboards&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;understand-the-alloy-configuration&#34;&gt;Understand the Alloy configuration&lt;/h2&gt;
&lt;p&gt;This example uses a &lt;code&gt;config.alloy&lt;/code&gt; file to configure Alloy components for logging.
You can find the &lt;code&gt;config.alloy&lt;/code&gt; file in the cloned repository at &lt;code&gt;alloy-scenarios/syslog/&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The configuration includes &lt;code&gt;livedebugging&lt;/code&gt; to stream real-time data to the Alloy UI.&lt;/p&gt;
&lt;h3 id=&#34;configure-livedebugging&#34;&gt;Configure &lt;code&gt;livedebugging&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;Livedebugging streams real-time data from components directly to the Alloy UI.
Refer to the &lt;a href=&#34;/docs/alloy/latest/troubleshoot/debug/#live-debugging-page&#34;&gt;Troubleshooting documentation&lt;/a&gt; for more details about this feature.&lt;/p&gt;
&lt;h4 id=&#34;livedebugging&#34;&gt;&lt;code&gt;livedebugging&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;livedebugging&lt;/code&gt; is disabled by default.
Enable it explicitly through the &lt;code&gt;livedebugging&lt;/code&gt; configuration block to make debugging data visible in the Alloy UI.&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;livedebugging {
  enabled = true
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;configure-logging&#34;&gt;Configure logging&lt;/h3&gt;
&lt;p&gt;The logging configuration in this example requires two components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;loki.source.syslog&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;loki.write&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;lokisourcesyslog&#34;&gt;&lt;code&gt;loki.source.syslog&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/loki/loki.source.syslog/&#34;&gt;&lt;code&gt;loki.source.syslog&lt;/code&gt;&lt;/a&gt; component listens for syslog messages over TCP or UDP connections and forwards them to other Loki components.
In this example, the component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;address&lt;/code&gt;: The host and port address to listen to for syslog messages.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;protocol&lt;/code&gt;: The protocol to listen to for syslog messages. The default is TCP.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;labels&lt;/code&gt;: The labels to associate with each received syslog record.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;forward_to&lt;/code&gt;: The list of receivers to send log entries to.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;loki.source.syslog &amp;#34;local&amp;#34; {
  listener {
    address  = &amp;#34;0.0.0.0:51893&amp;#34;
    labels   = { component = &amp;#34;loki.source.syslog&amp;#34;, protocol = &amp;#34;tcp&amp;#34; }
  }

  listener {
    address  = &amp;#34;0.0.0.0:51898&amp;#34;
    protocol = &amp;#34;udp&amp;#34;
    labels   = { component = &amp;#34;loki.source.syslog&amp;#34;, protocol = &amp;#34;udp&amp;#34; }
  }

  forward_to = [loki.write.local.receiver]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;lokiwrite&#34;&gt;&lt;code&gt;loki.write&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/loki/loki.write/&#34;&gt;&lt;code&gt;loki.write&lt;/code&gt;&lt;/a&gt; component writes logs to a Loki destination.
In this example, the component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;url&lt;/code&gt;: Defines the full URL endpoint in Loki to send logs to.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;loki.write &amp;#34;local&amp;#34; {
  endpoint {
    url = &amp;#34;http://loki:3100/loki/api/v1/push&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="monitor-rfc5424-compliant-syslog-messages-with-grafana-alloy">Monitor RFC5424-compliant syslog messages with Grafana Alloy&lt;/h1>
&lt;p>RFC5424-compliant syslog messages follow a well-defined, standardized structure for logging.
These logs include fields such as priority, timestamp, hostname, application name, process ID, message ID, structured data, and the actual message.
With Alloy, you can collect your logs, forward them to a Grafana stack, and create dashboards to monitor your system behavior.&lt;/p></description></item><item><title>Monitor structured logs with Grafana Alloy</title><link>https://grafana.com/docs/alloy/v1.15/monitor/monitor-structured-logs/</link><pubDate>Mon, 30 Mar 2026 15:47:22 +0000</pubDate><guid>https://grafana.com/docs/alloy/v1.15/monitor/monitor-structured-logs/</guid><content><![CDATA[&lt;h1 id=&#34;monitor-structured-logs-with-grafana-alloy&#34;&gt;Monitor structured logs with Grafana Alloy&lt;/h1&gt;
&lt;p&gt;Structured logs use a consistent format, such as JSON, to organize data into key-value pairs.
This format makes it easier to search, filter, and analyze log data.
With Alloy, you can collect your logs, forward them to a Grafana stack, and create dashboards to monitor your system behavior.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&#34;https://github.com/grafana/alloy-scenarios/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;alloy-scenarios&lt;/code&gt;&lt;/a&gt; repository contains complete examples of Alloy deployments.
Clone the repository and use the examples to understand how Alloy collects, processes, and exports telemetry signals.&lt;/p&gt;
&lt;p&gt;In this example scenario, Alloy collects log entries over HTTP, parses them into labels and structured metadata, and forwards the results to a Loki destination.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Ensure you have the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.docker.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://git-scm.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Git&lt;/a&gt;&lt;/li&gt;
&lt;/ul&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;You need administrator privileges to run &lt;code&gt;docker&lt;/code&gt; commands.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;clone-and-deploy-the-example&#34;&gt;Clone and deploy the example&lt;/h2&gt;
&lt;p&gt;Follow these steps to clone the scenarios repository and deploy the monitoring example:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Clone the Alloy scenarios repository:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&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-shell&#34;&gt;git clone https://github.com/grafana/alloy-scenarios.git&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Start Docker to deploy the Grafana stack:&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;shell&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-shell&#34;&gt;cd alloy-scenarios/mail-house
docker compose up -d&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Verify the status of the Docker containers:&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;shell&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-shell&#34;&gt;docker ps&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) Stop Docker to shut down the Grafana stack when you finish exploring this example:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&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-shell&#34;&gt;docker compose down&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;monitor-and-visualize-your-data&#34;&gt;Monitor and visualize your data&lt;/h2&gt;
&lt;p&gt;Use Grafana to monitor your deployment&amp;rsquo;s health and visualize your data.&lt;/p&gt;
&lt;h3 id=&#34;monitor-alloy&#34;&gt;Monitor Alloy&lt;/h3&gt;
&lt;p&gt;To monitor the health of your Alloy deployment, open your browser and go to &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;/p&gt;
&lt;p&gt;For more information about the Alloy UI, refer to &lt;a href=&#34;/docs/alloy/latest/troubleshoot/debug/&#34;&gt;Debug Grafana Alloy&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;visualize-your-data&#34;&gt;Visualize your data&lt;/h3&gt;
&lt;p&gt;To use the Grafana Logs Drilldown, open your browser and go to &lt;a href=&#34;http://localhost:3000/a/grafana-lokiexplore-app&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/a/grafana-lokiexplore-app&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To create a &lt;a href=&#34;/docs/grafana/latest/getting-started/build-first-dashboard/#create-a-dashboard&#34;&gt;dashboard&lt;/a&gt; to visualize your metrics and logs, open your browser and go to &lt;a href=&#34;http://localhost:3000/dashboards&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/dashboards&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;understand-the-alloy-configuration&#34;&gt;Understand the Alloy configuration&lt;/h2&gt;
&lt;p&gt;This example uses a &lt;code&gt;config.alloy&lt;/code&gt; file to configure the Alloy components for logging.
You can find the &lt;code&gt;config.alloy&lt;/code&gt; file in the cloned repository at &lt;code&gt;alloy-scenarios/mail-house/&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The configuration includes &lt;code&gt;livedebugging&lt;/code&gt; to stream real-time data to the Alloy UI.&lt;/p&gt;
&lt;h3 id=&#34;configure-livedebugging&#34;&gt;Configure &lt;code&gt;livedebugging&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;livedebugging&lt;/code&gt; streams real-time data from your components directly to the Alloy UI.
Refer to the &lt;a href=&#34;/docs/alloy/latest/troubleshoot/debug/#live-debugging-page&#34;&gt;Troubleshooting documentation&lt;/a&gt; for more details about this feature.&lt;/p&gt;
&lt;h4 id=&#34;livedebugging&#34;&gt;&lt;code&gt;livedebugging&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;livedebugging&lt;/code&gt; is disabled by default.
Enable it explicitly through the &lt;code&gt;livedebugging&lt;/code&gt; configuration block to make debugging data visible in the Alloy UI.&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;livedebugging {
  enabled = true
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;configure-logging&#34;&gt;Configure logging&lt;/h3&gt;
&lt;p&gt;The logging configuration in this example requires three components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;loki.source.api&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;loki.process&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;loki.write&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;lokisourceapi&#34;&gt;&lt;code&gt;loki.source.api&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/loki/loki.source.api/&#34;&gt;&lt;code&gt;loki.source.api&lt;/code&gt;&lt;/a&gt; component receives log entries over HTTP and forwards them to other Loki components.
In this example, the component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;listen_address&lt;/code&gt;: The network address the server listens to for new connections.
Setting this argument to &lt;code&gt;0.0.0.0&lt;/code&gt; tells the server to listen on all IP addresses.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;listen_port&lt;/code&gt;: The port the server listens to for new connections.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;forward_to&lt;/code&gt;: The list of receivers to send log entries to.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;loki.source.api &amp;#34;loki_push_api&amp;#34; {
    http {
        listen_address = &amp;#34;0.0.0.0&amp;#34;
        listen_port = 9999
    }
    forward_to = [
        loki.process.labels.receiver,
    ]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;lokiprocess&#34;&gt;&lt;code&gt;loki.process&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/loki/loki.process/&#34;&gt;&lt;code&gt;loki.process&lt;/code&gt;&lt;/a&gt; component receives log entries from other Loki components, applies processing stages, and forwards the results to the list of receivers.
In this example, the component requires the following arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;expressions&lt;/code&gt;: Key-value pairs defining the name of the data extracted and the value it&amp;rsquo;s populated with.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;source&lt;/code&gt;: Name from extracted values map to use for the timestamp.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;format&lt;/code&gt;: Determines how to parse the source string.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;values&lt;/code&gt;: Key-value pairs defining the label to set and how to look them up.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;forward_to&lt;/code&gt;: The list of receivers to send log entries to.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;loki.process &amp;#34;labels&amp;#34; {
    stage.json {
      expressions = { 
                      &amp;#34;timestamp&amp;#34; = &amp;#34;&amp;#34;,
                      &amp;#34;state&amp;#34; = &amp;#34;&amp;#34;, 
                      &amp;#34;package_size&amp;#34; = &amp;#34;&amp;#34;, 
                      &amp;#34;package_status&amp;#34; = &amp;#34;&amp;#34;, 
                      &amp;#34;package_id&amp;#34; = &amp;#34;&amp;#34;,
                    }
    }

  stage.timestamp {
    source = &amp;#34;timestamp&amp;#34;
    format = &amp;#34;RFC3339&amp;#34;
  }

  stage.labels {
    values = {
      &amp;#34;state&amp;#34; = &amp;#34;&amp;#34;,
      &amp;#34;package_size&amp;#34; = &amp;#34;&amp;#34;,
    }
  }

  stage.structured_metadata {
    values = {
      &amp;#34;package_status&amp;#34; = &amp;#34;&amp;#34;,
      &amp;#34;package_id&amp;#34; = &amp;#34;&amp;#34;,
    }
  }

  stage.static_labels {
    values = {
      &amp;#34;service_name&amp;#34; = &amp;#34;Delivery World&amp;#34;,
    }
  }

  stage.output {
    source = &amp;#34;message&amp;#34;
  }

  forward_to = [loki.write.local.receiver]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;lokiwrite&#34;&gt;&lt;code&gt;loki.write&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/alloy/v1.15/reference/components/loki/loki.write/&#34;&gt;&lt;code&gt;loki.write&lt;/code&gt;&lt;/a&gt; component writes logs to a Loki destination.
In this example, the component requires the following argument:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;url&lt;/code&gt;: Defines the full URL endpoint in Loki to send logs to.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;loki.write &amp;#34;local&amp;#34; {
  endpoint {
    url = &amp;#34;http://loki:3100/loki/api/v1/push&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="monitor-structured-logs-with-grafana-alloy">Monitor structured logs with Grafana Alloy&lt;/h1>
&lt;p>Structured logs use a consistent format, such as JSON, to organize data into key-value pairs.
This format makes it easier to search, filter, and analyze log data.
With Alloy, you can collect your logs, forward them to a Grafana stack, and create dashboards to monitor your system behavior.&lt;/p></description></item><item><title>Monitor Kubernetes logs with Grafana Alloy</title><link>https://grafana.com/docs/alloy/v1.15/monitor/monitor-kubernetes-logs/</link><pubDate>Mon, 30 Mar 2026 15:47:22 +0000</pubDate><guid>https://grafana.com/docs/alloy/v1.15/monitor/monitor-kubernetes-logs/</guid><content><![CDATA[&lt;h1 id=&#34;monitor-kubernetes-logs-with-grafana-alloy&#34;&gt;Monitor Kubernetes logs with Grafana Alloy&lt;/h1&gt;
&lt;p&gt;Kubernetes captures logs from each container in a running Pod.&lt;br /&gt;
With Alloy, you can collect Kubernetes logs, forward them to a Grafana stack, and create dashboards to monitor your Kubernetes Deployment.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&#34;https://github.com/grafana/alloy-scenarios/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;alloy-scenarios&lt;/code&gt;&lt;/a&gt; repository contains complete examples of Alloy deployments.&lt;br /&gt;
Clone the repository and use the examples to understand how Alloy collects, processes, and exports telemetry signals.&lt;/p&gt;
&lt;p&gt;This example scenario uses a Kubernetes Monitoring Helm chart to deploy and monitor Kubernetes logs.&lt;br /&gt;
It installs three Helm charts: Loki, Grafana, and Alloy.&lt;br /&gt;
The Helm chart simplifies configuration and deploys best practices for monitoring Kubernetes clusters.&lt;/p&gt;
&lt;p&gt;Alloy, installed with &lt;code&gt;k8s-monitoring-helm&lt;/code&gt;, collects two log sources: &lt;a href=&#34;https://kubernetes.io/docs/concepts/cluster-administration/logging/#basic-logging-in-kubernetes&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Pod Logs&lt;/a&gt; and &lt;a href=&#34;https://kubernetes.io/docs/reference/kubernetes-api/cluster-resources/event-v1/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Kubernetes Events&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Ensure you have the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.docker.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://git-scm.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Git&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://helm.sh/docs/intro/install/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Helm&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://kind.sigs.k8s.io/docs/user/quick-start/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;kind&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;clone-and-deploy-the-example&#34;&gt;Clone and deploy the example&lt;/h2&gt;
&lt;p&gt;Follow these steps to clone the scenarios repository and deploy the monitoring example:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Clone the Alloy scenarios repository:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&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-shell&#34;&gt;git clone https://github.com/grafana/alloy-scenarios.git&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set up the example Kubernetes environment:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Navigate to the &lt;code&gt;alloy-scenarios/k8s/logs&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;shell&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-shell&#34;&gt;cd alloy-scenarios/k8s/logs&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create a local Kubernetes cluster using kind.&lt;br /&gt;
The &lt;code&gt;kind.yml&lt;/code&gt; file provides the cluster configuration:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&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-shell&#34;&gt;kind create cluster --config kind.yml&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add the Grafana Helm repository:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&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-shell&#34;&gt;helm repo add grafana https://grafana.github.io/helm-charts&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create the &lt;code&gt;meta&lt;/code&gt; and &lt;code&gt;prod&lt;/code&gt; namespaces:&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;shell&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-shell&#34;&gt;kubectl create namespace meta &amp;amp;&amp;amp; \
kubectl create namespace prod&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Deploy Loki in the &lt;code&gt;meta&lt;/code&gt; namespace.&lt;br /&gt;
Loki stores the collected logs.&lt;br /&gt;
The &lt;code&gt;loki-values.yml&lt;/code&gt; file contains the Loki Helm chart configuration:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&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-shell&#34;&gt;helm install --values loki-values.yml loki grafana/loki -n meta&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This Helm chart installs Loki in monolithic mode.&lt;br /&gt;
For more details, refer to the &lt;a href=&#34;/docs/loki/latest/get-started/deployment-modes/&#34;&gt;Loki documentation&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Deploy Grafana in the &lt;code&gt;meta&lt;/code&gt; namespace.&lt;br /&gt;
You can use Grafana to visualize the logs stored in Loki.&lt;br /&gt;
The &lt;code&gt;grafana-values.yml&lt;/code&gt; file contains the Grafana Helm chart configuration:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&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-shell&#34;&gt;helm install --values grafana-values.yml grafana grafana/grafana --namespace meta&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This Helm chart installs Grafana and sets the &lt;code&gt;datasources.datasources.yaml&lt;/code&gt; field to the Loki data source configuration.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Deploy Alloy in the &lt;code&gt;meta&lt;/code&gt; namespace.&lt;br /&gt;
The &lt;code&gt;k8s-monitoring-values.yml&lt;/code&gt; file contains the Kubernetes monitoring Helm chart configuration:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&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-shell&#34;&gt;helm install --values ./k8s-monitoring-values.yml k8s grafana/k8s-monitoring -n meta --create-namespace&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This Helm chart installs Alloy and specifies the Pod logs and Kubernetes Events sources that Alloy collects logs from.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Port-forward the Grafana Pod to your local machine:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Get the name of the Grafana Pod:&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;shell&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-shell&#34;&gt;export POD_NAME=$(kubectl get pods --namespace meta -l &amp;#34;app.kubernetes.io/name=grafana,app.kubernetes.io/instance=grafana&amp;#34; -o jsonpath=&amp;#34;{.items[0].metadata.name}&amp;#34;)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set up port-forwarding:&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;shell&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-shell&#34;&gt;kubectl --namespace meta port-forward $POD_NAME 3000&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Port-forward the Alloy Pod to your local machine:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Get the name of the Alloy Pod:&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;shell&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-shell&#34;&gt;export POD_NAME=$(kubectl get pods --namespace meta -l &amp;#34;app.kubernetes.io/name=alloy-logs,app.kubernetes.io/instance=k8s-alloy-logs&amp;#34; -o jsonpath=&amp;#34;{.items[0].metadata.name}&amp;#34;)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set up port-forwarding:&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;shell&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-shell&#34;&gt;kubectl --namespace meta port-forward $POD_NAME 12345&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Deploy Grafana Tempo to the &lt;code&gt;prod&lt;/code&gt; namespace.&lt;br /&gt;
Tempo generates logs for this example:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;shell&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-shell&#34;&gt;helm install tempo grafana/tempo-distributed -n prod&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;monitor-and-visualize-your-data&#34;&gt;Monitor and visualize your data&lt;/h2&gt;
&lt;p&gt;Use Grafana to monitor your deployment&amp;rsquo;s health and visualize your data.&lt;/p&gt;
&lt;h3 id=&#34;monitor-the-health-of-your-alloy-deployment&#34;&gt;Monitor the health of your Alloy deployment&lt;/h3&gt;
&lt;p&gt;To monitor the health of your Alloy deployment, open your browser and go to &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;/p&gt;
&lt;p&gt;For more information about the Alloy UI, refer to &lt;a href=&#34;/docs/alloy/latest/troubleshoot/debug/&#34;&gt;Debug Grafana Alloy&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;visualize-your-data&#34;&gt;Visualize your data&lt;/h3&gt;
&lt;p&gt;To use the Grafana Logs Drilldown, open your browser and go to &lt;a href=&#34;http://localhost:3000/a/grafana-lokiexplore-app&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/a/grafana-lokiexplore-app&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To create a &lt;a href=&#34;/docs/grafana/latest/getting-started/build-first-dashboard/#create-a-dashboard&#34;&gt;dashboard&lt;/a&gt; to visualize your metrics and logs, open your browser and go to &lt;a href=&#34;http://localhost:3000/dashboards&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://localhost:3000/dashboards&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;understand-the-kubernetes-monitoring-helm-chart&#34;&gt;Understand the Kubernetes Monitoring Helm chart&lt;/h2&gt;
&lt;p&gt;The Kubernetes Monitoring Helm chart, &lt;code&gt;k8s-monitoring-helm&lt;/code&gt;, collects, scrapes, and forwards Kubernetes telemetry data to a Grafana stack.&lt;br /&gt;
This includes metrics, logs, traces, and continuous profiling data.&lt;/p&gt;
&lt;h3 id=&#34;cluster&#34;&gt;&lt;code&gt;cluster&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;Define the cluster name as &lt;code&gt;meta-monitoring-tutorial&lt;/code&gt;.&lt;br /&gt;
This is a static label attached to all logs collected by the Kubernetes Monitoring Helm chart.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;cluster:
  name: meta-monitoring-tutorial&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;destinations&#34;&gt;&lt;code&gt;destinations&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;Define a destination named &lt;code&gt;loki&lt;/code&gt; to forward logs to Loki.&lt;br /&gt;
The &lt;code&gt;url&lt;/code&gt; attribute specifies the URL of the Loki gateway.&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;destinations:
  - name: loki
    type: loki
    url: http://loki-gateway.meta.svc.cluster.local/loki/api/v1/push&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;clusterevents&#34;&gt;&lt;code&gt;clusterEvents&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;Enable the collection of cluster events.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;collector&lt;/code&gt;: Use the &lt;code&gt;alloy-logs&lt;/code&gt; collector to collect logs.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;namespaces&lt;/code&gt;: Specify the &lt;code&gt;meta&lt;/code&gt; and &lt;code&gt;prod&lt;/code&gt; namespaces to collect logs from.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;YAML&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-yaml&#34;&gt;clusterEvents:
  enabled: true
  collector: alloy-logs
  namespaces:
    - meta
    - prod&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;nodelogs&#34;&gt;&lt;code&gt;nodeLogs&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;Disable the collection of node logs.&lt;br /&gt;
Collecting node logs requires mounting &lt;code&gt;/var/log/journal&lt;/code&gt;, which is out of scope for this example.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;YAML&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-yaml&#34;&gt;nodeLogs:
  enabled: false&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;podlogs&#34;&gt;&lt;code&gt;podLogs&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;Enable the collection of Pod logs.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;labelsToKeep&lt;/code&gt;: Specify labels to keep when collecting logs.&lt;br /&gt;
This configuration removes &lt;code&gt;pod&lt;/code&gt; from the labels to keep.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;structuredMetadata&lt;/code&gt;: Specify structured metadata to collect.&lt;br /&gt;
This configuration sets the structured metadata &lt;code&gt;pod&lt;/code&gt; to keep the Pod name for querying.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;YAML&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-yaml&#34;&gt;podLogs:
  enabled: true
  gatherMethod: kubernetesApi
  collector: alloy-logs
  labelsToKeep: [&amp;#34;app_kubernetes_io_name&amp;#34;,&amp;#34;container&amp;#34;,&amp;#34;instance&amp;#34;,&amp;#34;job&amp;#34;,&amp;#34;level&amp;#34;,&amp;#34;namespace&amp;#34;,&amp;#34;service_name&amp;#34;,&amp;#34;service_namespace&amp;#34;,&amp;#34;deployment_environment&amp;#34;,&amp;#34;deployment_environment_name&amp;#34;]
  structuredMetadata:
    pod: pod  # Set structured metadata &amp;#34;pod&amp;#34; from label &amp;#34;pod&amp;#34;
  namespaces:
    - meta
    - prod&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;define-the-alloy-role&#34;&gt;Define the Alloy role&lt;/h3&gt;
&lt;p&gt;The Kubernetes Monitoring Helm chart deploys only what you need.&lt;br /&gt;
In this case, the configuration deploys Alloy with the capability to collect logs.&lt;br /&gt;
Metrics, traces, and continuous profiling are disabled.&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;alloy-singleton:
  enabled: false

alloy-metrics:
  enabled: false

alloy-logs:
  enabled: true
  alloy:
    mounts:
      varlog: false
    clustering:
      enabled: true

alloy-profiles:
  enabled: false

alloy-receiver:
  enabled: false&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="monitor-kubernetes-logs-with-grafana-alloy">Monitor Kubernetes logs with Grafana Alloy&lt;/h1>
&lt;p>Kubernetes captures logs from each container in a running Pod.&lt;br />
With Alloy, you can collect Kubernetes logs, forward them to a Grafana stack, and create dashboards to monitor your Kubernetes Deployment.&lt;/p></description></item></channel></rss>