<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Concepts on Grafana Labs</title><link>https://grafana.com/docs/agent/v0.44/flow/concepts/</link><description>Recent content in Concepts on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/agent/v0.44/flow/concepts/index.xml" rel="self" type="application/rss+xml"/><item><title>Configuration language</title><link>https://grafana.com/docs/agent/v0.44/flow/concepts/config-language/</link><pubDate>Wed, 29 Jan 2025 11:00:55 +0000</pubDate><guid>https://grafana.com/docs/agent/v0.44/flow/concepts/config-language/</guid><content><![CDATA[&lt;h1 id=&#34;configuration-language&#34;&gt;Configuration language&lt;/h1&gt;
&lt;p&gt;Grafana Agent Flow dynamically configures and connects components with a custom configuration language called River.&lt;/p&gt;
&lt;p&gt;River aims to reduce errors in configuration files by making configurations easier to read and write.
River configurations use blocks that can be easily copied and pasted from the documentation to help you get started as quickly as possible.&lt;/p&gt;
&lt;p&gt;A River configuration file tells Grafana Agent Flow which components to launch and how to bind them together into a pipeline.&lt;/p&gt;
&lt;p&gt;The River syntax uses blocks, attributes, and expressions.&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;// Create a local.file component labeled my_file.
// This can be referenced by other components as local.file.my_file.
local.file &amp;#34;my_file&amp;#34; {
  filename = &amp;#34;/tmp/my-file.txt&amp;#34;
}

// Pattern for creating a labeled block, which the above block follows:
BLOCK_NAME &amp;#34;BLOCK_LABEL&amp;#34; {
  // Block body
  IDENTIFIER = EXPRESSION // Attribute
}

// Pattern for creating an unlabeled block:
BLOCK_NAME {
  // Block body
  IDENTIFIER = EXPRESSION // Attribute
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href=&#34;https://github.com/grafana/agent/blob/97a55d0d908b26dbb1126cc08b6dcc18f6e30087/docs/rfcs/0005-river.md&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;River is designed&lt;/a&gt; with the following requirements in mind:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Fast&lt;/em&gt;: The configuration language must be fast so the component controller can quickly evaluate changes.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Simple&lt;/em&gt;: The configuration language must be easy to read and write to minimize the learning curve.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Debuggable&lt;/em&gt;: The configuration language must give detailed information when there&amp;rsquo;s a mistake in the configuration file.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;River is similar to HCL, the language Terraform and other Hashicorp projects use.
It&amp;rsquo;s a distinct language with custom syntax and features, such as first-class functions.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Blocks are a group of related settings and usually represent creating a component.
Blocks have a name that consists of zero or more identifiers separated by &lt;code&gt;.&lt;/code&gt;, an optional user label, and a body containing attributes and nested blocks.&lt;/li&gt;
&lt;li&gt;Attributes appear within blocks and assign a value to a name.&lt;/li&gt;
&lt;li&gt;Expressions represent a value, either literally or by referencing and combining other values.
You use expressions to compute a value for an attribute.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;River is declarative, so ordering components, blocks, and attributes within a block isn&amp;rsquo;t significant.
The relationship between components determines the order of operations.&lt;/p&gt;
&lt;h2 id=&#34;attributes&#34;&gt;Attributes&lt;/h2&gt;
&lt;p&gt;You use &lt;em&gt;Attributes&lt;/em&gt; to configure individual settings.
Attributes always take the form of &lt;code&gt;ATTRIBUTE_NAME = ATTRIBUTE_VALUE&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The following example shows how to set the &lt;code&gt;log_level&lt;/code&gt; attribute to &lt;code&gt;&amp;quot;debug&amp;quot;&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;log_level = &amp;#34;debug&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;expressions&#34;&gt;Expressions&lt;/h2&gt;
&lt;p&gt;You use expressions to compute the value of an attribute.
The simplest expressions are constant values like &lt;code&gt;&amp;quot;debug&amp;quot;&lt;/code&gt;, &lt;code&gt;32&lt;/code&gt;, or &lt;code&gt;[1, 2, 3, 4]&lt;/code&gt;.
River supports complex expressions, for example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Referencing the exports of components: &lt;code&gt;local.file.password_file.content&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Mathematical operations: &lt;code&gt;1 &#43; 2&lt;/code&gt;, &lt;code&gt;3 * 4&lt;/code&gt;, &lt;code&gt;(5 * 6) &#43; (7 &#43; 8)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Equality checks: &lt;code&gt;local.file.file_a.content == local.file.file_b.content&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Calling functions from River&amp;rsquo;s standard library: &lt;code&gt;env(&amp;quot;HOME&amp;quot;)&lt;/code&gt; retrieves the value of the &lt;code&gt;HOME&lt;/code&gt; environment variable.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can use expressions for any attribute inside a component definition.&lt;/p&gt;
&lt;h3 id=&#34;referencing-component-exports&#34;&gt;Referencing component exports&lt;/h3&gt;
&lt;p&gt;The most common expression is to reference the exports of a component, for example, &lt;code&gt;local.file.password_file.content&lt;/code&gt;.
You form a reference to a component&amp;rsquo;s exports by merging the component&amp;rsquo;s name (for example, &lt;code&gt;local.file&lt;/code&gt;),
label (for example, &lt;code&gt;password_file&lt;/code&gt;), and export name (for example, &lt;code&gt;content&lt;/code&gt;), delimited by a period.&lt;/p&gt;
&lt;h2 id=&#34;blocks&#34;&gt;Blocks&lt;/h2&gt;
&lt;p&gt;You use &lt;em&gt;Blocks&lt;/em&gt; to configure components and groups of attributes.
Each block can contain any number of attributes or nested blocks.&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;default&amp;#34; {
  endpoint {
    url = &amp;#34;http://localhost:9009/api/prom/push&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The preceding example has two blocks:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;prometheus.remote_write &amp;quot;default&amp;quot;&lt;/code&gt;: A labeled block which instantiates a &lt;code&gt;prometheus.remote_write&lt;/code&gt; component.
The label is the string &lt;code&gt;&amp;quot;default&amp;quot;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;endpoint&lt;/code&gt;: An unlabeled block inside the component that configures an endpoint to send metrics to.
This block sets the &lt;code&gt;url&lt;/code&gt; attribute to specify the endpoint.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;tooling&#34;&gt;Tooling&lt;/h2&gt;
&lt;p&gt;You can use one or all of the following tools to help you write configuration files in River.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Experimental editor support for
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/rfratto/vim-river&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;vim&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/rfratto/vscode-river&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;VSCode&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/jdbaldry/river-mode&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;river-mode&lt;/a&gt; for Emacs&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Code formatting using the 
    &lt;a href=&#34;/docs/agent/v0.44/flow/reference/cli/fmt/&#34;&gt;&lt;code&gt;agent fmt&lt;/code&gt; command&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can also start developing your own tooling using the Grafana Agent repository as a go package or use the
&lt;a href=&#34;https://github.com/grafana/tree-sitter-river&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;tree-sitter grammar&lt;/a&gt; with other programming languages.&lt;/p&gt;
]]></content><description>&lt;h1 id="configuration-language">Configuration language&lt;/h1>
&lt;p>Grafana Agent Flow dynamically configures and connects components with a custom configuration language called River.&lt;/p>
&lt;p>River aims to reduce errors in configuration files by making configurations easier to read and write.
River configurations use blocks that can be easily copied and pasted from the documentation to help you get started as quickly as possible.&lt;/p></description></item><item><title>Components</title><link>https://grafana.com/docs/agent/v0.44/flow/concepts/components/</link><pubDate>Wed, 29 Jan 2025 11:00:55 +0000</pubDate><guid>https://grafana.com/docs/agent/v0.44/flow/concepts/components/</guid><content><![CDATA[&lt;h1 id=&#34;components&#34;&gt;Components&lt;/h1&gt;
&lt;p&gt;&lt;em&gt;Components&lt;/em&gt; are the building blocks of Grafana Agent Flow.
Each component handles a single task, such as retrieving secrets or collecting Prometheus metrics.&lt;/p&gt;
&lt;p&gt;Components are composed of the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Arguments: Settings that configure a component.&lt;/li&gt;
&lt;li&gt;Exports: Named values that a component exposes to other components.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each component has a name that describes what that component is responsible for.
For example, the &lt;code&gt;local.file&lt;/code&gt; component is responsible for retrieving the contents of files on disk.&lt;/p&gt;
&lt;p&gt;You specify components in the configuration file by first providing the component&amp;rsquo;s name with a user-specified label,
and then by giving arguments to configure the 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;discovery.kubernetes &amp;#34;pods&amp;#34; {
  role = &amp;#34;pod&amp;#34;
}

discovery.kubernetes &amp;#34;nodes&amp;#34; {
  role = &amp;#34;node&amp;#34;
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You reference components by combining the component name with its label.
For example, you can reference a &lt;code&gt;local.file&lt;/code&gt; component labeled &lt;code&gt;foo&lt;/code&gt; as &lt;code&gt;local.file.foo&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The combination of a component&amp;rsquo;s name and its label must be unique within the configuration file.
Combining component names with a label means you can define multiple instances of a component as long as each instance has a different label value.&lt;/p&gt;
&lt;h2 id=&#34;pipelines&#34;&gt;Pipelines&lt;/h2&gt;
&lt;p&gt;Most arguments for a component in a configuration file are constant values, such as setting a &lt;code&gt;log_level&lt;/code&gt; attribute to the quoted string &lt;code&gt;&amp;quot;debug&amp;quot;&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;log_level = &amp;#34;debug&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You use &lt;em&gt;expressions&lt;/em&gt; to dynamically compute the value of an argument at runtime.
You can use expressions to retrieve the value of an environment variable (&lt;code&gt;log_level = env(&amp;quot;LOG_LEVEL&amp;quot;)&lt;/code&gt;)
or to reference an exported field of another component (&lt;code&gt;log_level = local.file.log_level.content&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;You create a dependent relationship when a component&amp;rsquo;s argument references an exported field of another component.
A component&amp;rsquo;s arguments now depend on another component&amp;rsquo;s exports.
The input of the component is re-evaluated whenever the exports of the components it references are updated.&lt;/p&gt;
&lt;p&gt;The flow of data through the set of references between components forms a &lt;em&gt;pipeline&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;An example pipeline may look like this:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;A &lt;code&gt;local.file&lt;/code&gt; component watches a file that contains an API key.&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;prometheus.remote_write&lt;/code&gt; component is configured to receive metrics and forward them to an external database using the API key from the &lt;code&gt;local.file&lt;/code&gt; for authentication.&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;discovery.kubernetes&lt;/code&gt; component discovers and exports Kubernetes Pods where metrics can be collected.&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;prometheus.scrape&lt;/code&gt; component references the exports of the previous component, and sends collected metrics to the &lt;code&gt;prometheus.remote_write&lt;/code&gt; component.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/agent/concepts_example_pipeline.svg&#34;
  alt=&#34;Flow of example pipeline&#34;/&gt;&lt;/p&gt;
&lt;p&gt;The following configuration file represents the pipeline.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;// Get our API key from disk.
//
// This component has an exported field called &amp;#34;content&amp;#34;, holding the content
// of the file.
//
// local.file.api_key will watch the file and update its exports any time the
// file changes.
local.file &amp;#34;api_key&amp;#34; {
  filename  = &amp;#34;/var/data/secrets/api-key&amp;#34;

  // Mark this file as sensitive to prevent its value from being shown in the
  // UI.
  is_secret = true
}

// Create a prometheus.remote_write component, which other components can send
// metrics to.
//
// This component exports a &amp;#34;receiver&amp;#34; value, which can be used by other
// components to send metrics.
prometheus.remote_write &amp;#34;prod&amp;#34; {
  endpoint {
    url = &amp;#34;https://prod:9090/api/v1/write&amp;#34;

    basic_auth {
      username = &amp;#34;admin&amp;#34;

      // Use the password file to authenticate with the production database.
      password = local.file.api_key.content
    }
  }
}

// Find Kubernetes pods where we can collect metrics.
//
// This component exports a &amp;#34;targets&amp;#34; value, which contains the list of
// discovered pods.
discovery.kubernetes &amp;#34;pods&amp;#34; {
  role = &amp;#34;pod&amp;#34;
}

// Collect metrics from Kubernetes pods and send them to prod.
prometheus.scrape &amp;#34;default&amp;#34; {
  targets    = discovery.kubernetes.pods.targets
  forward_to = [prometheus.remote_write.prod.receiver]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="components">Components&lt;/h1>
&lt;p>&lt;em>Components&lt;/em> are the building blocks of Grafana Agent Flow.
Each component handles a single task, such as retrieving secrets or collecting Prometheus metrics.&lt;/p>
&lt;p>Components are composed of the following:&lt;/p></description></item><item><title>Component controller</title><link>https://grafana.com/docs/agent/v0.44/flow/concepts/component_controller/</link><pubDate>Wed, 29 Jan 2025 11:00:55 +0000</pubDate><guid>https://grafana.com/docs/agent/v0.44/flow/concepts/component_controller/</guid><content><![CDATA[&lt;h1 id=&#34;component-controller&#34;&gt;Component controller&lt;/h1&gt;
&lt;p&gt;The &lt;em&gt;component controller&lt;/em&gt; is the core part of Grafana Agent Flow which manages components at runtime.&lt;/p&gt;
&lt;p&gt;The component controller is responsible for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Reading and validating the configuration file.&lt;/li&gt;
&lt;li&gt;Managing the lifecycle of defined components.&lt;/li&gt;
&lt;li&gt;Evaluating the arguments used to configure components.&lt;/li&gt;
&lt;li&gt;Reporting the health of defined components.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;component-graph&#34;&gt;Component graph&lt;/h2&gt;
&lt;p&gt;A relationship between 
    &lt;a href=&#34;/docs/agent/v0.44/flow/concepts/components/&#34;&gt;components&lt;/a&gt; is created when an expression is used to set the argument of one component to an exported field of another component.&lt;/p&gt;
&lt;p&gt;The set of all components and the relationships between them define a &lt;a href=&#34;https://en.wikipedia.org/wiki/Directed_acyclic_graph&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Directed Acyclic Graph&lt;/a&gt; (DAG),
which informs the component controller which references are valid and in what order components must be evaluated.&lt;/p&gt;
&lt;p&gt;For a configuration file to be valid, components must not reference themselves or contain a cyclic reference.&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;// INVALID: local.file.some_file can not reference itself:
local.file &amp;#34;self_reference&amp;#34; {
  filename = local.file.self_reference.content
}&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;// INVALID: cyclic reference between local.file.a and local.file.b:
local.file &amp;#34;a&amp;#34; {
  filename = local.file.b.content
}
local.file &amp;#34;b&amp;#34; {
  filename = local.file.a.content
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;component-evaluation&#34;&gt;Component evaluation&lt;/h2&gt;
&lt;p&gt;A component is &lt;em&gt;evaluated&lt;/em&gt; when its expressions are computed into concrete values.
The computed values configure the component&amp;rsquo;s runtime behavior.
The component controller is finished loading once all components are evaluated, configured, and running.&lt;/p&gt;
&lt;p&gt;The component controller only evaluates a given component after evaluating all of that component&amp;rsquo;s dependencies.
Components that don&amp;rsquo;t depend on other components can be evaluated anytime during the evaluation process.&lt;/p&gt;
&lt;h2 id=&#34;component-reevaluation&#34;&gt;Component reevaluation&lt;/h2&gt;
&lt;p&gt;A 
    &lt;a href=&#34;/docs/agent/v0.44/flow/concepts/components/&#34;&gt;component&lt;/a&gt; is dynamic. A component can update its exports any number of times throughout its lifetime.&lt;/p&gt;
&lt;p&gt;A &lt;em&gt;controller reevaluation&lt;/em&gt; is triggered when a component updates its exports.
The component controller reevaluates any component that references the changed component, any components that reference those components,
and so on, until all affected components are reevaluated.&lt;/p&gt;
&lt;h2 id=&#34;component-health&#34;&gt;Component health&lt;/h2&gt;
&lt;p&gt;At any given time, a component can have one of the following health states:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Unknown: The default state. The component isn&amp;rsquo;t running yet.&lt;/li&gt;
&lt;li&gt;Healthy: The component is working as expected.&lt;/li&gt;
&lt;li&gt;Unhealthy: The component isn&amp;rsquo;t working as expected.&lt;/li&gt;
&lt;li&gt;Exited: The component has stopped and is no longer running.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;By default, the component controller determines the health of a component.
The component controller marks a component as healthy as long as that component is running and its most recent evaluation succeeded.&lt;/p&gt;
&lt;p&gt;Some components can report their own component-specific health information.
For example, the &lt;code&gt;local.file&lt;/code&gt; component reports itself as unhealthy if the file it was watching gets deleted.&lt;/p&gt;
&lt;p&gt;The overall health of a component is determined by combining the controller-reported health of the component with the component-specific health information.&lt;/p&gt;
&lt;p&gt;An individual component&amp;rsquo;s health is independent of the health of any other components it references.
A component can be marked as healthy even if it references an exported field of an unhealthy component.&lt;/p&gt;
&lt;h2 id=&#34;handling-evaluation-failures&#34;&gt;Handling evaluation failures&lt;/h2&gt;
&lt;p&gt;When a component fails to evaluate, it&amp;rsquo;s marked as unhealthy with the reason for why the evaluation failed.&lt;/p&gt;
&lt;p&gt;When an evaluation fails, the component continues operating as normal.
The component continues using its previous set of evaluated arguments and can continue exporting new values.&lt;/p&gt;
&lt;p&gt;This behavior prevents failure propagation.
If your &lt;code&gt;local.file&lt;/code&gt; component, which watches API keys, suddenly stops working, other components continue using the last valid API key until the component returns to a healthy state.&lt;/p&gt;
&lt;h2 id=&#34;in-memory-traffic&#34;&gt;In-memory traffic&lt;/h2&gt;
&lt;p&gt;Components that expose HTTP endpoints, such as 
    &lt;a href=&#34;/docs/agent/v0.44/flow/reference/components/prometheus.exporter.unix/&#34;&gt;prometheus.exporter.unix&lt;/a&gt;, can expose an internal address that completely bypasses the network and communicate in-memory.
Components within the same process can communicate with one another without needing to be aware of any network-level protections such as authentication or mutual TLS.&lt;/p&gt;
&lt;p&gt;The internal address defaults to &lt;code&gt;agent.internal:12345&lt;/code&gt;.
If this address collides with a real target on your network, change it to something unique using the &lt;code&gt;--server.http.memory-addr&lt;/code&gt; flag in the 
    &lt;a href=&#34;/docs/agent/v0.44/flow/reference/cli/run/&#34;&gt;run&lt;/a&gt; command.&lt;/p&gt;
&lt;p&gt;Components must opt-in to using in-memory traffic.
Refer to the individual documentation for components to learn if in-memory traffic is supported.&lt;/p&gt;
&lt;h2 id=&#34;updating-the-configuration-file&#34;&gt;Updating the configuration file&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;/-/reload&lt;/code&gt; HTTP endpoint and the &lt;code&gt;SIGHUP&lt;/code&gt; signal can inform the component controller to reload the configuration file.
When this happens, the component controller synchronizes the set of running components with the ones in the configuration file,
removing components no longer defined in the configuration file and creating new components added to the configuration file.
All components managed by the controller are reevaluated after reloading.&lt;/p&gt;
]]></content><description>&lt;h1 id="component-controller">Component controller&lt;/h1>
&lt;p>The &lt;em>component controller&lt;/em> is the core part of Grafana Agent Flow which manages components at runtime.&lt;/p>
&lt;p>The component controller is responsible for:&lt;/p>
&lt;ul>
&lt;li>Reading and validating the configuration file.&lt;/li>
&lt;li>Managing the lifecycle of defined components.&lt;/li>
&lt;li>Evaluating the arguments used to configure components.&lt;/li>
&lt;li>Reporting the health of defined components.&lt;/li>
&lt;/ul>
&lt;h2 id="component-graph">Component graph&lt;/h2>
&lt;p>A relationship between
&lt;a href="/docs/agent/v0.44/flow/concepts/components/">components&lt;/a> is created when an expression is used to set the argument of one component to an exported field of another component.&lt;/p></description></item><item><title>Custom components</title><link>https://grafana.com/docs/agent/v0.44/flow/concepts/custom_components/</link><pubDate>Wed, 18 Jun 2025 15:04:54 +0000</pubDate><guid>https://grafana.com/docs/agent/v0.44/flow/concepts/custom_components/</guid><content><![CDATA[&lt;h1 id=&#34;custom-components&#34;&gt;Custom components&lt;/h1&gt;
&lt;p&gt;&lt;em&gt;Custom components&lt;/em&gt; are a way to create new components from a pipeline of built-in and other custom components.&lt;/p&gt;
&lt;p&gt;A custom component is composed of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Arguments&lt;/em&gt;: Settings that configure the custom component.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Exports&lt;/em&gt;: Values that a custom component exposes to its consumers.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Components&lt;/em&gt;: Built-in and custom components that are run as part of the custom component.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;creating-custom-components&#34;&gt;Creating custom components&lt;/h2&gt;
&lt;p&gt;You can create a new custom component using &lt;a href=&#34;../../reference/config-blocks/declare/&#34;&gt;the &lt;code&gt;declare&lt;/code&gt; configuration block&lt;/a&gt;.
The label of the block determines the name of the custom component.&lt;/p&gt;
&lt;p&gt;The following custom configuration blocks can be used inside a &lt;code&gt;declare&lt;/code&gt; block:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../../reference/config-blocks/argument/&#34;&gt;argument&lt;/a&gt;: Create a new named argument, whose current value can be referenced using the expression &lt;code&gt;argument.NAME.value&lt;/code&gt;. Argument values are determined by the user of a custom component.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../../reference/config-blocks/export/&#34;&gt;export&lt;/a&gt;: Expose a new named value to custom component users.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Custom components are useful for reusing a common pipeline multiple times. To learn how to share custom components across multiple files, refer to &lt;a href=&#34;../modules/&#34;&gt;Modules&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;example&#34;&gt;Example&lt;/h2&gt;
&lt;p&gt;This example creates a new custom component called &lt;code&gt;add&lt;/code&gt;, which exports the sum of two arguments:&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;declare &amp;#34;add&amp;#34; {
    argument &amp;#34;a&amp;#34; { }
    argument &amp;#34;b&amp;#34; { }

    export &amp;#34;sum&amp;#34; {
        value = argument.a.value &amp;#43; argument.b.value
    }
}

add &amp;#34;example&amp;#34; {
    a = 15
    b = 17
}

// add.example.sum == 32&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="custom-components">Custom components&lt;/h1>
&lt;p>&lt;em>Custom components&lt;/em> are a way to create new components from a pipeline of built-in and other custom components.&lt;/p>
&lt;p>A custom component is composed of:&lt;/p></description></item><item><title>Modules</title><link>https://grafana.com/docs/agent/v0.44/flow/concepts/modules/</link><pubDate>Wed, 18 Jun 2025 15:04:54 +0000</pubDate><guid>https://grafana.com/docs/agent/v0.44/flow/concepts/modules/</guid><content><![CDATA[&lt;h1 id=&#34;modules&#34;&gt;Modules&lt;/h1&gt;
&lt;p&gt;A &lt;em&gt;Module&lt;/em&gt; is a unit of Grafana Agent Flow configuration, which combines all the other concepts, containing a mix of configuration blocks, instantiated components, and custom component definitions.
The module passed as an argument to &lt;a href=&#34;../../reference/cli/run/&#34;&gt;the &lt;code&gt;run&lt;/code&gt; command&lt;/a&gt; is called the &lt;em&gt;main configuration&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Modules can be &lt;a href=&#34;#importing-modules&#34;&gt;imported&lt;/a&gt; to enable the reuse of &lt;a href=&#34;../custom_components/&#34;&gt;custom components&lt;/a&gt; defined by that module.&lt;/p&gt;
&lt;h2 id=&#34;importing-modules&#34;&gt;Importing modules&lt;/h2&gt;
&lt;p&gt;A module can be &lt;em&gt;imported&lt;/em&gt;, allowing the custom components defined by that module to be used by other modules, called the &lt;em&gt;importing module&lt;/em&gt;.
Modules can be imported from multiple locations using one of the &lt;code&gt;import&lt;/code&gt; configuration blocks:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../../reference/config-blocks/import.file/&#34;&gt;import.file&lt;/a&gt;: Imports a module from a file or a directory on disk.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../../reference/config-blocks/import.git/&#34;&gt;import.git&lt;/a&gt;: Imports a module from a file located in a Git repository.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../../reference/config-blocks/import.http/&#34;&gt;import.http&lt;/a&gt;: Imports a module from the response of an HTTP request.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../../reference/config-blocks/import.string/&#34;&gt;import.string&lt;/a&gt;: Imports a module from a string.&lt;/li&gt;
&lt;/ul&gt;


&lt;div class=&#34;admonition admonition-warning&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Warning&lt;/p&gt;&lt;p&gt;You can&amp;rsquo;t import a module that contains top-level blocks other than &lt;code&gt;declare&lt;/code&gt; or &lt;code&gt;import&lt;/code&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;Modules are imported into a &lt;em&gt;namespace&lt;/em&gt; where the top-level custom components of the imported module are exposed to the importing module.
The label of the import block specifies the namespace of an import.
For example, if a configuration contains a block called &lt;code&gt;import.file &amp;quot;my_module&amp;quot;&lt;/code&gt;, then custom components defined by that module are exposed as &lt;code&gt;my_module.CUSTOM_COMPONENT_NAME&lt;/code&gt;. Imported namespaces must be unique across a given importing module.&lt;/p&gt;
&lt;p&gt;If an import namespace matches the name of a built-in component namespace, such as &lt;code&gt;prometheus&lt;/code&gt;, the built-in namespace is hidden from the importing module, and only components defined in the imported module may be used.&lt;/p&gt;
&lt;h2 id=&#34;example&#34;&gt;Example&lt;/h2&gt;
&lt;p&gt;This example module defines a component to filter out debug-level and info-level log lines:&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;declare &amp;#34;log_filter&amp;#34; {
  // argument.write_to is a required argument that specifies where filtered
  // log lines are sent.
  //
  // The value of the argument is retrieved in this file with
  // argument.write_to.value.
  argument &amp;#34;write_to&amp;#34; {
    optional = false
  }

  // loki.process.filter is our component which executes the filtering,
  // passing filtered logs to argument.write_to.value.
  loki.process &amp;#34;filter&amp;#34; {
    // Drop all debug- and info-level logs.
    stage.match {
      selector = `{job!=&amp;#34;&amp;#34;} |~ &amp;#34;level=(debug|info)&amp;#34;`
      action   = &amp;#34;drop&amp;#34;
    }

    // Send processed logs to our argument.
    forward_to = argument.write_to.value
  }

  // export.filter_input exports a value to the module consumer.
  export &amp;#34;filter_input&amp;#34; {
    // Expose the receiver of loki.process so the module importer can send
    // logs to our loki.process component.
    value = loki.process.filter.receiver
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can save this module to a file called &lt;code&gt;helpers.river&lt;/code&gt; and import it:&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;// Import our helpers.river module, exposing its custom components as
// helpers.COMPONENT_NAME.
import.file &amp;#34;helpers&amp;#34; {
  filename = &amp;#34;helpers.river&amp;#34;
}

loki.source.file &amp;#34;self&amp;#34; {
  targets = LOG_TARGETS

  // Forward collected logs to the input of our filter.
  forward_to = [helpers.log_filter.default.filter_input]
}

helpers.log_filter &amp;#34;default&amp;#34; {
  // Configure the filter to forward filtered logs to loki.write below.
  write_to = [loki.write.default.receiver]
}

loki.write &amp;#34;default&amp;#34; {
  endpoint {
    url = LOKI_URL
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;collapse&#34; x-data=&#34;app_collapse()&#34;&gt;
  &lt;button class=&#34;collapse-trigger&#34; @click=&#34;toggle()&#34;&gt;
    &lt;span class=&#34;body-large&#34;&gt;Classic modules&lt;/span&gt;
    &lt;span class=&#34;collapse-trigger__icon&#34; :class=&#34;{ &#39;collapse-trigger__icon-open&#39; : open }&#34;&gt;
      
  &lt;svg width=&#34;27&#34; height=&#34;26&#34; viewBox=&#34;0 0 27 26&#34; fill=&#34;none&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;
&lt;path opacity=&#34;0.2&#34; d=&#34;M1.73047 12.8359C1.73047 19.4634 7.10305 24.8359 13.7305 24.8359C20.3579 24.8359 25.7305 19.4634 25.7305 12.8359C25.7305 6.20852 20.3579 0.835937 13.7305 0.835937C7.10305 0.835937 1.73047 6.20852 1.73047 12.8359Z&#34; stroke=&#34;black&#34; stroke-width=&#34;1.5&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;
&lt;path d=&#34;M18.2344 12.8359L9.23438 12.8359&#34; stroke=&#34;black&#34; stroke-width=&#34;1.5&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;
&lt;path d=&#34;M13.7344 8.33594L13.7344 17.3359&#34; stroke=&#34;black&#34; stroke-width=&#34;1.5&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34;/&gt;
&lt;/svg&gt;


    &lt;/span&gt;
  &lt;/button&gt;
  &lt;div class=&#34;collapse-content&#34; x-ref=&#34;content&#34; hidden=&#34;until-found&#34;&gt;
    &lt;div class=&#34;collapse-content__inner&#34; x-ref=&#34;content-inner&#34;&gt;&lt;h1 id=&#34;classic-modules-deprecated&#34;&gt;Classic modules (deprecated)&lt;/h1&gt;
&lt;div class=&#34;admonition admonition-caution&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Caution&lt;/p&gt;&lt;p&gt;Modules were redesigned in v0.40 to simplify concepts. This section outlines the design of the original modules prior to v0.40. Classic modules are scheduled to be removed in the release after v0.40.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;
&lt;p&gt;You use &lt;em&gt;Modules&lt;/em&gt; to create Grafana Agent Flow configurations that you can load as a component.
Modules are a great way to parameterize a configuration to create reusable pipelines.&lt;/p&gt;
&lt;p&gt;Modules are Grafana Agent Flow configurations which have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Arguments&lt;/em&gt;: Settings that configure a module.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Exports&lt;/em&gt;: Named values that a module exposes to the consumer of the module.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Components&lt;/em&gt;: Grafana Agent Flow components to run when the module is running.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You use a &lt;a href=&#34;#module-loaders&#34;&gt;Module loader&lt;/a&gt; to load Modules into Grafana Agent Flow.&lt;/p&gt;
&lt;p&gt;Refer to 
    &lt;a href=&#34;/docs/agent/v0.44/flow/reference/config-blocks/argument/&#34;&gt;argument block&lt;/a&gt; and 
    &lt;a href=&#34;/docs/agent/v0.44/flow/reference/config-blocks/export/&#34;&gt;export block&lt;/a&gt; to learn how to define arguments and exports for a module.&lt;/p&gt;
&lt;h2 id=&#34;module-loaders&#34;&gt;Module loaders&lt;/h2&gt;
&lt;p&gt;A &lt;em&gt;Module loader&lt;/em&gt; is a Grafana Agent Flow component that retrieves a module and runs the defined components.&lt;/p&gt;
&lt;p&gt;Module loader components are responsible for the following functions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Retrieving the module source.&lt;/li&gt;
&lt;li&gt;Creating a 
    &lt;a href=&#34;/docs/agent/v0.44/flow/concepts/component_controller/&#34;&gt;Component controller&lt;/a&gt; for the module.&lt;/li&gt;
&lt;li&gt;Passing arguments to the loaded module.&lt;/li&gt;
&lt;li&gt;Exposing exports from the loaded module.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Module loaders are typically called &lt;code&gt;module.LOADER_NAME&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Some module loaders may not support running modules with arguments or exports.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;
&lt;p&gt;Refer to 
    &lt;a href=&#34;/docs/agent/v0.44/flow/reference/components/&#34;&gt;Components&lt;/a&gt; for more information about the module loader components.&lt;/p&gt;
&lt;h2 id=&#34;module-sources&#34;&gt;Module sources&lt;/h2&gt;
&lt;p&gt;Modules are flexible, and you can retrieve their configuration anywhere, such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The local filesystem.&lt;/li&gt;
&lt;li&gt;An S3 bucket.&lt;/li&gt;
&lt;li&gt;An HTTP endpoint.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each module loader component supports different ways of retrieving &lt;code&gt;module.sources&lt;/code&gt;.
The most generic module loader component, &lt;code&gt;module.string&lt;/code&gt;, can load modules from the export of another Grafana Agent Flow 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;local.file &amp;#34;my_module&amp;#34; {
  filename = &amp;#34;PATH_TO_MODULE&amp;#34;
}

module.string &amp;#34;my_module&amp;#34; {
  content = local.file.my_module.content

  arguments {
    MODULE_ARGUMENT_NAME_1 = MODULE_ARGUMENT_VALUE_1
    MODULE_ARGUMENT_NAME_2 = MODULE_ARGUMENT_VALUE_2
    // ...
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;example-module&#34;&gt;Example module&lt;/h2&gt;
&lt;p&gt;This example module manages a pipeline that filters out debug-level and info-level log lines.&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;// argument.write_to is a required argument that specifies where filtered
// log lines are sent.
//
// The value of the argument is retrieved in this file with
// argument.write_to.value.
argument &amp;#34;write_to&amp;#34; {
  optional = false
}

// loki.process.filter is our component which executes the filtering, passing
// filtered logs to argument.write_to.value.
loki.process &amp;#34;filter&amp;#34; {
  // Drop all debug- and info-level logs.
  stage.match {
    selector = &amp;#34;{job!=\&amp;#34;\&amp;#34;} |~ \&amp;#34;level=(debug|info)\&amp;#34;&amp;#34;
    action   = &amp;#34;drop&amp;#34;
  }

  // Send processed logs to our argument.
  forward_to = argument.write_to.value
}

// export.filter_input exports a value to the module consumer.
export &amp;#34;filter_input&amp;#34; {
  // Expose the receiver of loki.process so the module consumer can send
  // logs to our loki.process component.
  value = loki.process.filter.receiver
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can save the module to a file and then use it as a processing step before writing logs to Loki.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;self&amp;#34; {
  targets = LOG_TARGETS

  // Forward collected logs to the input of our filter.
  forward_to = [module.file.log_filter.exports.filter_input]
}

module.file &amp;#34;log_filter&amp;#34; {
  filename = &amp;#34;/path/to/modules/log_filter.river&amp;#34;

  arguments {
    // Configure the filter to forward filtered logs to loki.write below.
    write_to = [loki.write.default.receiver],
  }
}

loki.write &amp;#34;default&amp;#34; {
  endpoint {
    url = &amp;#34;LOKI_URL&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

]]></content><description>&lt;h1 id="modules">Modules&lt;/h1>
&lt;p>A &lt;em>Module&lt;/em> is a unit of Grafana Agent Flow configuration, which combines all the other concepts, containing a mix of configuration blocks, instantiated components, and custom component definitions.
The module passed as an argument to &lt;a href="../../reference/cli/run/">the &lt;code>run&lt;/code> command&lt;/a> is called the &lt;em>main configuration&lt;/em>.&lt;/p></description></item><item><title>Clustering</title><link>https://grafana.com/docs/agent/v0.44/flow/concepts/clustering/</link><pubDate>Wed, 29 Jan 2025 11:00:55 +0000</pubDate><guid>https://grafana.com/docs/agent/v0.44/flow/concepts/clustering/</guid><content><![CDATA[&lt;h1 id=&#34;clustering&#34;&gt;Clustering&lt;/h1&gt;
&lt;p&gt;Clustering enables a fleet of Grafana Agents to work together for workload distribution and high availability.
It helps create horizontally scalable deployments with minimal resource and operational overhead.&lt;/p&gt;
&lt;p&gt;To achieve this, Grafana Agent Flow makes use of an eventually consistent model that assumes all participating
Grafana Agents are interchangeable and converge on using the same configuration file.&lt;/p&gt;
&lt;p&gt;The behavior of a standalone, non-clustered Grafana Agent is the same as if it were a single-node cluster.&lt;/p&gt;
&lt;p&gt;You configure clustering by passing &lt;code&gt;cluster&lt;/code&gt; command-line flags to the 
    &lt;a href=&#34;/docs/agent/v0.44/flow/reference/cli/run/#clustering&#34;&gt;run&lt;/a&gt; command.&lt;/p&gt;
&lt;h2 id=&#34;use-cases&#34;&gt;Use cases&lt;/h2&gt;
&lt;h3 id=&#34;target-auto-distribution&#34;&gt;Target auto-distribution&lt;/h3&gt;
&lt;p&gt;Target auto-distribution is the most basic use case of clustering.
It allows scraping components running on all peers to distribute the scrape load between themselves.
Target auto-distribution requires that all Grafana Agent in the same cluster can reach the same service discovery APIs and scrape the same targets.&lt;/p&gt;
&lt;p&gt;You must explicitly enable target auto-distribution on components by defining a &lt;code&gt;clustering&lt;/code&gt; block.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;default&amp;#34; {
    clustering {
        enabled = true
    }

    ...
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;A cluster state change is detected when a new node joins or an existing node leaves.
All participating components locally recalculate target ownership and re-balance the number of targets they’re scraping without explicitly communicating ownership over the network.&lt;/p&gt;
&lt;p&gt;Target auto-distribution allows you to dynamically scale the number of Grafana Agents to distribute workload during peaks.
It also provides resiliency because targets are automatically picked up by one of the node peers if a node leaves.&lt;/p&gt;
&lt;p&gt;Grafana Agent Flow uses a local consistent hashing algorithm to distribute targets, meaning that, on average, only ~1/N of the targets are redistributed.&lt;/p&gt;
&lt;p&gt;Refer to component reference documentation to discover whether it supports clustering, such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/agent/v0.44/flow/reference/components/prometheus.scrape/#clustering-beta&#34;&gt;prometheus.scrape&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/agent/v0.44/flow/reference/components/pyroscope.scrape/#clustering-beta&#34;&gt;pyroscope.scrape&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/agent/v0.44/flow/reference/components/prometheus.operator.podmonitors/#clustering-beta&#34;&gt;prometheus.operator.podmonitors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/agent/v0.44/flow/reference/components/prometheus.operator.servicemonitors/#clustering-beta&#34;&gt;prometheus.operator.servicemonitors&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;cluster-monitoring-and-troubleshooting&#34;&gt;Cluster monitoring and troubleshooting&lt;/h2&gt;
&lt;p&gt;You can use the Grafana Agent Flow UI 
    &lt;a href=&#34;/docs/agent/v0.44/flow/tasks/debug/#clustering-page&#34;&gt;clustering page&lt;/a&gt; to monitor your cluster status.
Refer to 
    &lt;a href=&#34;/docs/agent/v0.44/flow/tasks/debug/#debugging-clustering-issues&#34;&gt;Debugging clustering issues&lt;/a&gt; for additional troubleshooting information.&lt;/p&gt;
]]></content><description>&lt;h1 id="clustering">Clustering&lt;/h1>
&lt;p>Clustering enables a fleet of Grafana Agents to work together for workload distribution and high availability.
It helps create horizontally scalable deployments with minimal resource and operational overhead.&lt;/p></description></item></channel></rss>