<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>The Grafana Agent command-line interface on Grafana Labs</title><link>https://grafana.com/docs/agent/v0.43/flow/reference/cli/</link><description>Recent content in The Grafana Agent command-line interface on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/agent/v0.43/flow/reference/cli/index.xml" rel="self" type="application/rss+xml"/><item><title>The convert command</title><link>https://grafana.com/docs/agent/v0.43/flow/reference/cli/convert/</link><pubDate>Mon, 24 Feb 2025 10:20:37 +0100</pubDate><guid>https://grafana.com/docs/agent/v0.43/flow/reference/cli/convert/</guid><content><![CDATA[&lt;h1 id=&#34;the-convert-command&#34;&gt;The convert command&lt;/h1&gt;
&lt;p&gt;The &lt;code&gt;convert&lt;/code&gt; command converts a supported configuration format to Grafana Agent Flow River format.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-caution&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Caution&lt;/p&gt;&lt;p&gt;This command has no backward compatibility guarantees and may change or be removed between releases.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;usage&#34;&gt;Usage&lt;/h2&gt;
&lt;p&gt;Usage:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;AGENT_MODE=flow grafana-agent convert [&amp;lt;FLAG&amp;gt; ...] &amp;lt;FILE_NAME&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;grafana-agent-flow convert [&amp;lt;FLAG&amp;gt; ...] &amp;lt;FILE_NAME&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Replace the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;FLAG&amp;gt;&lt;/code&gt;&lt;/em&gt;: One or more flags that define the input and output of the command.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;FILE_NAME&amp;gt;&lt;/code&gt;&lt;/em&gt;: The Grafana Agent configuration file.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If the &lt;code&gt;FILE_NAME&lt;/code&gt; argument isn&amp;rsquo;t provided or if the &lt;code&gt;FILE_NAME&lt;/code&gt; argument is
equal to &lt;code&gt;-&lt;/code&gt;, &lt;code&gt;convert&lt;/code&gt; converts the contents of standard input. Otherwise,
&lt;code&gt;convert&lt;/code&gt; reads and converts the file from disk specified by the argument.&lt;/p&gt;
&lt;p&gt;There are several different flags available for the &lt;code&gt;convert&lt;/code&gt; command. You can use the &lt;code&gt;--output&lt;/code&gt; flag to write the contents of the converted configuration to a specified path. You can use the &lt;code&gt;--report&lt;/code&gt; flag to generate a diagnostic report. The &lt;code&gt;--bypass-errors&lt;/code&gt; flag allows you to bypass any &lt;a href=&#34;#errors&#34;&gt;errors&lt;/a&gt; generated during the file conversion.&lt;/p&gt;
&lt;p&gt;The command fails if the source configuration has syntactically incorrect
configuration or can&amp;rsquo;t be converted to Grafana Agent Flow River format.&lt;/p&gt;
&lt;p&gt;The following flags are supported:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;--output&lt;/code&gt;, &lt;code&gt;-o&lt;/code&gt;: The filepath and filename where the output is written.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;--report&lt;/code&gt;, &lt;code&gt;-r&lt;/code&gt;: The filepath and filename where the report is written.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;--source-format&lt;/code&gt;, &lt;code&gt;-f&lt;/code&gt;: Required. The format of the source file. Supported formats: &lt;a href=&#34;#opentelemetry-collector&#34;&gt;otelcol&lt;/a&gt;, &lt;a href=&#34;#prometheus&#34;&gt;prometheus&lt;/a&gt;, &lt;a href=&#34;#promtail&#34;&gt;promtail&lt;/a&gt;, &lt;a href=&#34;#static&#34;&gt;static&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;--bypass-errors&lt;/code&gt;, &lt;code&gt;-b&lt;/code&gt;: Enable bypassing errors when converting.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;--extra-args&lt;/code&gt;, &lt;code&gt;e&lt;/code&gt;: Extra arguments from the original format used by the converter.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;defaults&#34;&gt;Defaults&lt;/h3&gt;
&lt;p&gt;Grafana Agent Flow defaults are managed as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If a provided source configuration value matches a Grafana Agent Flow default value, the property is left off the output.&lt;/li&gt;
&lt;li&gt;If a non-provided source configuration value default matches a Grafana Agent Flow default value, the property is left off the output.&lt;/li&gt;
&lt;li&gt;If a non-provided source configuration value default doesn&amp;rsquo;t match a Grafana Agent Flow default value, the default value is included in the output.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;errors&#34;&gt;Errors&lt;/h3&gt;
&lt;p&gt;Errors are defined as non-critical issues identified during the conversion
where an output can still be generated. These can be bypassed using the
&lt;code&gt;--bypass-errors&lt;/code&gt; flag.&lt;/p&gt;
&lt;h3 id=&#34;opentelemetry-collector&#34;&gt;OpenTelemetry Collector&lt;/h3&gt;
&lt;p&gt;You can use the &lt;code&gt;--source-format=otelcol&lt;/code&gt; to convert the source configuration from an &lt;a href=&#34;https://opentelemetry.io/docs/collector/configuration/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;OpenTelemetry Collector&lt;/a&gt; to a Grafana Agent Flow configuration.&lt;/p&gt;
&lt;p&gt;Many OpenTelemetry Collector components are supported.
Review the &lt;code&gt;otelcol.*&lt;/code&gt; component information in the &lt;a href=&#34;../../components/&#34;&gt;Component Reference&lt;/a&gt; for more information about &lt;code&gt;otelcol&lt;/code&gt; components that you can convert.
If a source configuration has unsupported features, you will receive &lt;a href=&#34;#errors&#34;&gt;errors&lt;/a&gt; when you convert it to a flow configuration.
The converter raises warnings for configuration options that may require your attention.&lt;/p&gt;
&lt;p&gt;Refer to &lt;a href=&#34;../../../tasks/migrate/from-otelcol/&#34;&gt;Migrate from OpenTelemetry Collector to Grafana Agent Flow&lt;/a&gt; for a detailed migration guide.&lt;/p&gt;
&lt;h3 id=&#34;prometheus&#34;&gt;Prometheus&lt;/h3&gt;
&lt;p&gt;Using the &lt;code&gt;--source-format=prometheus&lt;/code&gt; will convert the source configuration from
&lt;a href=&#34;https://prometheus.io/docs/prometheus/2.45/configuration/configuration/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Prometheus v2.45&lt;/a&gt;
to Grafana Agent Flow configuration.&lt;/p&gt;
&lt;p&gt;This includes Prometheus features such as
&lt;a href=&#34;https://prometheus.io/docs/prometheus/2.45/configuration/configuration/#scrape_config&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;scrape_config&lt;/a&gt;,
&lt;a href=&#34;https://prometheus.io/docs/prometheus/2.45/configuration/configuration/#relabel_config&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;relabel_config&lt;/a&gt;,
&lt;a href=&#34;https://prometheus.io/docs/prometheus/2.45/configuration/configuration/#metric_relabel_configs&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;metric_relabel_configs&lt;/a&gt;,
&lt;a href=&#34;https://prometheus.io/docs/prometheus/2.45/configuration/configuration/#remote_write&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;remote_write&lt;/a&gt;,
and many supported *_sd_configs. Unsupported features in a source configuration result
in &lt;a href=&#34;#errors&#34;&gt;errors&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Refer to &lt;a href=&#34;../../../tasks/migrate/from-prometheus/&#34;&gt;Migrate from Prometheus to Grafana Agent Flow&lt;/a&gt; for a detailed migration guide.&lt;/p&gt;
&lt;h3 id=&#34;promtail&#34;&gt;Promtail&lt;/h3&gt;
&lt;p&gt;Using the &lt;code&gt;--source-format=promtail&lt;/code&gt; will convert the source configuration from
&lt;a href=&#34;/docs/loki/v2.8.x/clients/promtail/&#34;&gt;Promtail v2.8.x&lt;/a&gt;
to Grafana Agent Flow configuration.&lt;/p&gt;
&lt;p&gt;Nearly all &lt;a href=&#34;/docs/loki/v2.8.x/clients/promtail/configuration/&#34;&gt;Promtail features&lt;/a&gt;
are supported and can be converted to Grafana Agent Flow configuration.&lt;/p&gt;
&lt;p&gt;If you have unsupported features in a source configuration, you will receive &lt;a href=&#34;#errors&#34;&gt;errors&lt;/a&gt; when you convert to a flow configuration. The converter will
also raise warnings for configuration options that may require your attention.&lt;/p&gt;
&lt;p&gt;Refer to &lt;a href=&#34;../../../tasks/migrate/from-promtail/&#34;&gt;Migrate from Promtail to Grafana Agent Flow&lt;/a&gt; for a detailed migration guide.&lt;/p&gt;
&lt;h3 id=&#34;static&#34;&gt;Static&lt;/h3&gt;
&lt;p&gt;Using the &lt;code&gt;--source-format=static&lt;/code&gt; will convert the source configuration from a
&lt;a href=&#34;../../../../static/&#34;&gt;Grafana Agent Static&lt;/a&gt; configuration to a Grafana Agent Flow configuration.&lt;/p&gt;
&lt;p&gt;Include &lt;code&gt;--extra-args&lt;/code&gt; for passing additional command line flags from the original format.
For example, &lt;code&gt;--extra-args=&amp;quot;-enable-features=integrations-next&amp;quot;&lt;/code&gt; will convert a Grafana Agent Static
&lt;a href=&#34;../../../../static/configuration/integrations/integrations-next/&#34;&gt;integrations-next&lt;/a&gt; configuration to a Grafana Agent Flow configuration. You can also
expand environment variables with &lt;code&gt;--extra-args=&amp;quot;-config.expand-env&amp;quot;&lt;/code&gt;. You can combine multiple command line
flags with a space between each flag, for example &lt;code&gt;--extra-args=&amp;quot;-enable-features=integrations-next -config.expand-env&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you have unsupported features in a Static mode source configuration, you will receive &lt;a href=&#34;#errors&#34;&gt;errors&lt;/a&gt; when you convert to a Flow mode configuration. The converter will
also raise warnings for configuration options that may require your attention.&lt;/p&gt;
&lt;p&gt;Refer to &lt;a href=&#34;../../../tasks/migrate/from-static/&#34;&gt;Migrate from Grafana Agent Static to Grafana Agent Flow&lt;/a&gt; for a detailed migration guide.&lt;/p&gt;
]]></content><description>&lt;h1 id="the-convert-command">The convert command&lt;/h1>
&lt;p>The &lt;code>convert&lt;/code> command converts a supported configuration format to Grafana Agent Flow River format.&lt;/p>
&lt;div class="admonition admonition-caution">&lt;blockquote>&lt;p class="title text-uppercase">Caution&lt;/p>&lt;p>This command has no backward compatibility guarantees and may change or be removed between releases.&lt;/p></description></item><item><title>The fmt command</title><link>https://grafana.com/docs/agent/v0.43/flow/reference/cli/fmt/</link><pubDate>Wed, 11 Sep 2024 17:43:35 +0000</pubDate><guid>https://grafana.com/docs/agent/v0.43/flow/reference/cli/fmt/</guid><content><![CDATA[&lt;h1 id=&#34;the-fmt-command&#34;&gt;The fmt command&lt;/h1&gt;
&lt;p&gt;The &lt;code&gt;fmt&lt;/code&gt; command formats a given Grafana Agent Flow configuration file.&lt;/p&gt;
&lt;h2 id=&#34;usage&#34;&gt;Usage&lt;/h2&gt;
&lt;p&gt;Usage:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;AGENT_MODE=flow grafana-agent fmt [FLAG ...] FILE_NAME&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;grafana-agent-flow fmt [FLAG ...] FILE_NAME&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Replace the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;FLAG&lt;/code&gt;: One or more flags that define the input and output of the command.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;FILE_NAME&lt;/code&gt;: The Grafana Agent Flow configuration file.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If the &lt;code&gt;FILE_NAME&lt;/code&gt; argument is not provided or if the &lt;code&gt;FILE_NAME&lt;/code&gt; argument is
equal to &lt;code&gt;-&lt;/code&gt;, &lt;code&gt;fmt&lt;/code&gt; formats the contents of standard input. Otherwise,
&lt;code&gt;fmt&lt;/code&gt; reads and formats the file from disk specified by the argument.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;--write&lt;/code&gt; flag can be specified to replace the contents of the original
file on disk with the formatted results. &lt;code&gt;--write&lt;/code&gt; can only be provided when
&lt;code&gt;fmt&lt;/code&gt; is not reading from standard input.&lt;/p&gt;
&lt;p&gt;The command fails if the file being formatted has syntactically incorrect River
configuration, but does not validate whether Flow components are configured
properly.&lt;/p&gt;
&lt;p&gt;The following flags are supported:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;--write&lt;/code&gt;, &lt;code&gt;-w&lt;/code&gt;: Write the formatted file back to disk when not reading from
standard input.&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="the-fmt-command">The fmt command&lt;/h1>
&lt;p>The &lt;code>fmt&lt;/code> command formats a given Grafana Agent Flow configuration file.&lt;/p>
&lt;h2 id="usage">Usage&lt;/h2>
&lt;p>Usage:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;code>AGENT_MODE=flow grafana-agent fmt [FLAG ...] FILE_NAME&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>grafana-agent-flow fmt [FLAG ...] FILE_NAME&lt;/code>&lt;/p></description></item><item><title>The run command</title><link>https://grafana.com/docs/agent/v0.43/flow/reference/cli/run/</link><pubDate>Wed, 12 Mar 2025 11:45:31 +0100</pubDate><guid>https://grafana.com/docs/agent/v0.43/flow/reference/cli/run/</guid><content><![CDATA[&lt;h1 id=&#34;the-run-command&#34;&gt;The run command&lt;/h1&gt;
&lt;p&gt;The &lt;code&gt;run&lt;/code&gt; command runs Grafana Agent Flow in the foreground until an interrupt is received.&lt;/p&gt;
&lt;h2 id=&#34;usage&#34;&gt;Usage&lt;/h2&gt;
&lt;p&gt;Usage:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;AGENT_MODE=flow grafana-agent run [FLAG ...] PATH_NAME&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;grafana-agent-flow run [FLAG ...] PATH_NAME&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Replace the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;FLAG&lt;/code&gt;: One or more flags that define the input and output of the command.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;PATH_NAME&lt;/code&gt;: Required. The Grafana Agent Flow configuration file/directory path.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If the &lt;code&gt;PATH_NAME&lt;/code&gt; argument is not provided, or if the configuration path can&amp;rsquo;t be loaded or
contains errors during the initial load, the &lt;code&gt;run&lt;/code&gt; command will immediately exit and show an error message.&lt;/p&gt;
&lt;p&gt;If you give the &lt;code&gt;PATH_NAME&lt;/code&gt; argument a directory path, Grafana Agent Flow will find &lt;code&gt;*.river&lt;/code&gt; files
(ignoring nested directories) and load them as a single configuration source. However, component names must
be &lt;strong&gt;unique&lt;/strong&gt; across all River files, and configuration blocks must not be repeated.&lt;/p&gt;
&lt;p&gt;Grafana Agent Flow will continue to run if subsequent reloads of the configuration
file fail, potentially marking components as unhealthy depending on the nature
of the failure. When this happens, Grafana Agent Flow will continue functioning
in the last valid state.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;run&lt;/code&gt; launches an HTTP server that exposes metrics about itself and its
components. The HTTP server is also exposes a UI at &lt;code&gt;/&lt;/code&gt; for debugging
running components.&lt;/p&gt;
&lt;p&gt;The following flags are supported:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;--server.http.enable-pprof&lt;/code&gt;: Enable /debug/pprof profiling endpoints. (default &lt;code&gt;true&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--server.http.memory-addr&lt;/code&gt;: Address to listen for &lt;a href=&#34;../../../concepts/component_controller/#in-memory-traffic&#34;&gt;in-memory HTTP traffic&lt;/a&gt; on
(default &lt;code&gt;agent.internal:12345&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--server.http.listen-addr&lt;/code&gt;: Address to listen for HTTP traffic on (default &lt;code&gt;127.0.0.1:12345&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--server.http.ui-path-prefix&lt;/code&gt;: Base path where the UI is exposed (default &lt;code&gt;/&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--storage.path&lt;/code&gt;: Base directory where components can store data (default &lt;code&gt;data-agent/&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--disable-reporting&lt;/code&gt;: Disable &lt;a href=&#34;../../../../data-collection/&#34;&gt;data collection&lt;/a&gt; (default &lt;code&gt;false&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--cluster.enabled&lt;/code&gt;: Start Grafana Agent Flow in clustered mode (default &lt;code&gt;false&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--cluster.node-name&lt;/code&gt;: The name to use for this node (defaults to the environment&amp;rsquo;s hostname).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--cluster.join-addresses&lt;/code&gt;: Comma-separated list of addresses to join the cluster at (default &lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt;). Mutually exclusive with &lt;code&gt;--cluster.discover-peers&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--cluster.discover-peers&lt;/code&gt;: List of key-value tuples for discovering peers (default &lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt;). Mutually exclusive with &lt;code&gt;--cluster.join-addresses&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--cluster.rejoin-interval&lt;/code&gt;: How often to rejoin the list of peers (default &lt;code&gt;&amp;quot;60s&amp;quot;&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--cluster.advertise-address&lt;/code&gt;: Address to advertise to other cluster nodes (default &lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--cluster.advertise-interfaces&lt;/code&gt;: List of interfaces used to infer an address to advertise. Set to &lt;code&gt;all&lt;/code&gt; to use all available network interfaces on the system. (default &lt;code&gt;&amp;quot;eth0,en0&amp;quot;&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--cluster.max-join-peers&lt;/code&gt;: Number of peers to join from the discovered set (default &lt;code&gt;5&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--cluster.name&lt;/code&gt;: Name to prevent nodes without this identifier from joining the cluster (default &lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--config.format&lt;/code&gt;: The format of the source file. Supported formats: &lt;code&gt;flow&lt;/code&gt;, &lt;code&gt;otelcol&lt;/code&gt;, &lt;code&gt;prometheus&lt;/code&gt;, &lt;code&gt;promtail&lt;/code&gt;, &lt;code&gt;static&lt;/code&gt; (default &lt;code&gt;&amp;quot;flow&amp;quot;&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--config.bypass-conversion-errors&lt;/code&gt;: Enable bypassing errors when converting (default &lt;code&gt;false&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--config.extra-args&lt;/code&gt;: Extra arguments from the original format used by the converter.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;update-the-configuration-file&#34;&gt;Update the configuration file&lt;/h2&gt;
&lt;p&gt;The configuration file can be reloaded from disk by either:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Sending an HTTP POST request to the &lt;code&gt;/-/reload&lt;/code&gt; endpoint.&lt;/li&gt;
&lt;li&gt;Sending a &lt;code&gt;SIGHUP&lt;/code&gt; signal to the Grafana Agent Flow process.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When this happens, the &lt;a href=&#34;../../../concepts/component_controller/&#34;&gt;component controller&lt;/a&gt; synchronizes the set of running
components with the latest set of components specified in the configuration file.
Components that are no longer defined in the configuration file after reloading are
shut down, and components that have been added to the configuration file since the
previous reload are created.&lt;/p&gt;
&lt;p&gt;All components managed by the component controller are reevaluated after
reloading.&lt;/p&gt;
&lt;h2 id=&#34;clustering&#34;&gt;Clustering&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;--cluster.enabled&lt;/code&gt; command-line argument starts Grafana Agent in
&lt;a href=&#34;../../../concepts/clustering/&#34;&gt;clustering&lt;/a&gt; mode. The rest of the &lt;code&gt;--cluster.*&lt;/code&gt; command-line flags can be
used to configure how nodes discover and connect to one another.&lt;/p&gt;
&lt;p&gt;Each cluster member’s name must be unique within the cluster. Nodes which try
to join with a conflicting name are rejected and will fall back to
bootstrapping a new cluster of their own.&lt;/p&gt;
&lt;p&gt;Peers communicate over HTTP/2 on the built-in HTTP server. Each node
must be configured to accept connections on &lt;code&gt;--server.http.listen-addr&lt;/code&gt; and the
address defined or inferred in &lt;code&gt;--cluster.advertise-address&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If the &lt;code&gt;--cluster.advertise-address&lt;/code&gt; flag isn&amp;rsquo;t explicitly set, Grafana Agent Flow
tries to infer a suitable one from &lt;code&gt;--cluster.advertise-interfaces&lt;/code&gt;.
If &lt;code&gt;--cluster.advertise-interfaces&lt;/code&gt; isn&amp;rsquo;t explicitly set, Grafana Agent Flow will
infer one from the &lt;code&gt;eth0&lt;/code&gt; and &lt;code&gt;en0&lt;/code&gt; local network interfaces.
Grafana Agent Flow will fail to start if it can&amp;rsquo;t determine the advertised address.
Since Windows doesn&amp;rsquo;t use the interface names &lt;code&gt;eth0&lt;/code&gt; or &lt;code&gt;en0&lt;/code&gt;, Windows users must explicitly pass
at least one valid network interface for &lt;code&gt;--cluster.advertise-interfaces&lt;/code&gt; or a value for &lt;code&gt;--cluster.advertise-address&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The comma-separated list of addresses provided in &lt;code&gt;--cluster.join-addresses&lt;/code&gt;
can either be IP addresses with an optional port, or DNS records to lookup.
The ports on the list of addresses default to the port used for the HTTP
listener if not explicitly provided. We recommend that you
align the port numbers on as many nodes as possible to simplify the deployment
process.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;--cluster.discover-peers&lt;/code&gt; command-line flag expects a list of tuples in
the form of &lt;code&gt;provider=XXX key=val key=val ...&lt;/code&gt;. Clustering uses the
&lt;a href=&#34;https://github.com/hashicorp/go-discover&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;go-discover&lt;/a&gt; package to discover peers and fetch their IP addresses, based
on the chosen provider and the filtering key-values it supports. Clustering
supports the default set of providers available in go-discover and registers
the &lt;code&gt;k8s&lt;/code&gt; provider on top.&lt;/p&gt;
&lt;p&gt;If either the key or the value in a tuple pair contains a space, a backslash, or
double quotes, then it must be quoted with double quotes. Within this quoted
string, the backslash can be used to escape double quotes or the backslash
itself.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;--cluster.rejoin-interval&lt;/code&gt; flag defines how often each node should
rediscover peers based on the contents of the &lt;code&gt;--cluster.join-addresses&lt;/code&gt; and
&lt;code&gt;--cluster.discover-peers&lt;/code&gt; flags and try to rejoin them.  This operation
is useful for addressing split-brain issues if the initial bootstrap is
unsuccessful and for making clustering easier to manage in dynamic
environments. To disable this behavior, set the &lt;code&gt;--cluster.rejoin-interval&lt;/code&gt;
flag to &lt;code&gt;&amp;quot;0s&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Discovering peers using the &lt;code&gt;--cluster.join-addresses&lt;/code&gt; and
&lt;code&gt;--cluster.discover-peers&lt;/code&gt; flags only happens on startup; after that, cluster
nodes depend on gossiping messages with each other to converge on the cluster&amp;rsquo;s
state.&lt;/p&gt;
&lt;p&gt;The first node that is used to bootstrap a new cluster (also known as
the &amp;ldquo;seed node&amp;rdquo;) can either omit the flags that specify peers to join or can
try to connect to itself.&lt;/p&gt;
&lt;p&gt;To join or rejoin a cluster, Grafana Agent Flow will try to connect to a certain number of peers limited by the &lt;code&gt;--cluster.max-join-peers&lt;/code&gt; flag.
This flag can be useful for clusters of significant sizes because connecting to a high number of peers can be an expensive operation.
To disable this behavior, set the &lt;code&gt;--cluster.max-join-peers&lt;/code&gt; flag to 0.
If the value of &lt;code&gt;--cluster.max-join-peers&lt;/code&gt; is higher than the number of peers discovered, Grafana Agent Flow will connect to all of them.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;--cluster.name&lt;/code&gt; flag can be used to prevent clusters from accidentally merging.
When &lt;code&gt;--cluster.name&lt;/code&gt; is provided, nodes will only join peers who share the same cluster name value.
By default, the cluster name is empty, and any node that doesn&amp;rsquo;t set the flag can join.
Attempting to join a cluster with a wrong &lt;code&gt;--cluster.name&lt;/code&gt; will result in a &amp;ldquo;failed to join memberlist&amp;rdquo; error.&lt;/p&gt;
&lt;h3 id=&#34;clustering-states&#34;&gt;Clustering states&lt;/h3&gt;
&lt;p&gt;Clustered Grafana Agents are in one of three states:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Viewer&lt;/strong&gt;: Grafana Agent Flow has a read-only view of the cluster and isn&amp;rsquo;t participating in workload distribution.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Participant&lt;/strong&gt;: Grafana Agent Flow is participating in workload distribution for components that have clustering enabled.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Terminating&lt;/strong&gt;: Grafana Agent Flow is shutting down and will no longer assign new work to itself.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each Grafana Agent initially joins the cluster in the viewer state and then transitions to
the participant state after the process startup completes. Each Grafana Agent then
transitions to the terminating state when shutting down.&lt;/p&gt;
&lt;p&gt;The current state of a clustered Grafana Agent is shown on the clustering page in the &lt;a href=&#34;../../../tasks/debug/#clustering-page&#34;&gt;UI&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;configuration-conversion-beta&#34;&gt;Configuration conversion (beta)&lt;/h2&gt;
&lt;p&gt;When you use the &lt;code&gt;--config.format&lt;/code&gt; command-line argument with a value
other than &lt;code&gt;flow&lt;/code&gt;, Grafana Agent converts the configuration file from
the source format to River and immediately starts running with the new
configuration. This conversion uses the converter API described in the
&lt;a href=&#34;../convert/&#34;&gt;grafana-agent-flow convert&lt;/a&gt; docs.&lt;/p&gt;
&lt;p&gt;If you include the &lt;code&gt;--config.bypass-conversion-errors&lt;/code&gt; command-line argument,
Grafana Agent Flow will ignore any errors from the converter. Use this argument
with caution because the resulting conversion may not be equivalent to the
original configuration.&lt;/p&gt;
&lt;p&gt;Include &lt;code&gt;--config.extra-args&lt;/code&gt; to pass additional command line flags from the original format to the converter.
Refer to &lt;a href=&#34;../convert/&#34;&gt;grafana-agent-flow convert&lt;/a&gt; for more details on how &lt;code&gt;extra-args&lt;/code&gt; work.&lt;/p&gt;
]]></content><description>&lt;h1 id="the-run-command">The run command&lt;/h1>
&lt;p>The &lt;code>run&lt;/code> command runs Grafana Agent Flow in the foreground until an interrupt is received.&lt;/p>
&lt;h2 id="usage">Usage&lt;/h2>
&lt;p>Usage:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;code>AGENT_MODE=flow grafana-agent run [FLAG ...] PATH_NAME&lt;/code>&lt;/p></description></item><item><title>The tools command</title><link>https://grafana.com/docs/agent/v0.43/flow/reference/cli/tools/</link><pubDate>Wed, 11 Sep 2024 17:43:35 +0000</pubDate><guid>https://grafana.com/docs/agent/v0.43/flow/reference/cli/tools/</guid><content><![CDATA[&lt;h1 id=&#34;the-tools-command&#34;&gt;The tools command&lt;/h1&gt;
&lt;p&gt;The &lt;code&gt;tools&lt;/code&gt; command contains command line tooling grouped by Flow component.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-caution&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Caution&lt;/p&gt;&lt;p&gt;Utilities in this command have no backward compatibility
guarantees and may change or be removed between releases.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;subcommands&#34;&gt;Subcommands&lt;/h2&gt;
&lt;h3 id=&#34;prometheusremote_write-sample-stats&#34;&gt;prometheus.remote_write sample-stats&lt;/h3&gt;
&lt;p&gt;Usage:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;AGENT_MODE=flow grafana-agent tools prometheus.remote_write sample-stats [FLAG ...] WAL_DIRECTORY&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;grafana-agent-flow tools prometheus.remote_write sample-stats [FLAG ...] WAL_DIRECTORY&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;code&gt;sample-stats&lt;/code&gt; command reads the Write-Ahead Log (WAL) specified by
&lt;code&gt;WAL_DIRECTORY&lt;/code&gt; and collects information on metric samples within it.&lt;/p&gt;
&lt;p&gt;For each metric discovered, &lt;code&gt;sample-stats&lt;/code&gt; emits:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The timestamp of the oldest sample received for that metric.&lt;/li&gt;
&lt;li&gt;The timestamp of the newest sample received for that metric.&lt;/li&gt;
&lt;li&gt;The total number of samples discovered for that metric.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By default, &lt;code&gt;sample-stats&lt;/code&gt; will return information for every metric in the WAL.
You can pass the &lt;code&gt;--selector&lt;/code&gt; flag to filter the reported metrics to a smaller set.&lt;/p&gt;
&lt;p&gt;The following flag is supported:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;--selector&lt;/code&gt;: A PromQL label selector to filter data by. (default &lt;code&gt;{}&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;prometheusremote_write-target-stats&#34;&gt;prometheus.remote_write target-stats&lt;/h3&gt;
&lt;p&gt;Usage:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;AGENT_MODE=flow grafana-agent tools prometheus.remote_write target-stats --job JOB --instance INSTANCE WAL_DIRECTORY&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;grafana-agent-flow tools prometheus.remote_write target-stats --job JOB --instance INSTANCE WAL_DIRECTORY&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;code&gt;target-stats&lt;/code&gt; command reads the Write-Ahead Log (WAL) specified by
&lt;code&gt;WAL_DIRECTORY&lt;/code&gt; and collects metric cardinality information for a specific
target.&lt;/p&gt;
&lt;p&gt;For the target specified by the &lt;code&gt;--job&lt;/code&gt; and &lt;code&gt;--instance&lt;/code&gt; flags, unique metric
names for that target are printed along with the number of series with that
metric name.&lt;/p&gt;
&lt;p&gt;The following flags are supported:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;--job&lt;/code&gt;: The &lt;code&gt;job&lt;/code&gt; label of the target.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--instance&lt;/code&gt;: The &lt;code&gt;instance&lt;/code&gt; label of the target.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;code&gt;--job&lt;/code&gt; and &lt;code&gt;--instance&lt;/code&gt; labels are required.&lt;/p&gt;
&lt;h3 id=&#34;prometheusremote_write-wal-stats&#34;&gt;prometheus.remote_write wal-stats&lt;/h3&gt;
&lt;p&gt;Usage:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;AGENT_MODE=flow grafana-agent tools prometheus.remote_write wal-stats WAL_DIRECTORY&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;grafana-agent-flow tools prometheus.remote_write wal-stats WAL_DIRECTORY&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;code&gt;wal-stats&lt;/code&gt; command reads the Write-Ahead Log (WAL) specified by
&lt;code&gt;WAL_DIRECTORY&lt;/code&gt; and collects general information about it.&lt;/p&gt;
&lt;p&gt;The following information is reported:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The timestamp of the oldest sample in the WAL.&lt;/li&gt;
&lt;li&gt;The timestamp of the newest sample in the WAL.&lt;/li&gt;
&lt;li&gt;The total number of unique series defined in the WAL.&lt;/li&gt;
&lt;li&gt;The total number of samples in the WAL.&lt;/li&gt;
&lt;li&gt;The number of hash collisions detected, if any.&lt;/li&gt;
&lt;li&gt;The total number of invalid records in the WAL, if any.&lt;/li&gt;
&lt;li&gt;The most recent WAL checkpoint segment number.&lt;/li&gt;
&lt;li&gt;The oldest segment number in the WAL.&lt;/li&gt;
&lt;li&gt;The newest segment number in the WAL.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Additionally, &lt;code&gt;wal-stats&lt;/code&gt; reports per-target information, where a target is
defined as a unique combination of the &lt;code&gt;job&lt;/code&gt; and &lt;code&gt;instance&lt;/code&gt; label values. For
each target, &lt;code&gt;wal-stats&lt;/code&gt; reports the number of series and the number of
metric samples associated with that target.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;wal-stats&lt;/code&gt; command does not support any flags.&lt;/p&gt;
]]></content><description>&lt;h1 id="the-tools-command">The tools command&lt;/h1>
&lt;p>The &lt;code>tools&lt;/code> command contains command line tooling grouped by Flow component.&lt;/p>
&lt;div class="admonition admonition-caution">&lt;blockquote>&lt;p class="title text-uppercase">Caution&lt;/p>&lt;p>Utilities in this command have no backward compatibility
guarantees and may change or be removed between releases.&lt;/p></description></item></channel></rss>