<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Tutorials on Grafana Labs</title><link>https://grafana.com/docs/agent/v0.40/flow/tutorials/</link><description>Recent content in Tutorials on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/agent/v0.40/flow/tutorials/index.xml" rel="self" type="application/rss+xml"/><item><title>Flow by example</title><link>https://grafana.com/docs/agent/v0.40/flow/tutorials/flow-by-example/</link><pubDate>Tue, 14 Apr 2026 08:40:50 +0000</pubDate><guid>https://grafana.com/docs/agent/v0.40/flow/tutorials/flow-by-example/</guid><content><![CDATA[&lt;h1 id=&#34;flow-by-example&#34;&gt;Flow by example&lt;/h1&gt;
&lt;p&gt;This section provides a set of step-by-step tutorials that show how to use Grafana Agent Flow.&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;
    &lt;a href=&#34;/docs/agent/v0.40/flow/tutorials/flow-by-example/get-started/&#34;&gt;Get started&lt;/a&gt;&lt;/li&gt;&lt;li&gt;
    &lt;a href=&#34;/docs/agent/v0.40/flow/tutorials/flow-by-example/first-components-and-stdlib/&#34;&gt;First components and introducing the standard library&lt;/a&gt;&lt;/li&gt;&lt;li&gt;
    &lt;a href=&#34;/docs/agent/v0.40/flow/tutorials/flow-by-example/logs-and-relabeling-basics/&#34;&gt;Logs and relabeling basics&lt;/a&gt;&lt;/li&gt;&lt;li&gt;
    &lt;a href=&#34;/docs/agent/v0.40/flow/tutorials/flow-by-example/processing-logs/&#34;&gt;Processing Logs&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
]]></content><description>&lt;h1 id="flow-by-example">Flow by example&lt;/h1>
&lt;p>This section provides a set of step-by-step tutorials that show how to use Grafana Agent Flow.&lt;/p>
&lt;ul>&lt;li>
&lt;a href="/docs/agent/v0.40/flow/tutorials/flow-by-example/get-started/">Get started&lt;/a>&lt;/li>&lt;li>
&lt;a href="/docs/agent/v0.40/flow/tutorials/flow-by-example/first-components-and-stdlib/">First components and introducing the standard library&lt;/a>&lt;/li>&lt;li>
&lt;a href="/docs/agent/v0.40/flow/tutorials/flow-by-example/logs-and-relabeling-basics/">Logs and relabeling basics&lt;/a>&lt;/li>&lt;li>
&lt;a href="/docs/agent/v0.40/flow/tutorials/flow-by-example/processing-logs/">Processing Logs&lt;/a>&lt;/li>&lt;/ul></description></item><item><title>Collect Prometheus metrics</title><link>https://grafana.com/docs/agent/v0.40/flow/tutorials/collecting-prometheus-metrics/</link><pubDate>Tue, 14 Apr 2026 08:40:50 +0000</pubDate><guid>https://grafana.com/docs/agent/v0.40/flow/tutorials/collecting-prometheus-metrics/</guid><content><![CDATA[&lt;h1 id=&#34;collect-prometheus-metrics&#34;&gt;Collect Prometheus metrics&lt;/h1&gt;
&lt;p&gt;Grafana Agent is a telemetry collector with the primary goal of moving telemetry data from one location to another. In this tutorial, you&amp;rsquo;ll set up Grafana Agent Flow.&lt;/p&gt;
&lt;h2 id=&#34;prerequisites&#34;&gt;Prerequisites&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.docker.com/products/docker-desktop&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;run-the-example&#34;&gt;Run the example&lt;/h2&gt;
&lt;p&gt;Run the following command in a terminal window:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;curl https://raw.githubusercontent.com/grafana/agent/main/docs/sources/flow/tutorials/assets/runt.sh -O &amp;amp;&amp;amp; bash ./runt.sh agent.river&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;runt.sh&lt;/code&gt; script does:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Downloads the configurations necessary for Mimir, Grafana, and Grafana Agent.&lt;/li&gt;
&lt;li&gt;Downloads the docker image for Grafana Agent explicitly.&lt;/li&gt;
&lt;li&gt;Runs the docker-compose up command to bring all the services up.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Allow Grafana Agent to run for two minutes, then navigate to &lt;a href=&#34;http://localhost:3000/explore?orgId=1&amp;amp;left=%5B%22now-1h%22,%22now%22,%22Mimir%22,%7B%22refId%22:%22A%22,%22instant%22:true,%22range%22:true,%22exemplar%22:true,%22expr%22:%22agent_build_info%7B%7D%22%7D%5D&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Grafana&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/agent/screenshot-grafana-agent-collect-metrics-build-info.png&#34;
  alt=&#34;Dashboard showing agent_build_info metrics&#34; width=&#34;1084&#34;
     height=&#34;866&#34;/&gt;&lt;/p&gt;
&lt;p&gt;This example scrapes the Grafana Agent Flow &lt;code&gt;http://localhost:12345/metrics&lt;/code&gt; endpoint and pushes those metrics to the Mimir instance.&lt;/p&gt;
&lt;p&gt;Navigate to &lt;code&gt;http://localhost:12345/graph&lt;/code&gt; to view the Grafana Agent Flow UI.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/agent/screenshot-grafana-agent-collect-metrics-graph.png&#34;
  alt=&#34;The User Interface&#34; width=&#34;820&#34;
     height=&#34;737&#34;/&gt;&lt;/p&gt;
&lt;p&gt;Grafana Agent displays the component pipeline in a dependency graph. See &lt;a href=&#34;#scraping-component&#34;&gt;Scraping component&lt;/a&gt; and &lt;a href=&#34;#remote-write-component&#34;&gt;Remote Write component&lt;/a&gt; for details about the components used in this configuration.
Click the nodes to navigate to the associated component page. There, you can view the state, health information, and, if applicable, the debug information.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/agent/screenshot-grafana-agent-collect-metrics-comp-info.png&#34;
  alt=&#34;Component information&#34; width=&#34;1075&#34;
     height=&#34;1418&#34;/&gt;&lt;/p&gt;
&lt;h2 id=&#34;scraping-component&#34;&gt;Scraping component&lt;/h2&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/agent/v0.40/flow/reference/components/prometheus.scrape/&#34;&gt;&lt;code&gt;prometheus.scrape&lt;/code&gt;&lt;/a&gt; component is responsible for scraping the metrics of a particular endpoint and passing them on to another component.&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.scrape is the name of the component and &amp;#34;default&amp;#34; is its label.
prometheus.scrape &amp;#34;default&amp;#34; {
    // Tell the scraper to scrape at http://localhost:12345/metrics.
    // The http:// and metrics are implied but able to be overwritten.
    targets = [{&amp;#34;__address__&amp;#34; = &amp;#34;localhost:12345&amp;#34;}]
    // Forward the scrape results to the receiver. In general,
    // Flow uses forward_to to tell which receiver to send results to.
    // The forward_to is an argument of prometheus.scrape.default and
    // the receiver is an exported field of prometheus.remote_write.prom.
    forward_to = [prometheus.remote_write.prom.receiver]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;prometheus.scrape &amp;quot;default&amp;quot;&lt;/code&gt; annotation indicates the name of the component, &lt;code&gt;prometheus.scrape&lt;/code&gt;, and its label, &lt;code&gt;default&lt;/code&gt;. All components must have a unique combination of name and if applicable label.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;targets&lt;/code&gt; 
    &lt;a href=&#34;/docs/agent/v0.40/flow/concepts/config-language/#attributes&#34;&gt;attribute&lt;/a&gt; is an 
    &lt;a href=&#34;/docs/agent/v0.40/flow/concepts/components/&#34;&gt;argument&lt;/a&gt;. &lt;code&gt;targets&lt;/code&gt; is a list of labels that specify the target via the special key &lt;code&gt;__address__&lt;/code&gt;. The scraper is targeting the Grafana Agent Flow &lt;code&gt;/metrics&lt;/code&gt; endpoint. Both &lt;code&gt;http&lt;/code&gt; and &lt;code&gt;/metrics&lt;/code&gt; are implied but can be overridden.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;forward_to&lt;/code&gt; attribute is an argument that references the 
    &lt;a href=&#34;/docs/agent/v0.40/flow/concepts/components/&#34;&gt;export&lt;/a&gt; of the &lt;code&gt;prometheus.remote_write.prom&lt;/code&gt; component. This is where the scraper will send the metrics for further processing.&lt;/p&gt;
&lt;h2 id=&#34;remote-write-component&#34;&gt;Remote Write component&lt;/h2&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/agent/v0.40/flow/reference/components/prometheus.remote_write/&#34;&gt;&lt;code&gt;prometheus.remote_write&lt;/code&gt;&lt;/a&gt; component is responsible for writing the metrics to a Prometheus-compatible endpoint (Mimir).&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;prom&amp;#34; {
    endpoint {
        url = &amp;#34;http://mimir:9009/api/v1/push&amp;#34;
    }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;running-without-docker&#34;&gt;Running without Docker&lt;/h2&gt;
&lt;p&gt;To try out Grafana Agent without using Docker:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Download Grafana Agent.&lt;/li&gt;
&lt;li&gt;Set the environment variable &lt;code&gt;AGENT_MODE=flow&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Run the Grafana Agent with &lt;code&gt;grafana-agent run &amp;lt;path_to_flow_config&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
]]></content><description>&lt;h1 id="collect-prometheus-metrics">Collect Prometheus metrics&lt;/h1>
&lt;p>Grafana Agent is a telemetry collector with the primary goal of moving telemetry data from one location to another. In this tutorial, you&amp;rsquo;ll set up Grafana Agent Flow.&lt;/p></description></item><item><title>Filter Prometheus metrics</title><link>https://grafana.com/docs/agent/v0.40/flow/tutorials/filtering-metrics/</link><pubDate>Tue, 14 Apr 2026 08:40:50 +0000</pubDate><guid>https://grafana.com/docs/agent/v0.40/flow/tutorials/filtering-metrics/</guid><content><![CDATA[&lt;h1 id=&#34;filter-prometheus-metrics&#34;&gt;Filter Prometheus metrics&lt;/h1&gt;
&lt;p&gt;In this tutorial, you&amp;rsquo;ll add a new component 
    &lt;a href=&#34;/docs/agent/v0.40/flow/reference/components/prometheus.relabel/&#34;&gt;prometheus.relabel&lt;/a&gt; using 
    &lt;a href=&#34;/docs/agent/v0.40/flow/tutorials/assets/flow_configs/relabel.river&#34;&gt;relabel.river&lt;/a&gt; to filter metrics. This tutorial uses the same base as 
    &lt;a href=&#34;/docs/agent/v0.40/flow/tutorials/collecting-prometheus-metrics/&#34;&gt;Collecting Prometheus metrics&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;prerequisites&#34;&gt;Prerequisites&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.docker.com/products/docker-desktop&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;run-the-example&#34;&gt;Run the example&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;prometheus.relabel&lt;/code&gt; component is used to drop, add, or filter metrics.&lt;/p&gt;
&lt;p&gt;Run the following:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;curl https://raw.githubusercontent.com/grafana/agent/main/docs/sources/flow/tutorials/assets/runt.sh -O &amp;amp;&amp;amp; bash ./runt.sh relabel.river&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;runt.sh&lt;/code&gt; script does:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Downloads the configurations necessary for Mimir, Grafana and Grafana Agent.&lt;/li&gt;
&lt;li&gt;Downloads the docker image for Grafana Agent explicitly.&lt;/li&gt;
&lt;li&gt;Runs the docker-compose up command to bring all the services up.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Allow Grafana Agent to run for two minutes, then navigate to &lt;a href=&#34;http://localhost:3000/explore?orgId=1&amp;amp;left=%5B%22now-1h%22,%22now%22,%22Mimir%22,%7B%22refId%22:%22A%22,%22instant%22:true,%22range%22:true,%22exemplar%22:true,%22expr%22:%22agent_build_info%7B%7D%22%7D%5D&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Grafana&lt;/a&gt; page and the &lt;code&gt;service&lt;/code&gt; label will be there with the &lt;code&gt;api_server&lt;/code&gt; value.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/agent/screenshot-grafana-agent-filtering-metrics-filter.png&#34;
  alt=&#34;Dashboard showing api_server&#34; width=&#34;1562&#34;
     height=&#34;847&#34;/&gt;&lt;/p&gt;
&lt;h2 id=&#34;whats-happening&#34;&gt;What&amp;rsquo;s happening?&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;The Prometheus scraper is sending the metrics to the filter.&lt;/li&gt;
&lt;li&gt;The filter is adding a new label named &lt;code&gt;service&lt;/code&gt; with the value &lt;code&gt;api_server&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The filter is then sending metrics to the remote_write endpoint.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;update-the-service-value&#34;&gt;Update the service value&lt;/h2&gt;
&lt;p&gt;Open the &lt;code&gt;relabel.river&lt;/code&gt; file that was downloaded and change the name of the service to &lt;code&gt;api_server_v2&lt;/code&gt;, then run &lt;code&gt;bash ./runt.sh relabel.river&lt;/code&gt;. Allow Grafana Agent to run for two minutes, then navigate to the &lt;a href=&#34;http://localhost:3000/explore?orgId=1&amp;amp;left=%5B%22now-1h%22,%22now%22,%22Mimir%22,%7B%22refId%22:%22A%22,%22instant%22:true,%22range%22:true,%22exemplar%22:true,%22expr%22:%22agent_build_info%7B%7D%22%7D%5D&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Grafana&lt;/a&gt; page, and the new label will be updated. The old value &lt;code&gt;api_server&lt;/code&gt; may still show up in the graph but hovering over the lines will show that that value stopped being scraped and was replaced with &lt;code&gt;api_server_v2&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/agent/screenshot-grafana-agent-filtering-metrics-transition.png&#34;
  alt=&#34;Updated dashboard showing api_server_v2&#34; width=&#34;1580&#34;
     height=&#34;894&#34;/&gt;&lt;/p&gt;
]]></content><description>&lt;h1 id="filter-prometheus-metrics">Filter Prometheus metrics&lt;/h1>
&lt;p>In this tutorial, you&amp;rsquo;ll add a new component
&lt;a href="/docs/agent/v0.40/flow/reference/components/prometheus.relabel/">prometheus.relabel&lt;/a> using
&lt;a href="/docs/agent/v0.40/flow/tutorials/assets/flow_configs/relabel.river">relabel.river&lt;/a> to filter metrics. This tutorial uses the same base as
&lt;a href="/docs/agent/v0.40/flow/tutorials/collecting-prometheus-metrics/">Collecting Prometheus metrics&lt;/a>.&lt;/p>
&lt;h2 id="prerequisites">Prerequisites&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://www.docker.com/products/docker-desktop" target="_blank" rel="noopener noreferrer">Docker&lt;/a>&lt;/li>
&lt;/ul>
&lt;h2 id="run-the-example">Run the example&lt;/h2>
&lt;p>The &lt;code>prometheus.relabel&lt;/code> component is used to drop, add, or filter metrics.&lt;/p></description></item><item><title>Chain Prometheus components</title><link>https://grafana.com/docs/agent/v0.40/flow/tutorials/chaining/</link><pubDate>Tue, 14 Apr 2026 08:40:50 +0000</pubDate><guid>https://grafana.com/docs/agent/v0.40/flow/tutorials/chaining/</guid><content><![CDATA[&lt;h1 id=&#34;chain-prometheus-components&#34;&gt;Chain Prometheus components&lt;/h1&gt;
&lt;p&gt;This tutorial shows how to use 
    &lt;a href=&#34;/docs/agent/v0.40/flow/tutorials/assets/flow_configs/multiple-inputs.river&#34;&gt;multiple-inputs.river&lt;/a&gt; to send data to several different locations. This tutorial uses the same base as 
    &lt;a href=&#34;/docs/agent/v0.40/flow/tutorials/filtering-metrics/&#34;&gt;Filtering metrics&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;A new concept introduced in Flow is chaining components together in a composable pipeline. This promotes the reusability of components while offering flexibility.&lt;/p&gt;
&lt;h2 id=&#34;prerequisites&#34;&gt;Prerequisites&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.docker.com/products/docker-desktop&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;run-the-example&#34;&gt;Run the example&lt;/h2&gt;
&lt;p&gt;Run the following&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;curl https://raw.githubusercontent.com/grafana/agent/main/docs/sources/flow/tutorials/assets/runt.sh -O &amp;amp;&amp;amp; bash ./runt.sh multiple-inputs.river&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;runt.sh&lt;/code&gt; script does:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Downloads the configurations necessary for Mimir, Grafana, and Grafana Agent.&lt;/li&gt;
&lt;li&gt;Downloads the docker image for Grafana Agent explicitly.&lt;/li&gt;
&lt;li&gt;Runs the &lt;code&gt;docker-compose up&lt;/code&gt; command to bring all the services up.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Allow Grafana Agent to run for two minutes, then navigate to &lt;a href=&#34;http://localhost:3000/explore?orgId=1&amp;amp;left=%5B%22now-1h%22,%22now%22,%22Mimir%22,%7B%22refId%22:%22A%22,%22instant%22:true,%22range%22:true,%22exemplar%22:true,%22expr%22:%22agent_build_info%7B%7D%22%7D%5D&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Grafana&lt;/a&gt; to see Grafana Agent scrape metrics. The &lt;a href=&#34;http://localhost:3000/explore?orgId=1&amp;amp;left=%5B%22now-1h%22,%22now%22,%22Mimir%22,%7B%22refId%22:%22A%22,%22instant%22:true,%22range%22:true,%22exemplar%22:true,%22expr%22:%22node_cpu_seconds_total%22%7D%5D&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;node_exporter&lt;/a&gt; metrics also show up now.&lt;/p&gt;
&lt;p&gt;There are two scrapes each sending metrics to one filter. Note the &lt;code&gt;job&lt;/code&gt; label lists the full name of the scrape component.&lt;/p&gt;
&lt;h2 id=&#34;multiple-outputs&#34;&gt;Multiple outputs&lt;/h2&gt;

&lt;div class=&#34;code-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;agent&amp;#34; {
    targets    = [{&amp;#34;__address__&amp;#34; = &amp;#34;localhost:12345&amp;#34;}]
    forward_to = [prometheus.relabel.service.receiver]
}

prometheus.exporter.unix &amp;#34;default&amp;#34; {
    set_collectors = [&amp;#34;cpu&amp;#34;, &amp;#34;diskstats&amp;#34;]
}

prometheus.scrape &amp;#34;unix&amp;#34; {
    targets    = prometheus.exporter.unix.default.targets
    forward_to = [prometheus.relabel.service.receiver]
}

prometheus.relabel &amp;#34;service&amp;#34; {
    rule {
        source_labels = [&amp;#34;__name__&amp;#34;]
        regex         = &amp;#34;(.&amp;#43;)&amp;#34;
        replacement   = &amp;#34;api_server&amp;#34;
        target_label  = &amp;#34;service&amp;#34;
    }
    forward_to = [prometheus.remote_write.prom.receiver]
}

prometheus.remote_write &amp;#34;prom&amp;#34; {
    endpoint {
        url = &amp;#34;http://mimir:9009/api/v1/push&amp;#34;
    }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In the Flow block, &lt;code&gt;prometheus.relabel.service&lt;/code&gt; is being forwarded metrics from two sources &lt;code&gt;prometheus.scrape.agent&lt;/code&gt; and &lt;code&gt;prometheus.exporter.unix.default&lt;/code&gt;. This allows for a single relabel component to be used with any number of inputs.&lt;/p&gt;
&lt;h2 id=&#34;adding-another-relabel&#34;&gt;Adding another relabel&lt;/h2&gt;
&lt;p&gt;In &lt;code&gt;multiple-input.river&lt;/code&gt; add a new &lt;code&gt;prometheus.relabel&lt;/code&gt; component that adds a &lt;code&gt;version&lt;/code&gt; label with the value of &lt;code&gt;v2&lt;/code&gt; to all metrics after the &lt;code&gt;prometheus.relabel.service&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/agent/screenshot-grafana-agent-chaining-scrape-v2.png&#34;
  alt=&#34;Add a new label with the value v2&#34; width=&#34;1576&#34;
     height=&#34;892&#34;/&gt;&lt;/p&gt;
]]></content><description>&lt;h1 id="chain-prometheus-components">Chain Prometheus components&lt;/h1>
&lt;p>This tutorial shows how to use
&lt;a href="/docs/agent/v0.40/flow/tutorials/assets/flow_configs/multiple-inputs.river">multiple-inputs.river&lt;/a> to send data to several different locations. This tutorial uses the same base as
&lt;a href="/docs/agent/v0.40/flow/tutorials/filtering-metrics/">Filtering metrics&lt;/a>.&lt;/p>
&lt;p>A new concept introduced in Flow is chaining components together in a composable pipeline. This promotes the reusability of components while offering flexibility.&lt;/p></description></item></channel></rss>