<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Expressions on Grafana Labs</title><link>https://grafana.com/docs/alloy/v1.15/get-started/expressions/</link><description>Recent content in Expressions on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/alloy/v1.15/get-started/expressions/index.xml" rel="self" type="application/rss+xml"/><item><title>Types and values</title><link>https://grafana.com/docs/alloy/v1.15/get-started/expressions/types_and_values/</link><pubDate>Mon, 30 Mar 2026 15:47:22 +0000</pubDate><guid>https://grafana.com/docs/alloy/v1.15/get-started/expressions/types_and_values/</guid><content><![CDATA[&lt;h1 id=&#34;types-and-values&#34;&gt;Types and values&lt;/h1&gt;
&lt;p&gt;You learned about the main types of expressions in the previous section. These are literals, component references, functions, and arithmetic operations.
Now you&amp;rsquo;ll learn about the &lt;em&gt;types and values&lt;/em&gt; that these expressions work with and how Alloy uses them to ensure your configurations work correctly.&lt;/p&gt;
&lt;p&gt;Understanding types helps you write expressions that work reliably and helps you understand why certain combinations of components and values are compatible while others aren&amp;rsquo;t.&lt;/p&gt;
&lt;h2 id=&#34;value-types&#34;&gt;Value types&lt;/h2&gt;
&lt;p&gt;The Alloy syntax supports the following value types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;number&lt;/code&gt;: Any numeric value, such as &lt;code&gt;3&lt;/code&gt; or &lt;code&gt;3.14&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;string&lt;/code&gt;: A sequence of Unicode characters representing text, such as &lt;code&gt;&amp;quot;Hello, world!&amp;quot;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;bool&lt;/code&gt;: A boolean value, either &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;array&lt;/code&gt;: A sequence of values, such as &lt;code&gt;[1, 2, 3]&lt;/code&gt;. Index array elements using whole numbers starting from zero.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;object&lt;/code&gt;: A group of values identified by named labels, such as &lt;code&gt;{ name = &amp;quot;John&amp;quot; }&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;function&lt;/code&gt;: A value representing a routine that runs with arguments to compute another value, such as &lt;code&gt;sys.env(&amp;quot;HOME&amp;quot;)&lt;/code&gt;.
Functions take zero or more arguments as input and always return a single value as output.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;null&lt;/code&gt;: A type that represents no value.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;names-and-naming-conventions&#34;&gt;Names and naming conventions&lt;/h2&gt;
&lt;p&gt;In addition to the preceding types, the &lt;a href=&#34;../../../reference/components/&#34;&gt;component reference&lt;/a&gt; documentation uses the following conventions for referring to types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;any&lt;/code&gt;: A value of any type.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;map(T)&lt;/code&gt;: An &lt;code&gt;object&lt;/code&gt; where all values are of type &lt;code&gt;T&lt;/code&gt;.
For example, &lt;code&gt;map(string)&lt;/code&gt; is an object where all values are strings.
The key type of an object is always a string or an identifier converted into a string.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;list(T)&lt;/code&gt;: An &lt;code&gt;array&lt;/code&gt; where all values are of type &lt;code&gt;T&lt;/code&gt;.
For example, &lt;code&gt;list(string)&lt;/code&gt; is an array where all values are strings.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;duration&lt;/code&gt;: A &lt;code&gt;string&lt;/code&gt; that denotes a duration of time, such as &lt;code&gt;&amp;quot;100ms&amp;quot;&lt;/code&gt;, &lt;code&gt;&amp;quot;1h30m&amp;quot;&lt;/code&gt;, or &lt;code&gt;&amp;quot;10s&amp;quot;&lt;/code&gt;.
Valid units include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;h&lt;/code&gt; for hours.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;m&lt;/code&gt; for minutes.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;s&lt;/code&gt; for seconds.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ms&lt;/code&gt; for milliseconds.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ns&lt;/code&gt; for nanoseconds.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can combine values of descending units to add their values together.
For example, &lt;code&gt;&amp;quot;1h30m&amp;quot;&lt;/code&gt; is equivalent to &lt;code&gt;&amp;quot;90m&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;numbers&#34;&gt;Numbers&lt;/h2&gt;
&lt;p&gt;The Alloy syntax treats integers, unsigned integers, and floating-point values as a single &lt;code&gt;number&lt;/code&gt; type.
This simplifies writing and reading Alloy configuration files.&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;text&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-text&#34;&gt;3    == 3.00     // true
5.0  == (10 / 2) // true
1e&amp;#43;2 == 100      // true
2e-3 == 0.002    // true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;strings&#34;&gt;Strings&lt;/h2&gt;
&lt;p&gt;Strings are sequences of Unicode characters enclosed in double quotes &lt;code&gt;&amp;quot;&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;&amp;#34;Hello, world!&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;A &lt;code&gt;\&lt;/code&gt; in a string starts an escape sequence to represent a special character.
The following table lists the supported escape sequences.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Sequence&lt;/th&gt;
              &lt;th&gt;Replacement&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;\\&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The &lt;code&gt;\&lt;/code&gt; character &lt;code&gt;U&#43;005C&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;\a&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The alert or bell character &lt;code&gt;U&#43;0007&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;\b&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The backspace character &lt;code&gt;U&#43;0008&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;\f&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The form feed character &lt;code&gt;U&#43;000C&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;\n&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The newline character &lt;code&gt;U&#43;000A&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;\r&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The carriage return character &lt;code&gt;U&#43;000D&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;\t&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The horizontal tab character &lt;code&gt;U&#43;0009&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;\v&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The vertical tab character &lt;code&gt;U&#43;000B&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;\&#39;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The &lt;code&gt;&#39;&lt;/code&gt; character &lt;code&gt;U&#43;0027&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;\&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The &lt;code&gt;&amp;quot;&lt;/code&gt; character &lt;code&gt;U&#43;0022&lt;/code&gt;, which prevents terminating the string&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;\NNN&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;A literal byte (NNN is three octal digits)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;\xNN&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;A literal byte (NN is two hexadecimal digits)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;\uNNNN&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;A Unicode character from the basic multilingual plane (NNNN is four hexadecimal digits)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;\UNNNNNNNN&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;A Unicode character from supplementary planes (NNNNNNNN is eight hexadecimal digits)&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;raw-strings&#34;&gt;Raw strings&lt;/h2&gt;
&lt;p&gt;Raw strings are sequences of Unicode characters enclosed in backticks &lt;code&gt;``&lt;/code&gt;.
Raw strings don&amp;rsquo;t support escape sequences.&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;`Hello, &amp;#34;world&amp;#34;!`&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Within backticks, any character can appear except a backtick.
Include a backtick by concatenating a double-quoted string containing a backtick using &lt;code&gt;&#43;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Alloy interprets a multiline raw string exactly as written.&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;`Hello,
&amp;#34;world&amp;#34;!`&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Alloy interprets the preceding multiline raw string as a string with the following value.&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;string&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-string&#34;&gt;Hello,
&amp;#34;world&amp;#34;!&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;boolean-values&#34;&gt;Boolean values&lt;/h2&gt;
&lt;p&gt;The symbols &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt; represent boolean values.&lt;/p&gt;
&lt;h2 id=&#34;arrays&#34;&gt;Arrays&lt;/h2&gt;
&lt;p&gt;Construct arrays using a sequence of comma-separated values enclosed in square brackets &lt;code&gt;[]&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;[0, 1, 2, 3]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can place values on separate lines for readability.
Include a comma after the final value if the closing bracket &lt;code&gt;]&lt;/code&gt; is on a different line.&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;[
  0,
  1,
  2,
]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;objects&#34;&gt;Objects&lt;/h2&gt;
&lt;p&gt;Construct objects using a sequence of comma-separated key-value pairs enclosed in curly braces &lt;code&gt;{}&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;{
  first_name = &amp;#34;John&amp;#34;,
  last_name  = &amp;#34;Doe&amp;#34;,
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Include a comma after the final key-value pair if the closing curly brace &lt;code&gt;}&lt;/code&gt; is on a different line.&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;{ name = &amp;#34;John&amp;#34; }&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Wrap keys in double quotes if they aren&amp;rsquo;t &lt;a href=&#34;../../syntax#identifiers&#34;&gt;valid identifiers&lt;/a&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;{
  &amp;#34;app.kubernetes.io/name&amp;#34;     = &amp;#34;mysql&amp;#34;,
  &amp;#34;app.kubernetes.io/instance&amp;#34; = &amp;#34;mysql-abcxyz&amp;#34;,
  namespace                    = &amp;#34;default&amp;#34;,
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&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;Don&amp;rsquo;t confuse objects with blocks.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;An &lt;em&gt;object&lt;/em&gt; is a value assigned to an &lt;a href=&#34;../../syntax/#attributes&#34;&gt;Attribute&lt;/a&gt;. Use commas between key-value pairs on separate lines.&lt;/li&gt;
&lt;li&gt;A &lt;a href=&#34;../../syntax/#blocks&#34;&gt;Block&lt;/a&gt; is a named structural element composed of multiple attributes. Don&amp;rsquo;t use commas between attributes.&lt;/li&gt;
&lt;/ul&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;functions&#34;&gt;Functions&lt;/h2&gt;
&lt;p&gt;You can&amp;rsquo;t construct function values.
You can call functions from the standard library or export them from a component.&lt;/p&gt;
&lt;h2 id=&#34;null&#34;&gt;Null&lt;/h2&gt;
&lt;p&gt;The symbol &lt;code&gt;null&lt;/code&gt; represents the null value.&lt;/p&gt;
&lt;h2 id=&#34;special-types&#34;&gt;Special types&lt;/h2&gt;
&lt;h3 id=&#34;secrets&#34;&gt;Secrets&lt;/h3&gt;
&lt;p&gt;A &lt;code&gt;secret&lt;/code&gt; is a special type of string that&amp;rsquo;s never displayed to the user.
You can assign &lt;code&gt;string&lt;/code&gt; values to an attribute expecting a &lt;code&gt;secret&lt;/code&gt;, but not the inverse.
You can use &lt;a href=&#34;../../../reference/stdlib/convert/&#34;&gt;&lt;code&gt;convert.nonsensitive&lt;/code&gt;&lt;/a&gt; to convert a secret to a string.
You can&amp;rsquo;t assign a secret to an attribute expecting a string.&lt;/p&gt;
&lt;h3 id=&#34;capsules&#34;&gt;Capsules&lt;/h3&gt;
&lt;p&gt;A &lt;code&gt;capsule&lt;/code&gt; is a special type that represents a category of &lt;em&gt;internal&lt;/em&gt; types used by Alloy.
Each capsule type has a unique name and appears as &lt;code&gt;capsule(&amp;quot;&amp;lt;SOME_INTERNAL_NAME&amp;gt;&amp;quot;)&lt;/code&gt;.
You can&amp;rsquo;t construct capsule values.
Use capsules in expressions like any other type.
Capsules aren&amp;rsquo;t inter-compatible.
An attribute expecting a capsule can only accept a capsule of the same internal type.
If an attribute expects a &lt;code&gt;capsule(&amp;quot;prometheus.Receiver&amp;quot;)&lt;/code&gt;, you can only assign a &lt;code&gt;capsule(&amp;quot;prometheus.Receiver&amp;quot;)&lt;/code&gt; type.
Components that use or export capsules document the specific capsule type they expect.&lt;/p&gt;
&lt;p&gt;In the following example, the &lt;code&gt;prometheus.remote_write&lt;/code&gt; component exports a &lt;code&gt;receiver&lt;/code&gt;, which is a &lt;code&gt;capsule(&amp;quot;prometheus.Receiver&amp;quot;)&lt;/code&gt; type.
You can use this capsule in the &lt;code&gt;forward_to&lt;/code&gt; attribute of &lt;code&gt;prometheus.scrape&lt;/code&gt;, which expects an array of &lt;code&gt;capsule(&amp;quot;prometheus.Receiver&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;prometheus.remote_write &amp;#34;default&amp;#34; {
  endpoint {
    url = &amp;#34;http://localhost:9090/api/v1/write&amp;#34;
  }
}

prometheus.scrape &amp;#34;default&amp;#34; {
  targets    = [/* ... */]
  forward_to = [prometheus.remote_write.default.receiver]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;next-steps&#34;&gt;Next steps&lt;/h2&gt;
&lt;p&gt;Now that you understand types and values, learn how to use them in expressions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../referencing_exports/&#34;&gt;Component exports&lt;/a&gt; - Reference data from other components and understand how types ensure compatibility&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../operators/&#34;&gt;Operators&lt;/a&gt; - Learn how operators work with different value types and handle type compatibility&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For advanced expression features:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../function_calls/&#34;&gt;Function calls&lt;/a&gt; - Transform data using standard library functions that work with these types&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="types-and-values">Types and values&lt;/h1>
&lt;p>You learned about the main types of expressions in the previous section. These are literals, component references, functions, and arithmetic operations.
Now you&amp;rsquo;ll learn about the &lt;em>types and values&lt;/em> that these expressions work with and how Alloy uses them to ensure your configurations work correctly.&lt;/p></description></item><item><title>Component exports</title><link>https://grafana.com/docs/alloy/v1.15/get-started/expressions/referencing_exports/</link><pubDate>Mon, 30 Mar 2026 15:47:22 +0000</pubDate><guid>https://grafana.com/docs/alloy/v1.15/get-started/expressions/referencing_exports/</guid><content><![CDATA[&lt;h1 id=&#34;component-exports&#34;&gt;Component exports&lt;/h1&gt;
&lt;p&gt;You learned about expressions and how the component controller evaluates them in the previous topics.
Now you&amp;rsquo;ll learn how to use component references. These are expressions that connect components by referencing their exports.&lt;/p&gt;
&lt;p&gt;Component references create the connections that make Alloy pipelines work.
When you reference one component&amp;rsquo;s exports in another component&amp;rsquo;s arguments, you establish a dependency relationship that the component controller manages automatically.&lt;/p&gt;
&lt;p&gt;References can only appear in component arguments or configuration block fields.
Components can&amp;rsquo;t reference themselves.&lt;/p&gt;
&lt;h2 id=&#34;use-references&#34;&gt;Use references&lt;/h2&gt;
&lt;p&gt;You create references by combining the component&amp;rsquo;s name, label, and named export with dots.&lt;/p&gt;
&lt;p&gt;For example, you can refer to the contents of a file exported by the &lt;code&gt;local.file&lt;/code&gt; component labeled &lt;code&gt;target&lt;/code&gt; as &lt;code&gt;local.file.target.content&lt;/code&gt;.
Similarly, a &lt;code&gt;prometheus.remote_write&lt;/code&gt; component instance labeled &lt;code&gt;onprem&lt;/code&gt; exposes its receiver for metrics as &lt;code&gt;prometheus.remote_write.onprem.receiver&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The following example demonstrates references:&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;target&amp;#34; {
  filename = &amp;#34;/etc/alloy/target&amp;#34;
}

prometheus.scrape &amp;#34;default&amp;#34; {
  targets    = [{ &amp;#34;__address__&amp;#34; = local.file.target.content }]
  forward_to = [prometheus.remote_write.onprem.receiver]
}

prometheus.remote_write &amp;#34;onprem&amp;#34; {
  endpoint {
    url = &amp;#34;http://prometheus:9009/api/prom/push&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In the preceding example, you created a pipeline by writing a few Alloy expressions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The &lt;code&gt;local.file&lt;/code&gt; component reads a file and exports its &lt;code&gt;content&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;prometheus.scrape&lt;/code&gt; component references that content in its &lt;code&gt;targets&lt;/code&gt; field.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;prometheus.scrape&lt;/code&gt; component exports a &lt;code&gt;receiver&lt;/code&gt; for scraped metrics.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;prometheus.remote_write&lt;/code&gt; component receives and forwards those metrics to a remote endpoint.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;When the component controller evaluates these components, it:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Evaluates the &lt;code&gt;local.file&lt;/code&gt; component first because it has no dependencies.&lt;/li&gt;
&lt;li&gt;Evaluates the &lt;code&gt;prometheus.scrape&lt;/code&gt; component next, using the file content for its targets.&lt;/li&gt;
&lt;li&gt;Evaluates the &lt;code&gt;prometheus.remote_write&lt;/code&gt; component last, connecting it to receive metrics.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Each time the file content changes, the component controller automatically reevaluates the &lt;code&gt;prometheus.scrape&lt;/code&gt; component with the new target value.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p &#34;
    style=&#34;max-width: 1280px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/media/docs/alloy/diagram-referencing-exports.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/media/docs/alloy/diagram-referencing-exports.png&#34;data-srcset=&#34;/media/docs/alloy/diagram-referencing-exports.png?w=320 320w, /media/docs/alloy/diagram-referencing-exports.png?w=550 550w, /media/docs/alloy/diagram-referencing-exports.png?w=750 750w, /media/docs/alloy/diagram-referencing-exports.png?w=900 900w, /media/docs/alloy/diagram-referencing-exports.png?w=1040 1040w, /media/docs/alloy/diagram-referencing-exports.png?w=1240 1240w, /media/docs/alloy/diagram-referencing-exports.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;Example of a pipeline&#34;width=&#34;1280&#34;height=&#34;160&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/media/docs/alloy/diagram-referencing-exports.png&#34;
            alt=&#34;Example of a pipeline&#34;width=&#34;1280&#34;height=&#34;160&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;The component controller evaluates component references during the component evaluation process.
When you reference another component&amp;rsquo;s export, the component controller ensures that:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The referenced component is evaluated first.&lt;/li&gt;
&lt;li&gt;The reference resolves to the correct export value.&lt;/li&gt;
&lt;li&gt;The resolved value&amp;rsquo;s type is compatible with the target field.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;After a reference resolves, the value must match the &lt;a href=&#34;../types_and_values/&#34;&gt;type&lt;/a&gt; of the attribute it&amp;rsquo;s assigned to.
While you can only configure attributes using the basic Alloy types, component exports can use special internal Alloy types, such as Secrets or Capsules, which provide additional functionality.&lt;/p&gt;
&lt;h2 id=&#34;next-steps&#34;&gt;Next steps&lt;/h2&gt;
&lt;p&gt;Now that you understand component references, continue learning about expressions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../types_and_values/&#34;&gt;Types and values&lt;/a&gt; - Learn how the type system ensures references work correctly with different data types&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../function_calls/&#34;&gt;Function calls&lt;/a&gt; - Use built-in functions to transform values from referenced exports&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../operators/&#34;&gt;Operators&lt;/a&gt; - Combine referenced values with other expressions using mathematical and logical operators&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="component-exports">Component exports&lt;/h1>
&lt;p>You learned about expressions and how the component controller evaluates them in the previous topics.
Now you&amp;rsquo;ll learn how to use component references. These are expressions that connect components by referencing their exports.&lt;/p></description></item><item><title>Operators</title><link>https://grafana.com/docs/alloy/v1.15/get-started/expressions/operators/</link><pubDate>Mon, 30 Mar 2026 15:47:22 +0000</pubDate><guid>https://grafana.com/docs/alloy/v1.15/get-started/expressions/operators/</guid><content><![CDATA[&lt;h1 id=&#34;operators&#34;&gt;Operators&lt;/h1&gt;
&lt;p&gt;You learned how to reference component exports to connect your pipelines in the previous topic.
Now you&amp;rsquo;ll learn how to use operators to manipulate, transform, and combine values in your expressions.&lt;/p&gt;
&lt;p&gt;Operators are essential for creating dynamic configurations that can:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Calculate values&lt;/strong&gt;: Perform arithmetic operations on component exports and literals.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Compare data&lt;/strong&gt;: Make decisions based on component states or configuration values.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Combine strings&lt;/strong&gt;: Build dynamic identifiers, paths, or configuration strings.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Access nested data&lt;/strong&gt;: Extract values from complex objects and arrays.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The component controller evaluates all operators following the standard &lt;a href=&#34;https://en.wikipedia.org/wiki/Order_of_operations&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;PEMDAS&lt;/a&gt; order of mathematical operations.&lt;/p&gt;
&lt;h2 id=&#34;arithmetic-operators&#34;&gt;Arithmetic operators&lt;/h2&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Operator&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;&#43;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Adds two numbers.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;-&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Subtracts two numbers.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;*&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Multiplies two numbers.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;/&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Divides two numbers.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;%&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Computes the remainder after dividing two numbers.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;^&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Raises a number to the specified power.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;string-operators&#34;&gt;String operators&lt;/h2&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Operator&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;&#43;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Concatenate two strings or two secrets, or a string and a secret.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;String concatenation is particularly useful for building dynamic values from component exports:&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;app&amp;#34; {
  targets = [{ &amp;#34;__address__&amp;#34; = local.file.host.content &amp;#43; &amp;#34;:&amp;#34; &amp;#43; local.file.port.content }]
  job_name = &amp;#34;app-&amp;#34; &amp;#43; sys.env(&amp;#34;ENVIRONMENT&amp;#34;)
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;comparison-operators&#34;&gt;Comparison operators&lt;/h2&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Operator&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;==&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns &lt;code&gt;true&lt;/code&gt; when two values are equal.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;!=&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns &lt;code&gt;true&lt;/code&gt; when two values aren&amp;rsquo;t equal.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;&amp;lt;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns &lt;code&gt;true&lt;/code&gt; when the left value is less than the right value.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;&amp;lt;=&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns &lt;code&gt;true&lt;/code&gt; when the left value is less than or equal to the right value.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns &lt;code&gt;true&lt;/code&gt; when the left value is greater than the right value.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;&amp;gt;=&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns &lt;code&gt;true&lt;/code&gt; when the left value is greater than or equal to the right value.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;You can use the equality operators &lt;code&gt;==&lt;/code&gt; and &lt;code&gt;!=&lt;/code&gt; with any operands.&lt;/p&gt;
&lt;p&gt;The operands in ordering operators &lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;&amp;lt;=&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;gt;=&lt;/code&gt; must be &lt;em&gt;orderable&lt;/em&gt; and of the same type.
The results of these comparisons are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Boolean values are equal if both are either &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Numerical (integer and floating-point) values follow the usual ordering.&lt;/li&gt;
&lt;li&gt;String values follow lexical ordering, byte-wise.&lt;/li&gt;
&lt;li&gt;Objects are equal if all their fields are equal.&lt;/li&gt;
&lt;li&gt;Arrays are equal if their corresponding elements are equal.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Comparison operators are commonly used for conditional configuration:&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;// Check if environment matches
remote_write_enabled = sys.env(&amp;#34;ENVIRONMENT&amp;#34;) == &amp;#34;production&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;logical-operators&#34;&gt;Logical operators&lt;/h2&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Operator&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns &lt;code&gt;true&lt;/code&gt; when both the left &lt;em&gt;and&lt;/em&gt; right values are &lt;code&gt;true&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;||&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Returns &lt;code&gt;true&lt;/code&gt; when either the left &lt;em&gt;or&lt;/em&gt; right value is &lt;code&gt;true&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;!&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Negates a boolean value.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Logical operators work with boolean values and return a boolean result.&lt;/p&gt;
&lt;h2 id=&#34;assignment-operator&#34;&gt;Assignment operator&lt;/h2&gt;
&lt;p&gt;The Alloy configuration syntax uses &lt;code&gt;=&lt;/code&gt; as the assignment operator.&lt;/p&gt;
&lt;p&gt;An assignment statement can only assign a single value.
Each value must be &lt;em&gt;assignable&lt;/em&gt; to the attribute or object key:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;You can assign &lt;code&gt;null&lt;/code&gt; to any attribute.&lt;/li&gt;
&lt;li&gt;You can assign numerical, string, boolean, array, function, capsule, and object types to attributes of the corresponding type.&lt;/li&gt;
&lt;li&gt;You can assign numbers to string attributes with an implicit conversion.&lt;/li&gt;
&lt;li&gt;You can assign strings to numerical attributes if they represent a number.&lt;/li&gt;
&lt;li&gt;You can&amp;rsquo;t assign blocks.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The component controller performs type checking during evaluation to ensure assignments are valid before configuring components.&lt;/p&gt;
&lt;h2 id=&#34;brackets&#34;&gt;Brackets&lt;/h2&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Brackets&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;{ }&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Define blocks and objects.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;( )&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Group and prioritize expressions.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;[ ]&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Define arrays.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;For example, the following code uses curly braces and square brackets to define an object and an array.&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;obj = { app = &amp;#34;alloy&amp;#34;, namespace = &amp;#34;dev&amp;#34; }
arr = [1, true, 7 * (1&amp;#43;1), 3]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;access-operators&#34;&gt;Access operators&lt;/h2&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Operator&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;[ ]&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Access a member of an array or object.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;.&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Access a named member of an object or an exported field of a component.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;You can use the Alloy access operators to retrieve nested values.
Use square brackets to access zero-indexed array elements or object fields by enclosing the field name in double quotes.
Use the dot operator to access object fields without double quotes or component exports.&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;// Access array elements and object fields
obj[&amp;#34;app&amp;#34;]
arr[1]

// Access object fields and component exports
obj.app
local.file.token.content
discovery.kubernetes.endpoints.targets[0][&amp;#34;__address__&amp;#34;]

// Build complex expressions with nested access
prometheus.scrape &amp;#34;dynamic&amp;#34; {
  targets = discovery.kubernetes.endpoints.targets
  job_name = discovery.kubernetes.endpoints.targets[0][&amp;#34;job&amp;#34;] &amp;#43; &amp;#34;-scraper&amp;#34;
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If you use the &lt;code&gt;[ ]&lt;/code&gt; operator to access a non-existent object member, the result is &lt;code&gt;null&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you use the &lt;code&gt;.&lt;/code&gt; operator to access a non-existent named member of an object, an error occurs.&lt;/p&gt;
&lt;h2 id=&#34;next-steps&#34;&gt;Next steps&lt;/h2&gt;
&lt;p&gt;Now that you understand operators, continue learning about expressions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../types_and_values/&#34;&gt;Types and values&lt;/a&gt; - Learn how the type system works with operators to ensure expressions evaluate correctly&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../function_calls/&#34;&gt;Function calls&lt;/a&gt; - Use operators inside function calls and with function return values&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For building complete configurations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../referencing_exports/&#34;&gt;Component exports&lt;/a&gt; - Combine operators with component references to create dynamic pipelines&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="operators">Operators&lt;/h1>
&lt;p>You learned how to reference component exports to connect your pipelines in the previous topic.
Now you&amp;rsquo;ll learn how to use operators to manipulate, transform, and combine values in your expressions.&lt;/p></description></item><item><title>Function calls</title><link>https://grafana.com/docs/alloy/v1.15/get-started/expressions/function_calls/</link><pubDate>Mon, 30 Mar 2026 15:47:22 +0000</pubDate><guid>https://grafana.com/docs/alloy/v1.15/get-started/expressions/function_calls/</guid><content><![CDATA[&lt;h1 id=&#34;function-calls&#34;&gt;Function calls&lt;/h1&gt;
&lt;p&gt;You learned how to use operators to manipulate and combine values in your expressions in the previous topic.
Now you&amp;rsquo;ll learn how to use function calls to transform data, interact with the system, and create more sophisticated dynamic configurations.&lt;/p&gt;
&lt;p&gt;Functions are essential building blocks that extend what you can accomplish with expressions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Transform data&lt;/strong&gt;: Parse JSON, decode Base64, format strings, and convert between data types.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Access system information&lt;/strong&gt;: Read environment variables, paths, and system properties.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Process collections&lt;/strong&gt;: Combine arrays, group data, and extract specific elements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Enhance component logic&lt;/strong&gt;: Use functions within component arguments alongside operators and references.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The component controller evaluates function calls as part of expression evaluation, ensuring that function results integrate seamlessly with operators and component references.&lt;/p&gt;
&lt;h2 id=&#34;how-functions-work&#34;&gt;How functions work&lt;/h2&gt;
&lt;p&gt;Functions take zero or more arguments as input and always return a single value as output.
The component controller evaluates function calls during expression evaluation, following these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Evaluate arguments&lt;/strong&gt;: All function arguments are evaluated first, from left to right.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Type checking&lt;/strong&gt;: The function validates that arguments match expected types.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Execute function&lt;/strong&gt;: The function performs its operation and returns a result.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Integration&lt;/strong&gt;: The result becomes available for use with operators or assignment to component attributes.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Alloy provides functions through two sources:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Standard library functions&lt;/strong&gt;: Built-in functions available in any configuration.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Component exports&lt;/strong&gt;: Functions exported by components in your configuration.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can&amp;rsquo;t create your own functions in Alloy configuration files.&lt;/p&gt;
&lt;p&gt;If a function fails during evaluation, Alloy stops processing the expression and reports an error.
This fail-fast behavior prevents invalid data from propagating through your configuration and helps you identify issues quickly.&lt;/p&gt;
&lt;h2 id=&#34;standard-library-functions&#34;&gt;Standard library functions&lt;/h2&gt;
&lt;p&gt;The Alloy configuration syntax includes a &lt;a href=&#34;../../../reference/stdlib/&#34;&gt;standard library&lt;/a&gt; of functions organized into namespaces.
These functions fall into several categories:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;System functions&lt;/strong&gt;: Interact with the host system, like reading environment variables.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Encoding functions&lt;/strong&gt;: Transform data between different formats like JSON and YAML.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;String functions&lt;/strong&gt;: Manipulate and format text values.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Array functions&lt;/strong&gt;: Work with lists of values and perform collection operations.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Convert functions&lt;/strong&gt;: Transform data between different types.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;common-examples&#34;&gt;Common examples&lt;/h3&gt;
&lt;p&gt;The following examples show frequently used standard library functions combined with component references and operators:&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;// System functions - get environment variables
log_level = sys.env(&amp;#34;LOG_LEVEL&amp;#34;)
data_dir = sys.env(&amp;#34;DATA_PATH&amp;#34;) &amp;#43; &amp;#34;/metrics&amp;#34;

// Encoding functions - parse configuration data
config_data = encoding.from_json(local.file.config.content)
metrics_config = encoding.from_yaml(local.file.metrics.content)

// Extract and combine values
service_name = config_data[&amp;#34;service&amp;#34;][&amp;#34;name&amp;#34;]
full_address = config_data[&amp;#34;host&amp;#34;] &amp;#43; &amp;#34;:&amp;#34; &amp;#43; string.format(&amp;#34;%d&amp;#34;, config_data[&amp;#34;port&amp;#34;])

// String functions - format dynamic values
job_name = string.format(&amp;#34;%s-%s&amp;#34;, service_name, sys.env(&amp;#34;ENVIRONMENT&amp;#34;))
log_file = string.join([&amp;#34;/var/log&amp;#34;, service_name, &amp;#34;app.log&amp;#34;], &amp;#34;/&amp;#34;)

// Array functions - combine target lists
all_targets = array.concat(
  discovery.kubernetes.services.targets,
  discovery.file.local.targets,
  [{ &amp;#34;__address__&amp;#34; = &amp;#34;localhost:9090&amp;#34; }]
)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;component-export-functions&#34;&gt;Component export functions&lt;/h2&gt;
&lt;p&gt;Components can export functions that other components can call.
This creates reusable logic and enables sharing computed values across your configuration.&lt;/p&gt;
&lt;p&gt;Component-exported functions work the same way as standard library functions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Discovery and referencing&lt;/strong&gt;: Use component references to access exported functions.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Function calls&lt;/strong&gt;: Call the functions with appropriate arguments.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Result integration&lt;/strong&gt;: Use function results in expressions with operators and other components.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For example, a custom component might export functions that:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Validate data&lt;/strong&gt;: Check if configuration values meet specific criteria.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Transform metrics&lt;/strong&gt;: Convert metric formats or apply mathematical operations.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Generate dynamic values&lt;/strong&gt;: Create timestamps, UUIDs, or computed identifiers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Process collections&lt;/strong&gt;: Filter, sort, or group data for downstream components.&lt;/li&gt;
&lt;/ol&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;// Example: Using a function exported by a custom component
processed_targets = data_processor.custom.transform_targets(
  discovery.kubernetes.services.targets,
  { &amp;#34;environment&amp;#34; = sys.env(&amp;#34;ENV&amp;#34;), &amp;#34;region&amp;#34; = &amp;#34;us-west-2&amp;#34; }
)

// Combine function results with operators and references
final_config = {
  &amp;#34;targets&amp;#34; = processed_targets,
  &amp;#34;labels&amp;#34; = custom_labeler.instance.generate_labels(service_name) &amp;#43; base_labels,
  &amp;#34;enabled&amp;#34; = validator.config.is_valid(processed_targets) &amp;amp;&amp;amp; sys.env(&amp;#34;MONITORING_ENABLED&amp;#34;) == &amp;#34;true&amp;#34;
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;next-steps&#34;&gt;Next steps&lt;/h2&gt;
&lt;p&gt;Now that you understand function calls, continue learning about expressions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../types_and_values/&#34;&gt;Types and values&lt;/a&gt; - Learn how the type system ensures function arguments and return values work correctly&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For building complete configurations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../referencing_exports/&#34;&gt;Component exports&lt;/a&gt; - Use function calls with component references to create sophisticated pipelines&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../operators/&#34;&gt;Operators&lt;/a&gt; - Combine function results with operators for complex expressions&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For detailed function reference:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../../../reference/stdlib/&#34;&gt;Standard library reference&lt;/a&gt; - Complete documentation of all available functions and their usage&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="function-calls">Function calls&lt;/h1>
&lt;p>You learned how to use operators to manipulate and combine values in your expressions in the previous topic.
Now you&amp;rsquo;ll learn how to use function calls to transform data, interact with the system, and create more sophisticated dynamic configurations.&lt;/p></description></item></channel></rss>