<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.44/flow/concepts/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.44/flow/concepts/config-language/index.xml" rel="self" type="application/rss+xml"/><item><title>Files</title><link>https://grafana.com/docs/agent/v0.44/flow/concepts/config-language/files/</link><pubDate>Wed, 29 Jan 2025 11:00:55 +0000</pubDate><guid>https://grafana.com/docs/agent/v0.44/flow/concepts/config-language/files/</guid><content><![CDATA[&lt;h1 id=&#34;files&#34;&gt;Files&lt;/h1&gt;
&lt;p&gt;River files are plain text files with the &lt;code&gt;.river&lt;/code&gt; file extension.
You can refer to each River file as a &amp;ldquo;configuration file&amp;rdquo; or a &amp;ldquo;River configuration.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;River files must be UTF-8 encoded and can contain Unicode characters.
River files can use 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;
]]></content><description>&lt;h1 id="files">Files&lt;/h1>
&lt;p>River files are plain text files with the &lt;code>.river&lt;/code> file extension.
You can refer to each River file 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.44/flow/concepts/config-language/syntax/</link><pubDate>Wed, 29 Jan 2025 11:00:55 +0000</pubDate><guid>https://grafana.com/docs/agent/v0.44/flow/concepts/config-language/syntax/</guid><content><![CDATA[&lt;h1 id=&#34;syntax&#34;&gt;Syntax&lt;/h1&gt;
&lt;p&gt;The River syntax is easy to read and write. It has only two high-level elements, &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.
The order of blocks and attributes within the River configuration file isn&amp;rsquo;t important.
The language considers 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; and 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;You use &lt;em&gt;Attributes&lt;/em&gt; 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;#identifiers&#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;/docs/agent/v0.44/flow/concepts/config-language/expressions/types_and_values/&#34;&gt;type&lt;/a&gt; (for example, a string, boolean, number),
or an 
    &lt;a href=&#34;/docs/agent/v0.44/flow/concepts/config-language/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;You use &lt;em&gt;Blocks&lt;/em&gt; to configure the Grafana Agent&amp;rsquo;s behavior as well as Grafana Agent 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;p&gt;Some blocks can be defined more than once.&lt;/p&gt;
&lt;h4 id=&#34;examples&#34;&gt;Examples&lt;/h4&gt;
&lt;p&gt;You can use the following pattern to create an unlabeled 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;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;p&gt;You can use the following pattern to create a labeled 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;// 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 Grafana Agent 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; must 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, you use the label 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 &lt;code&gt;filename&lt;/code&gt; to the content 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 a 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;.
River ignores other newlines and you can can enter as many newlines as you want.&lt;/p&gt;
]]></content><description>&lt;h1 id="syntax">Syntax&lt;/h1>
&lt;p>The River syntax is easy to read and write. It has only two high-level elements, &lt;em>Attributes&lt;/em> and &lt;em>Blocks&lt;/em>.&lt;/p>
&lt;p>River is a &lt;em>declarative&lt;/em> language used to build programmable pipelines.
The order of blocks and attributes within the River configuration file isn&amp;rsquo;t important.
The language considers all direct and indirect dependencies between elements to determine their relationships.&lt;/p></description></item><item><title>Components configuration language</title><link>https://grafana.com/docs/agent/v0.44/flow/concepts/config-language/components/</link><pubDate>Wed, 29 Jan 2025 11:00:55 +0000</pubDate><guid>https://grafana.com/docs/agent/v0.44/flow/concepts/config-language/components/</guid><content><![CDATA[&lt;h1 id=&#34;components-configuration-language&#34;&gt;Components configuration language&lt;/h1&gt;
&lt;p&gt;Components are the defining feature of Grafana Agent Flow.
Components are small, reusable pieces of business logic that perform a single task like retrieving secrets or collecting Prometheus metrics,
and you can wire them together to form programmable pipelines of telemetry data.&lt;/p&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/agent/v0.44/flow/concepts/component_controller/&#34;&gt;&lt;em&gt;component controller&lt;/em&gt;&lt;/a&gt; is responsible for scheduling components, 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;You create 
    &lt;a href=&#34;/docs/agent/v0.44/flow/reference/components/&#34;&gt;components&lt;/a&gt; by defining a top-level River block.
All components are identified by their name, describing what the component is responsible for, and a user-specified &lt;em&gt;label&lt;/em&gt;.&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 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 that modify the behavior of a component.
They can be any number of attributes or nested unlabeled blocks, some required and some optional.
Any optional arguments that aren&amp;rsquo;t set 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 other components can refer to and can be of any River type.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;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 exposes 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.
You can also define a number of &lt;em&gt;optional&lt;/em&gt; arguments, 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;,
that configure how and how often the file should be polled and whether its contents are 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;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 target &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;Each time the file contents change, the &lt;code&gt;local.file&lt;/code&gt; updates its exports. The new value is sent to the &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;/docs/agent/v0.44/flow/concepts/config-language/expressions/types_and_values/&#34;&gt;type&lt;/a&gt;.
River checks the expression type before assigning a value to an attribute.
The documentation of each 
    &lt;a href=&#34;/docs/agent/v0.44/flow/reference/components/&#34;&gt;component&lt;/a&gt; provides more information about how to 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 is evaluated to a concrete value.
The value is type-checked and substituted into &lt;code&gt;prometheus.scrape.default&lt;/code&gt;, where you can configure it.&lt;/p&gt;
]]></content><description>&lt;h1 id="components-configuration-language">Components configuration language&lt;/h1>
&lt;p>Components are the defining feature of Grafana Agent Flow.
Components are small, reusable pieces of business logic that perform a single task like retrieving secrets or collecting Prometheus metrics,
and you can wire them together to form programmable pipelines of telemetry data.&lt;/p></description></item><item><title>Expressions</title><link>https://grafana.com/docs/agent/v0.44/flow/concepts/config-language/expressions/</link><pubDate>Wed, 29 Jan 2025 11:00:55 +0000</pubDate><guid>https://grafana.com/docs/agent/v0.44/flow/concepts/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 you can assign 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;/docs/agent/v0.44/flow/concepts/config-language/expressions/referencing_exports/&#34;&gt;refer to values&lt;/a&gt; exported by components, perform arithmetic, or 
    &lt;a href=&#34;/docs/agent/v0.44/flow/concepts/config-language/expressions/function_calls/&#34;&gt;call functions&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You use expressions when you configure any component.
All component arguments have an underlying 
    &lt;a href=&#34;/docs/agent/v0.44/flow/concepts/config-language/expressions/types_and_values/&#34;&gt;type&lt;/a&gt;.
River checks the expression type 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 you can assign 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="/docs/agent/v0.44/flow/concepts/config-language/expressions/referencing_exports/">refer to values&lt;/a> exported by components, perform arithmetic, or
&lt;a href="/docs/agent/v0.44/flow/concepts/config-language/expressions/function_calls/">call functions&lt;/a>.&lt;/p></description></item></channel></rss>