<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Configure clustering on Grafana Labs</title><link>https://grafana.com/docs/alloy/v1.20/configure/clustering/</link><description>Recent content in Configure clustering on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/alloy/v1.20/configure/clustering/index.xml" rel="self" type="application/rss+xml"/><item><title>Configure Alloy for clustering</title><link>https://grafana.com/docs/alloy/v1.20/configure/clustering/configure-alloy/</link><pubDate>Fri, 25 Sep 2026 13:16:18 +0000</pubDate><guid>https://grafana.com/docs/alloy/v1.20/configure/clustering/configure-alloy/</guid><content><![CDATA[&lt;h1 id=&#34;configure-hahahugoshortcode1568s0hbhb-for-clustering&#34;&gt;Configure Alloy for clustering&lt;/h1&gt;
&lt;p&gt;You can enable clustering in Alloy with Helm chart settings or command-line flags.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Cluster mode in Alloy allows instances to discover each other and form a cluster.
To distribute workload, you must also [enable clustering in individual components][distribute-workload].&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;configure-clustering-with-a-helm-chart&#34;&gt;Configure clustering with a Helm chart&lt;/h2&gt;
&lt;p&gt;You can enable clustering when Alloy is installed on Kubernetes with a &lt;a href=&#34;../../../set-up/install/kubernetes/&#34;&gt;Helm chart&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h3&gt;
&lt;p&gt;For multi-replica clustering on Kubernetes, set &lt;code&gt;controller.type&lt;/code&gt; to &lt;code&gt;statefulset&lt;/code&gt;.
A StatefulSet gives each Pod a stable network identity for peer discovery.
It also lets you choose how many Alloy Pods to run instead of running one Pod on every node.
Use a DaemonSet only when your configuration must collect node-local data.&lt;/p&gt;
&lt;h3 id=&#34;steps&#34;&gt;Steps&lt;/h3&gt;
&lt;p&gt;To configure clustering:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Amend your existing &lt;code&gt;values.yaml&lt;/code&gt; file to add &lt;code&gt;clustering.enabled=true&lt;/code&gt; inside the &lt;code&gt;alloy&lt;/code&gt; block:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;YAML&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-yaml&#34;&gt;alloy:
  clustering:
    enabled: true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Upgrade your installation to use the new &lt;code&gt;values.yaml&lt;/code&gt; file:&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;Bash&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-bash&#34;&gt;helm upgrade --namespace &amp;lt;NAMESPACE&amp;gt; &amp;lt;RELEASE_NAME&amp;gt; grafana/alloy -f values.yaml&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Replace the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;NAMESPACE&amp;gt;&lt;/code&gt;&lt;/em&gt;: The Kubernetes namespace where you installed the Helm chart.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;RELEASE_NAME&amp;gt;&lt;/code&gt;&lt;/em&gt;: The name of the installation you chose when you installed the Helm chart.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use the Alloy &lt;a href=&#34;../../../troubleshoot/debug/#clustering-page&#34;&gt;UI&lt;/a&gt; to verify the cluster status:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Clustering&lt;/strong&gt; in the navigation bar.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Ensure that all expected nodes appear in the resulting table.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;configure-clustering-with-command-line-flags&#34;&gt;Configure clustering with command-line flags&lt;/h2&gt;
&lt;p&gt;If you run Alloy outside of Kubernetes or without the Helm chart, use command-line flags to enable clustering.&lt;/p&gt;
&lt;h3 id=&#34;required-flags&#34;&gt;Required flags&lt;/h3&gt;
&lt;p&gt;Pass &lt;code&gt;--cluster.enabled&lt;/code&gt; and one of the following peer-discovery flags to the &lt;a href=&#34;../../../reference/cli/run/#clustering&#34;&gt;&lt;code&gt;alloy run&lt;/code&gt;&lt;/a&gt; command:&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;Flag&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;--cluster.enabled&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Enables clustering mode.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;--cluster.join-addresses&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Comma-separated list of addresses of cluster nodes to join.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;--cluster.discover-peers&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Key-value tuples used to discover peers dynamically.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&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;Bash&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-bash&#34;&gt;alloy run config.alloy \
  --cluster.enabled \
  --cluster.join-addresses=alloy-1:7946,alloy-2:7946&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The first node that bootstraps a new cluster can omit peer discovery flags or connect to itself.&lt;/p&gt;
&lt;p&gt;Cluster peers communicate over HTTP/2 on the built-in HTTP server.
Each node must accept connections on &lt;code&gt;--server.http.listen-addr&lt;/code&gt; and on the address defined or inferred by &lt;code&gt;--cluster.advertise-address&lt;/code&gt;.
If &lt;code&gt;--cluster.advertise-address&lt;/code&gt; isn&amp;rsquo;t set, Alloy tries to infer an address from &lt;code&gt;--cluster.advertise-interfaces&lt;/code&gt;.
The default interfaces are &lt;code&gt;eth0&lt;/code&gt; and &lt;code&gt;en0&lt;/code&gt;.
On Windows, set &lt;code&gt;--cluster.advertise-interfaces&lt;/code&gt; to a valid network interface or set &lt;code&gt;--cluster.advertise-address&lt;/code&gt; explicitly.
Alloy fails to start if it can&amp;rsquo;t determine the advertised address.&lt;/p&gt;
&lt;h3 id=&#34;optional-flags&#34;&gt;Optional flags&lt;/h3&gt;
&lt;p&gt;You can customize clustering behavior with additional flags:&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;Flag&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;--cluster.advertise-address&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Address to advertise to other cluster nodes.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;--cluster.advertise-interfaces&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Network interfaces to use for advertisement.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;eth0,en0&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;--cluster.enable-tls&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Enables TLS for cluster communication.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;--cluster.max-join-peers&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Number of peers to join from the discovered set.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;5&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;--cluster.name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Cluster name that nodes must share to join the same cluster.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;--cluster.node-name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The name to use for this node.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;--cluster.rejoin-interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Interval to rejoin the cluster.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;60s&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;--cluster.tls-ca-path&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Path to the CA certificate file.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;--cluster.tls-cert-path&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Path to the certificate file.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;--cluster.tls-key-path&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Path to the key file.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;--cluster.tls-server-name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Server name to use for TLS communication.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;--cluster.wait-for-size&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Minimum cluster size before traffic processing.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;0&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;--cluster.wait-timeout&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Timeout for cluster size wait.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;0&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;To enable TLS for peer-to-peer communication, set &lt;code&gt;--cluster.enable-tls&lt;/code&gt; and configure the related &lt;code&gt;--cluster.tls-*&lt;/code&gt; flags for the CA certificate, certificate file, key file, and server name.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;--cluster.rejoin-interval&lt;/code&gt; flag controls how often each node rediscovers peers from &lt;code&gt;--cluster.join-addresses&lt;/code&gt; and &lt;code&gt;--cluster.discover-peers&lt;/code&gt; and tries to rejoin them.
This can help recover from split-brain conditions and support dynamic environments.
To discover peers only at startup, set &lt;code&gt;--cluster.rejoin-interval=&amp;quot;0s&amp;quot;&lt;/code&gt;.
After startup, nodes use gossip messages to converge on the cluster state.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;--cluster.max-join-peers&lt;/code&gt; flag limits how many discovered peers a node tries to connect to when joining or rejoining a cluster.
This is useful for large clusters where connecting to many peers can be expensive.
To disable the limit, set &lt;code&gt;--cluster.max-join-peers=0&lt;/code&gt;.
If &lt;code&gt;--cluster.max-join-peers&lt;/code&gt; is higher than the number of discovered peers, Alloy connects to all discovered peers.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;--cluster.name&lt;/code&gt; flag prevents clusters from accidentally merging.
Nodes only join peers that use the same cluster name.
If a node tries to join a cluster with the wrong &lt;code&gt;--cluster.name&lt;/code&gt;, it returns a &lt;code&gt;failed to join memberlist&lt;/code&gt; error.&lt;/p&gt;
&lt;p&gt;For &lt;code&gt;--cluster.join-addresses&lt;/code&gt; DNS prefix syntax and &lt;code&gt;--cluster.discover-peers&lt;/code&gt; tuple quoting rules, refer to the &lt;a href=&#34;../../../reference/cli/run/#clustering&#34;&gt;&lt;code&gt;alloy run&lt;/code&gt; reference&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For production deployments, set &lt;code&gt;--cluster.wait-for-size&lt;/code&gt; to your expected cluster size and &lt;code&gt;--cluster.wait-timeout&lt;/code&gt; to a reasonable duration.
This ensures all nodes join before processing begins, which reduces duplicate scrapes and out-of-order samples at remote write during startup.&lt;/p&gt;
&lt;p&gt;If you leave &lt;code&gt;--cluster.wait-for-size&lt;/code&gt; at the default &lt;code&gt;0&lt;/code&gt;, nodes can scrape before enough peers have joined, so two nodes may write the same series and trigger errors.
Refer to &lt;a href=&#34;../../../reference/components/prometheus/prometheus.remote_write/#out-of-order-errors&#34;&gt;Out of order errors&lt;/a&gt; for additional troubleshooting.&lt;/p&gt;
&lt;p&gt;The following example configures a 3-node cluster where each node waits up to 5 minutes for all cluster members to join before it starts processing traffic:&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;Bash&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-bash&#34;&gt;alloy run config.alloy \
   --cluster.enabled \
   --cluster.join-addresses=alloy-1:7946,alloy-2:7946,alloy-3:7946 \
   --cluster.wait-for-size=3 \
   --cluster.wait-timeout=5m&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Refer to the &lt;a href=&#34;../../../reference/cli/run/#clustering&#34;&gt;&lt;code&gt;alloy run&lt;/code&gt; reference&lt;/a&gt; for complete details on all clustering flags.&lt;/p&gt;
&lt;h2 id=&#34;verify-cluster-status&#34;&gt;Verify cluster status&lt;/h2&gt;
&lt;p&gt;After you enable clustering, verify that all nodes have joined the cluster:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open the Alloy UI on any cluster node.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Clustering&lt;/strong&gt; in the navigation bar.&lt;/li&gt;
&lt;li&gt;Verify that all expected nodes appear in the cluster members table.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;next-steps&#34;&gt;Next steps&lt;/h2&gt;
&lt;p&gt;After you enable clustering in Alloy, &lt;a href=&#34;../distribute-workload/&#34;&gt;configure components to distribute workload&lt;/a&gt;.&lt;/p&gt;
]]></content><description>&lt;h1 id="configure-hahahugoshortcode1568s0hbhb-for-clustering">Configure Alloy for clustering&lt;/h1>
&lt;p>You can enable clustering in Alloy with Helm chart settings or command-line flags.&lt;/p>
&lt;div class="admonition admonition-note">&lt;blockquote>&lt;p class="title text-uppercase">Note&lt;/p>&lt;p>Cluster mode in Alloy allows instances to discover each other and form a cluster.
To distribute workload, you must also [enable clustering in individual components][distribute-workload].&lt;/p></description></item><item><title>Distribute workload across cluster nodes</title><link>https://grafana.com/docs/alloy/v1.20/configure/clustering/distribute-workload/</link><pubDate>Fri, 25 Sep 2026 13:16:18 +0000</pubDate><guid>https://grafana.com/docs/alloy/v1.20/configure/clustering/distribute-workload/</guid><content><![CDATA[&lt;h1 id=&#34;distribute-workload-across-cluster-nodes&#34;&gt;Distribute workload across cluster nodes&lt;/h1&gt;
&lt;p&gt;After you &lt;a href=&#34;../configure-alloy/&#34;&gt;enable clustering in Alloy&lt;/a&gt;, you can configure individual components to distribute their workload across the cluster.&lt;/p&gt;
&lt;p&gt;Clustering with target auto-distribution allows a fleet of Alloy instances to dynamically distribute workload and provides high availability and horizontal scalability.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../configure-alloy/&#34;&gt;Configure clustering&lt;/a&gt; in your Alloy installation.&lt;/li&gt;
&lt;li&gt;Ensure that all clustered Alloy instances have the same configuration file.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;enable-clustering-in-components&#34;&gt;Enable clustering in components&lt;/h2&gt;
&lt;p&gt;To enable workload distribution, add a &lt;code&gt;clustering&lt;/code&gt; block with &lt;code&gt;enabled = true&lt;/code&gt; inside each component block that should participate:&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;component.type &amp;#34;example&amp;#34; {
  # ...component settings...

  clustering {
    enabled = true
  }
}&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;Components don&amp;rsquo;t automatically participate in clustering.
You must explicitly enable clustering in each component that should distribute workload.
If cluster mode is enabled but a component doesn&amp;rsquo;t have &lt;code&gt;clustering { enabled = true }&lt;/code&gt;, every node runs that component&amp;rsquo;s full workload, which causes duplicate scraping, log collection, or profiling.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;components-that-support-clustering&#34;&gt;Components that support clustering&lt;/h3&gt;
&lt;p&gt;The following components support the &lt;code&gt;clustering&lt;/code&gt; block:&lt;/p&gt;
&lt;p&gt;Prometheus metrics collection components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../../../reference/components/prometheus/prometheus.operator.podmonitors/#clustering&#34;&gt;&lt;code&gt;prometheus.operator.podmonitors&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../../../reference/components/prometheus/prometheus.operator.probes/#clustering&#34;&gt;&lt;code&gt;prometheus.operator.probes&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../../../reference/components/prometheus/prometheus.operator.scrapeconfigs/#clustering&#34;&gt;&lt;code&gt;prometheus.operator.scrapeconfigs&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../../../reference/components/prometheus/prometheus.operator.servicemonitors/#clustering&#34;&gt;&lt;code&gt;prometheus.operator.servicemonitors&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../../../reference/components/prometheus/prometheus.scrape/#clustering&#34;&gt;&lt;code&gt;prometheus.scrape&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Pyroscope profiling components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../../../reference/components/pyroscope/pyroscope.scrape/#clustering&#34;&gt;&lt;code&gt;pyroscope.scrape&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Loki log collection components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../../../reference/components/loki/loki.source.kubernetes/#clustering&#34;&gt;&lt;code&gt;loki.source.kubernetes&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../../../reference/components/loki/loki.source.kubernetes_events/#clustering&#34;&gt;&lt;code&gt;loki.source.kubernetes_events&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../../../reference/components/loki/loki.source.podlogs/#clustering&#34;&gt;&lt;code&gt;loki.source.podlogs&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Database observability components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../../../reference/components/database_observability/database_observability.mysql/#clustering&#34;&gt;&lt;code&gt;database_observability.mysql&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;example-distribute-prometheus-metrics-scrape-load&#34;&gt;Example: Distribute Prometheus metrics scrape load&lt;/h2&gt;
&lt;p&gt;This example shows how to configure &lt;code&gt;prometheus.scrape&lt;/code&gt; to distribute scrape targets across cluster nodes.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Add a &lt;code&gt;clustering&lt;/code&gt; block to your &lt;code&gt;prometheus.scrape&lt;/code&gt; component:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Alloy&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-alloy&#34;&gt;prometheus.scrape &amp;#34;default&amp;#34; {
  targets    = discovery.kubernetes.pods.targets
  forward_to = [prometheus.remote_write.default.receiver]

  clustering {
    enabled = true
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Restart or reload Alloy for it to use the new configuration.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Validate that auto-distribution works:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Use the Alloy &lt;a href=&#34;../../../troubleshoot/debug/#component-detail-page&#34;&gt;UI&lt;/a&gt; on each node, navigate to the details page for the &lt;code&gt;prometheus.scrape&lt;/code&gt; component.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Compare the &lt;strong&gt;Debug Info&lt;/strong&gt; sections between two different nodes to ensure that they don&amp;rsquo;t scrape the same sets of targets.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;example-distribute-log-collection&#34;&gt;Example: Distribute log collection&lt;/h2&gt;
&lt;p&gt;This example shows how to configure &lt;code&gt;loki.source.kubernetes&lt;/code&gt; to distribute log collection across cluster nodes.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Alloy&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-alloy&#34;&gt;loki.source.kubernetes &amp;#34;pods&amp;#34; {
  targets    = discovery.kubernetes.pods.targets
  forward_to = [loki.write.default.receiver]

  clustering {
    enabled = true
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;example-distribute-profiling-targets&#34;&gt;Example: Distribute profiling targets&lt;/h2&gt;
&lt;p&gt;This example shows how to configure &lt;code&gt;pyroscope.scrape&lt;/code&gt; to distribute profiling targets across cluster nodes.&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;pyroscope.scrape &amp;#34;default&amp;#34; {
  targets    = discovery.kubernetes.pods.targets
  forward_to = [pyroscope.write.default.receiver]

  clustering {
    enabled = true
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;how-workload-distribution-works&#34;&gt;How workload distribution works&lt;/h2&gt;
&lt;p&gt;When you enable clustering in a component:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;All cluster nodes use a consistent hashing algorithm to determine target ownership.&lt;/li&gt;
&lt;li&gt;Each node only processes the subset of targets it&amp;rsquo;s responsible for.&lt;/li&gt;
&lt;li&gt;When a node joins or leaves the cluster, targets are automatically redistributed.&lt;/li&gt;
&lt;li&gt;Approximately 1/N of targets are redistributed when cluster membership changes. This minimizes disruption.&lt;/li&gt;
&lt;/ol&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;Target labels must be consistent across all cluster nodes.
If target discovery adds node-specific labels, such as &lt;code&gt;constants.hostname&lt;/code&gt;, the hashing algorithm can&amp;rsquo;t consistently determine target ownership.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;For more information about clustering concepts, refer to &lt;a href=&#34;../../../get-started/clustering/&#34;&gt;Clustering&lt;/a&gt;.&lt;/p&gt;
]]></content><description>&lt;h1 id="distribute-workload-across-cluster-nodes">Distribute workload across cluster nodes&lt;/h1>
&lt;p>After you &lt;a href="../configure-alloy/">enable clustering in Alloy&lt;/a>, you can configure individual components to distribute their workload across the cluster.&lt;/p>
&lt;p>Clustering with target auto-distribution allows a fleet of Alloy instances to dynamically distribute workload and provides high availability and horizontal scalability.&lt;/p></description></item></channel></rss>