<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Reading Alloy configuration on Grafana Labs</title><link>https://grafana.com/docs/learning-hub/intro-to-alloy/04-reading-configuration/</link><description>Recent content in Reading Alloy configuration on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/learning-hub/intro-to-alloy/04-reading-configuration/index.xml" rel="self" type="application/rss+xml"/><item><title>Configuration file anatomy</title><link>https://grafana.com/docs/learning-hub/intro-to-alloy/04-reading-configuration/11-configuration-anatomy/</link><pubDate>Fri, 14 Aug 2026 09:40:11 -0500</pubDate><guid>https://grafana.com/docs/learning-hub/intro-to-alloy/04-reading-configuration/11-configuration-anatomy/</guid><content><![CDATA[&lt;h2 id=&#34;configuration-file-anatomy&#34;&gt;Configuration file anatomy&lt;/h2&gt;
&lt;p&gt;To read an Alloy configuration, start by recognizing its parts. An Alloy configuration file is made of attributes, expressions, and blocks. These elements describe the settings and behavior that Alloy loads.&lt;/p&gt;
&lt;h3 id=&#34;attributes&#34;&gt;Attributes&lt;/h3&gt;
&lt;p&gt;Attributes are &lt;code&gt;key = value&lt;/code&gt; pairs that configure individual settings:&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;url = &amp;#34;http://localhost:9090&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Here, &lt;code&gt;url&lt;/code&gt; is the attribute name. The value on the right side of &lt;code&gt;=&lt;/code&gt; comes from an expression.&lt;/p&gt;
&lt;h3 id=&#34;expressions&#34;&gt;Expressions&lt;/h3&gt;
&lt;p&gt;Expressions compute the values that attributes use. An expression can be:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A constant, such as &lt;code&gt;&amp;quot;localhost:9090&amp;quot;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;A calculation, such as &lt;code&gt;(1 &#43; 2) * 3&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;A standard library call, such as &lt;code&gt;sys.env(&amp;quot;HOME&amp;quot;)&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Alloy evaluates an expression before assigning its result to an attribute. There is a fourth kind of expression, a reference to another component&amp;rsquo;s export, that you trace later in this section.&lt;/p&gt;
&lt;h3 id=&#34;blocks&#34;&gt;Blocks&lt;/h3&gt;
&lt;p&gt;Blocks group related attributes and nested blocks between &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt;. Most blocks you read define components. A component block has a name and a label:&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;example&amp;#34; {
  filename = &amp;#34;/tmp/example.txt&amp;#34;
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Here, &lt;code&gt;local.file&lt;/code&gt; is the component name, &lt;code&gt;&amp;quot;example&amp;quot;&lt;/code&gt; is the label, and &lt;code&gt;filename&lt;/code&gt; is an attribute inside the block.&lt;/p&gt;
]]></content><description>&lt;h2 id="configuration-file-anatomy">Configuration file anatomy&lt;/h2>
&lt;p>To read an Alloy configuration, start by recognizing its parts. An Alloy configuration file is made of attributes, expressions, and blocks. These elements describe the settings and behavior that Alloy loads.&lt;/p></description></item><item><title>Arguments and exports</title><link>https://grafana.com/docs/learning-hub/intro-to-alloy/04-reading-configuration/12-arguments-and-exports/</link><pubDate>Fri, 14 Aug 2026 09:40:11 -0500</pubDate><guid>https://grafana.com/docs/learning-hub/intro-to-alloy/04-reading-configuration/12-arguments-and-exports/</guid><content><![CDATA[&lt;h2 id=&#34;arguments-and-exports&#34;&gt;Arguments and exports&lt;/h2&gt;
&lt;p&gt;Every component has two main parts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Arguments&lt;/strong&gt; configure the component&amp;rsquo;s behavior. They are the attributes and nested blocks you write inside the component block.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Exports&lt;/strong&gt; are values that the running component makes available for other components to reference. You don&amp;rsquo;t write exports in the configuration; the component type provides them.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A component can have zero or more exports, and optional arguments can have defaults.&lt;/p&gt;
&lt;p&gt;Recall the &lt;code&gt;local.file&lt;/code&gt; example:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;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;example&amp;#34; {
  filename = &amp;#34;/tmp/example.txt&amp;#34;
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Here, &lt;code&gt;filename&lt;/code&gt; is an argument that tells &lt;code&gt;local.file&lt;/code&gt; which file to read. The &lt;code&gt;local.file&lt;/code&gt; component also provides a &lt;code&gt;content&lt;/code&gt; export, which holds the latest contents of that file.&lt;/p&gt;
&lt;h2 id=&#34;connecting-components&#34;&gt;Connecting components&lt;/h2&gt;
&lt;p&gt;When one component uses another component&amp;rsquo;s export as an argument, that reference connects the two. These connections are how components become the pipelines that collect, process, and send telemetry.&lt;/p&gt;
]]></content><description>&lt;h2 id="arguments-and-exports">Arguments and exports&lt;/h2>
&lt;p>Every component has two main parts:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Arguments&lt;/strong> configure the component&amp;rsquo;s behavior. They are the attributes and nested blocks you write inside the component block.&lt;/li>
&lt;li>&lt;strong>Exports&lt;/strong> are values that the running component makes available for other components to reference. You don&amp;rsquo;t write exports in the configuration; the component type provides them.&lt;/li>
&lt;/ul>
&lt;p>A component can have zero or more exports, and optional arguments can have defaults.&lt;/p></description></item><item><title>Trace a component reference</title><link>https://grafana.com/docs/learning-hub/intro-to-alloy/04-reading-configuration/13-trace-a-reference/</link><pubDate>Fri, 14 Aug 2026 09:40:11 -0500</pubDate><guid>https://grafana.com/docs/learning-hub/intro-to-alloy/04-reading-configuration/13-trace-a-reference/</guid><content><![CDATA[&lt;h2 id=&#34;trace-a-component-reference&#34;&gt;Trace a component reference&lt;/h2&gt;
&lt;p&gt;References are how components connect, so reading one is a core skill. The following example shows how one component&amp;rsquo;s export supplies another component&amp;rsquo;s argument. You don&amp;rsquo;t need to run 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;local.file &amp;#34;example&amp;#34; {
  filename = sys.env(&amp;#34;HOME&amp;#34;) &amp;#43; &amp;#34;/file.txt&amp;#34;
}

prometheus.remote_write &amp;#34;local_prom&amp;#34; {
  endpoint {
    url = &amp;#34;http://localhost:9090/api/v1/write&amp;#34;

    basic_auth {
      username = &amp;#34;admin&amp;#34;
      password = local.file.example.content
    }
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This example has two components. You already met &lt;code&gt;local.file&lt;/code&gt;, which reads a file and exports its contents. &lt;code&gt;prometheus.remote_write&lt;/code&gt; sends metrics to a Prometheus-compatible endpoint. Inside it, &lt;code&gt;endpoint&lt;/code&gt; and &lt;code&gt;basic_auth&lt;/code&gt; are nested argument blocks that group related settings.&lt;/p&gt;
&lt;h2 id=&#34;read-the-source-component&#34;&gt;Read the source component&lt;/h2&gt;
&lt;p&gt;Start with the &lt;code&gt;local.file &amp;quot;example&amp;quot;&lt;/code&gt; block. You already know the name and label. What&amp;rsquo;s new here is the &lt;code&gt;filename&lt;/code&gt; expression: &lt;code&gt;sys.env(&amp;quot;HOME&amp;quot;) &#43; &amp;quot;/file.txt&amp;quot;&lt;/code&gt; builds the path at runtime.&lt;/p&gt;
&lt;p&gt;As before, this component type also provides a &lt;code&gt;content&lt;/code&gt; export. That export isn&amp;rsquo;t written in the block. Other components reference it.&lt;/p&gt;
&lt;h2 id=&#34;find-and-read-the-reference&#34;&gt;Find and read the reference&lt;/h2&gt;
&lt;p&gt;Now find where that export is used. The &lt;code&gt;password&lt;/code&gt; argument inside &lt;code&gt;basic_auth&lt;/code&gt; is set to &lt;code&gt;local.file.example.content&lt;/code&gt;. Read that expression from left to right:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;local.file&lt;/code&gt; identifies the component type.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;example&lt;/code&gt; identifies the labeled instance.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;content&lt;/code&gt; identifies the export.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The component type and label together, &lt;code&gt;local.file.example&lt;/code&gt;, are the component&amp;rsquo;s fully qualified name.&lt;/p&gt;
&lt;p&gt;The reference means Alloy evaluates &lt;code&gt;local.file.example&lt;/code&gt; first, then supplies its &lt;code&gt;content&lt;/code&gt; export as the &lt;code&gt;password&lt;/code&gt; argument. This single reference creates a dependency: &lt;code&gt;prometheus.remote_write.local_prom&lt;/code&gt; depends on &lt;code&gt;local.file.example&lt;/code&gt;.&lt;/p&gt;
]]></content><description>&lt;h2 id="trace-a-component-reference">Trace a component reference&lt;/h2>
&lt;p>References are how components connect, so reading one is a core skill. The following example shows how one component&amp;rsquo;s export supplies another component&amp;rsquo;s argument. You don&amp;rsquo;t need to run it.&lt;/p></description></item><item><title>Circular dependencies</title><link>https://grafana.com/docs/learning-hub/intro-to-alloy/04-reading-configuration/14-circular-dependencies/</link><pubDate>Fri, 14 Aug 2026 09:40:11 -0500</pubDate><guid>https://grafana.com/docs/learning-hub/intro-to-alloy/04-reading-configuration/14-circular-dependencies/</guid><content><![CDATA[&lt;h2 id=&#34;circular-dependencies&#34;&gt;Circular dependencies&lt;/h2&gt;
&lt;p&gt;In the previous slide, a reference created a dependency: &lt;code&gt;prometheus.remote_write.local_prom&lt;/code&gt; depended on &lt;code&gt;local.file.example&lt;/code&gt;. Alloy uses dependencies like that to decide which components to evaluate first. Because it needs a clear order, those dependencies can&amp;rsquo;t form a circle.&lt;/p&gt;
&lt;h2 id=&#34;invalid-examples&#34;&gt;Invalid examples&lt;/h2&gt;
&lt;p&gt;A component can&amp;rsquo;t reference itself:&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: direct self-reference.
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;p&gt;Components also can&amp;rsquo;t reference each other in a loop:&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: circular dependency.
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;p&gt;Here, &lt;code&gt;a&lt;/code&gt; depends on &lt;code&gt;b&lt;/code&gt;, while &lt;code&gt;b&lt;/code&gt; depends on &lt;code&gt;a&lt;/code&gt;. Neither can be evaluated first.&lt;/p&gt;
&lt;h2 id=&#34;how-to-spot-a-loop&#34;&gt;How to spot a loop&lt;/h2&gt;
&lt;p&gt;When you read component references, follow each dependency in its direction. If following the references brings you back to a component you already visited, the configuration has a circular dependency and is invalid.&lt;/p&gt;
]]></content><description>&lt;h2 id="circular-dependencies">Circular dependencies&lt;/h2>
&lt;p>In the previous slide, a reference created a dependency: &lt;code>prometheus.remote_write.local_prom&lt;/code> depended on &lt;code>local.file.example&lt;/code>. Alloy uses dependencies like that to decide which components to evaluate first. Because it needs a clear order, those dependencies can&amp;rsquo;t form a circle.&lt;/p></description></item><item><title>Resources</title><link>https://grafana.com/docs/learning-hub/intro-to-alloy/04-reading-configuration/15-resources/</link><pubDate>Fri, 14 Aug 2026 09:40:11 -0500</pubDate><guid>https://grafana.com/docs/learning-hub/intro-to-alloy/04-reading-configuration/15-resources/</guid><content><![CDATA[&lt;h2 id=&#34;resources&#34;&gt;Resources&lt;/h2&gt;
&lt;p&gt;Use these resources to go deeper on Alloy configuration syntax and components.&lt;/p&gt;
&lt;h2 id=&#34;documentation&#34;&gt;Documentation&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;/docs/alloy/latest/get-started/syntax/&#34;&gt;Alloy syntax&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;/docs/alloy/latest/get-started/expressions/&#34;&gt;Expressions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;/docs/alloy/latest/reference/stdlib/&#34;&gt;Standard library&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;/docs/alloy/latest/get-started/components/&#34;&gt;Components&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;/docs/alloy/latest/reference/components/&#34;&gt;Component reference&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h2 id="resources">Resources&lt;/h2>
&lt;p>Use these resources to go deeper on Alloy configuration syntax and components.&lt;/p>
&lt;h2 id="documentation">Documentation&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="/docs/alloy/latest/get-started/syntax/">Alloy syntax&lt;/a>&lt;/li>
&lt;li>&lt;a href="/docs/alloy/latest/get-started/expressions/">Expressions&lt;/a>&lt;/li>
&lt;li>&lt;a href="/docs/alloy/latest/reference/stdlib/">Standard library&lt;/a>&lt;/li>
&lt;li>&lt;a href="/docs/alloy/latest/get-started/components/">Components&lt;/a>&lt;/li>
&lt;li>&lt;a href="/docs/alloy/latest/reference/components/">Component reference&lt;/a>&lt;/li>
&lt;/ul></description></item></channel></rss>