<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Configuration language on Grafana Labs</title><link>https://grafana.com/docs/agent/v0.31/flow/config-language/</link><description>Recent content in Configuration language on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/agent/v0.31/flow/config-language/index.xml" rel="self" type="application/rss+xml"/><item><title>Files</title><link>https://grafana.com/docs/agent/v0.31/flow/config-language/files/</link><pubDate>Sun, 08 Mar 2026 02:10:29 +0000</pubDate><guid>https://grafana.com/docs/agent/v0.31/flow/config-language/files/</guid><content><![CDATA[&lt;h1 id=&#34;files&#34;&gt;Files&lt;/h1&gt;
&lt;p&gt;River files are plaintext files with the &lt;code&gt;.river&lt;/code&gt; file extension. Each River
file may be referred to as a &amp;ldquo;configuration file,&amp;rdquo; or a &amp;ldquo;River configuration.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;River files are required to be UTF-8 encoded, and are permitted to contain
Unicode characters. River files can use both Unix-style line endings (LF) and
Windows-style line endings (CRLF), but formatters may replace all line endings
with Unix-style ones.&lt;/p&gt;
&lt;h2 id=&#34;community-tooling&#34;&gt;Community tooling&lt;/h2&gt;
&lt;p&gt;There is experimental support for River in
&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; and in
&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;/p&gt;
]]></content><description>&lt;h1 id="files">Files&lt;/h1>
&lt;p>River files are plaintext files with the &lt;code>.river&lt;/code> file extension. Each River
file may be referred to as a &amp;ldquo;configuration file,&amp;rdquo; or a &amp;ldquo;River configuration.&amp;rdquo;&lt;/p></description></item><item><title>Syntax</title><link>https://grafana.com/docs/agent/v0.31/flow/config-language/syntax/</link><pubDate>Sun, 08 Mar 2026 02:10:29 +0000</pubDate><guid>https://grafana.com/docs/agent/v0.31/flow/config-language/syntax/</guid><content><![CDATA[&lt;h1 id=&#34;syntax&#34;&gt;Syntax&lt;/h1&gt;
&lt;p&gt;The River syntax is designed to be easy to read and write. Essentially, there
are just two high-level elements to it: &lt;em&gt;Attributes&lt;/em&gt; and &lt;em&gt;Blocks&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;River is a &lt;em&gt;declarative&lt;/em&gt; language used to build programmable pipelines.
As such, the ordering of blocks and attributes within the River configuration
file is not important; the language will consider all direct and indirect
dependencies between elements to determine their relationships.&lt;/p&gt;
&lt;h2 id=&#34;comments&#34;&gt;Comments&lt;/h2&gt;
&lt;p&gt;River configuration files support single-line &lt;code&gt;//&lt;/code&gt; as well as block &lt;code&gt;/* */&lt;/code&gt;
comments.&lt;/p&gt;
&lt;h2 id=&#34;identifiers&#34;&gt;Identifiers&lt;/h2&gt;
&lt;p&gt;River considers an identifier as valid if it consists of one or more UTF-8
letters (A through Z, both upper- and lower-case), digits or underscores, but
doesn&amp;rsquo;t start with a digit.&lt;/p&gt;
&lt;h2 id=&#34;attributes-and-blocks&#34;&gt;Attributes and Blocks&lt;/h2&gt;
&lt;h3 id=&#34;attributes&#34;&gt;Attributes&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;Attributes&lt;/em&gt; are used to configure individual settings. They always take the
form of &lt;code&gt;ATTRIBUTE_NAME = ATTRIBUTE_VALUE&lt;/code&gt;. They can appear either as
top-level elements or nested within blocks.&lt;/p&gt;
&lt;p&gt;The following example sets 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;p&gt;The &lt;code&gt;ATTRIBUTE_NAME&lt;/code&gt; must be a valid River &lt;a href=&#34;#identifier&#34;&gt;identifier&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;ATTRIBUTE_VALUE&lt;/code&gt; can be either a constant value of a valid River
&lt;a href=&#34;../expressions/types_and_values/&#34;&gt;type&lt;/a&gt; (eg. string,
boolean, number) or an &lt;a href=&#34;../expressions/&#34;&gt;&lt;em&gt;expression&lt;/em&gt;&lt;/a&gt;
to represent or compute more complex attribute values.&lt;/p&gt;
&lt;h3 id=&#34;blocks&#34;&gt;Blocks&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;Blocks&lt;/em&gt; are used to configure the Agent behavior as well as Flow components by
grouping any number of attributes or nested blocks using curly braces.
Blocks have a &lt;em&gt;name&lt;/em&gt;, an optional &lt;em&gt;label&lt;/em&gt; and a body that contains any number
of arguments and nested unlabeled blocks.&lt;/p&gt;
&lt;h4 id=&#34;pattern-for-creating-an-unlabeled-block&#34;&gt;Pattern for creating an unlabeled block&lt;/h4&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;BLOCK_NAME {
  // Block body can contain attributes and nested unlabeled blocks
  IDENTIFIER = EXPRESSION // Attribute

  NESTED_BLOCK_NAME {
    // Nested block body
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;pattern-for-creating-a-labeled-block&#34;&gt;Pattern for creating a labeled block&lt;/h4&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;// Pattern for creating a labeled block:
BLOCK_NAME &amp;#34;BLOCK_LABEL&amp;#34; {
  // Block body can contain attributes and nested unlabeled blocks
  IDENTIFIER = EXPRESSION // Attribute

  NESTED_BLOCK_NAME {
    // Nested block body
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;block-naming-rules&#34;&gt;Block naming rules&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;BLOCK_NAME&lt;/code&gt; has to be recognized by Flow as either a valid component
name or a special block for configuring global settings. If the &lt;code&gt;BLOCK_LABEL&lt;/code&gt;
has to be set, it must be a valid River &lt;a href=&#34;#identifiers&#34;&gt;identifier&lt;/a&gt; wrapped in
double quotes. In these cases the label will be used to disambiguate between
multiple top-level blocks of the same name.&lt;/p&gt;
&lt;p&gt;The following snippet defines a block named &lt;code&gt;local.file&lt;/code&gt; with its label set to
&amp;ldquo;token&amp;rdquo;. The block&amp;rsquo;s body sets the to the contents of the &lt;code&gt;TOKEN_FILE_PATH&lt;/code&gt;
environment variable by using an expression and the &lt;code&gt;is_secret&lt;/code&gt; attribute is
set to the boolean &lt;code&gt;true&lt;/code&gt;, marking the file content as sensitive.&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;token&amp;#34; {
  filename  = env(&amp;#34;TOKEN_FILE_PATH&amp;#34;) // Use an expression to read from an env var.
  is_secret = true
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;terminators&#34;&gt;Terminators&lt;/h2&gt;
&lt;p&gt;All block and attribute definitions are followed by a newline, which River
calls a &lt;em&gt;terminator&lt;/em&gt;, as it terminates the current statement.&lt;/p&gt;
&lt;p&gt;A newline is treated as terminator when it follows any expression, &lt;code&gt;]&lt;/code&gt;,
&lt;code&gt;)&lt;/code&gt; or &lt;code&gt;}&lt;/code&gt;. Other newlines are ignored by River and and a user can enter as many
newlines as they want.&lt;/p&gt;
]]></content><description>&lt;h1 id="syntax">Syntax&lt;/h1>
&lt;p>The River syntax is designed to be easy to read and write. Essentially, there
are just two high-level elements to it: &lt;em>Attributes&lt;/em> and &lt;em>Blocks&lt;/em>.&lt;/p></description></item><item><title>Components</title><link>https://grafana.com/docs/agent/v0.31/flow/config-language/components/</link><pubDate>Sun, 08 Mar 2026 02:10:29 +0000</pubDate><guid>https://grafana.com/docs/agent/v0.31/flow/config-language/components/</guid><content><![CDATA[&lt;h1 id=&#34;components&#34;&gt;Components&lt;/h1&gt;
&lt;p&gt;Components are the defining feature of Grafana Agent Flow. They are small,
reusable pieces of business logic that perform a single task (like retrieving
secrets or collecting Prometheus metrics) and can be wired together to form
programmable pipelines of telemetry data.&lt;/p&gt;
&lt;p&gt;Under the hood, components are orchestrated via the &lt;a href=&#34;../../concepts/component_controller/&#34;&gt;&lt;em&gt;component
controller&lt;/em&gt;&lt;/a&gt;, which is
responsible for scheduling them, reporting their health and debug status,
re-evaluating their arguments and providing their exports.&lt;/p&gt;
&lt;h2 id=&#34;configuring-components&#34;&gt;Configuring components&lt;/h2&gt;
&lt;p&gt;Components are created by defining a top-level River block. All components
are identified by their name, describing what the component is responsible for,
while some allow or require to provide an extra user-specified &lt;em&gt;label&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&#34;../../reference/components/&#34;&gt;components docs&lt;/a&gt; contain a list
of all available components. Each one has a complete reference page, so getting
a component to work for you should be as easy as reading its documentation and
copy/pasting from an example.&lt;/p&gt;
&lt;h2 id=&#34;arguments-and-exports&#34;&gt;Arguments and exports&lt;/h2&gt;
&lt;p&gt;Most user interactions with components will center around two basic concepts;
&lt;em&gt;arguments&lt;/em&gt; and &lt;em&gt;exports&lt;/em&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Arguments&lt;/em&gt; are settings which modify the behavior of a component. They can
be any number of attributes or nested unlabeled blocks, some of them being
required and some being optional. Any optional arguments that are not set will
take on their default values.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Exports&lt;/em&gt; are zero or more output values that can be referred to by other
components, and can be of any River type.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here&amp;rsquo;s a quick example; the following block defines a &lt;code&gt;local.file&lt;/code&gt; component
labeled &amp;ldquo;targets&amp;rdquo;. The &lt;code&gt;local.file.targets&lt;/code&gt; component will then expose the
file &lt;code&gt;content&lt;/code&gt; as a string in its exports.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;filename&lt;/code&gt; attribute is a &lt;em&gt;required&lt;/em&gt; argument; the user can also define a
number of &lt;em&gt;optional&lt;/em&gt; ones, in this case &lt;code&gt;detector&lt;/code&gt;, &lt;code&gt;poll_frequency&lt;/code&gt; and
&lt;code&gt;is_secret&lt;/code&gt;, which configure how and how often the file should be polled
as well as whether its contents are sensitive or not.&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;targets&amp;#34; {
  // Required argument
  filename = &amp;#34;/etc/agent/targets&amp;#34;

  // Optional arguments: Components may have some optional arguments that
  // do not need to be defined.
  //
  // The optional arguments for local.file are is_secret, detector, and
  // poll_frequency.

  // Exports: a single field named `content`
  // It can be referred to as `local.file.targets.content`
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;referencing-components&#34;&gt;Referencing components&lt;/h2&gt;
&lt;p&gt;To wire components together, one can use the exports of one as the arguments
to another by using references. References can only appear in components.&lt;/p&gt;
&lt;p&gt;For example, here&amp;rsquo;s a component that scrapes Prometheus metrics. The &lt;code&gt;targets&lt;/code&gt;
field is populated with two scrape targets; a constant one &lt;code&gt;localhost:9001&lt;/code&gt; and
an expression that ties the target to the value of
&lt;code&gt;local.file.targets.content&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.scrape &amp;#34;default&amp;#34; {
  targets = [
    { &amp;#34;__address__&amp;#34; = local.file.targets.content }, // tada!
    { &amp;#34;__address__&amp;#34; = &amp;#34;localhost:9001&amp;#34; },
  ]

  forward_to = [prometheus.remote_write.default.receiver]
  scrape_config {
    job_name = &amp;#34;default&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Every time the file contents change, the &lt;code&gt;local.file&lt;/code&gt; will update its exports,
so the new value will provided to &lt;code&gt;prometheus.scrape&lt;/code&gt; targets field.&lt;/p&gt;
&lt;p&gt;Each argument and exported field has an underlying &lt;a href=&#34;../expressions/types_and_values/&#34;&gt;type&lt;/a&gt;.
River will type-check expressions before assigning a value to an attribute; the
documentation of each component will have more information about the ways that
you can wire components together.&lt;/p&gt;
&lt;p&gt;In the previous example, the contents of the &lt;code&gt;local.file.targets.content&lt;/code&gt;
expression must first be evaluated in a concrete value then type-checked and
substituted into &lt;code&gt;prometheus.scrape.default&lt;/code&gt; for it to be configured in turn.&lt;/p&gt;
]]></content><description>&lt;h1 id="components">Components&lt;/h1>
&lt;p>Components are the defining feature of Grafana Agent Flow. They are small,
reusable pieces of business logic that perform a single task (like retrieving
secrets or collecting Prometheus metrics) and can be wired together to form
programmable pipelines of telemetry data.&lt;/p></description></item><item><title>Expressions</title><link>https://grafana.com/docs/agent/v0.31/flow/config-language/expressions/</link><pubDate>Sun, 08 Mar 2026 02:10:29 +0000</pubDate><guid>https://grafana.com/docs/agent/v0.31/flow/config-language/expressions/</guid><content><![CDATA[&lt;h1 id=&#34;expressions&#34;&gt;Expressions&lt;/h1&gt;
&lt;p&gt;Expressions represent or compute values that can be assigned to attributes
within a configuration.&lt;/p&gt;
&lt;p&gt;Basic expressions are literal values, like &lt;code&gt;&amp;quot;Hello, world!&amp;quot;&lt;/code&gt; or &lt;code&gt;true&lt;/code&gt;.
Expressions may also do things like &lt;a href=&#34;referencing_exports/&#34;&gt;refer to values&lt;/a&gt; exported by components,
perform arithmetic, or &lt;a href=&#34;function_calls/&#34;&gt;call functions&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Expressions can be used when configuring any component. As all component
arguments have an underlying &lt;a href=&#34;types_and_values/&#34;&gt;type&lt;/a&gt;, River will type-check expressions before
assigning the result to an attribute.&lt;/p&gt;
]]></content><description>&lt;h1 id="expressions">Expressions&lt;/h1>
&lt;p>Expressions represent or compute values that can be assigned to attributes
within a configuration.&lt;/p>
&lt;p>Basic expressions are literal values, like &lt;code>&amp;quot;Hello, world!&amp;quot;&lt;/code> or &lt;code>true&lt;/code>.
Expressions may also do things like &lt;a href="referencing_exports/">refer to values&lt;/a> exported by components,
perform arithmetic, or &lt;a href="function_calls/">call functions&lt;/a>.&lt;/p></description></item></channel></rss>