<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>database_observability on Grafana Labs</title><link>https://grafana.com/docs/alloy/v1.21/reference/components/database_observability/</link><description>Recent content in database_observability on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/alloy/v1.21/reference/components/database_observability/index.xml" rel="self" type="application/rss+xml"/><item><title>database_observability.mysql</title><link>https://grafana.com/docs/alloy/v1.21/reference/components/database_observability/database_observability.mysql/</link><pubDate>Mon, 19 Oct 2026 11:17:26 +0000</pubDate><guid>https://grafana.com/docs/alloy/v1.21/reference/components/database_observability/database_observability.mysql/</guid><content><![CDATA[&lt;h1 id=&#34;database_observabilitymysql&#34;&gt;&lt;code&gt;database_observability.mysql&lt;/code&gt;&lt;/h1&gt;
&lt;p&gt;&lt;code&gt;database_observability.mysql&lt;/code&gt; connects to a MySQL database and collects observability data from the &lt;code&gt;performance_schema&lt;/code&gt; and &lt;code&gt;information_schema&lt;/code&gt;.
The component collects query details, schema information, explain plans, query samples, and lock information.
It forwards this data as log entries to Loki receivers and exports targets for Prometheus scraping.&lt;/p&gt;
&lt;h2 id=&#34;usage&#34;&gt;Usage&lt;/h2&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;database_observability.mysql &amp;#34;&amp;lt;LABEL&amp;gt;&amp;#34; {
  data_source_name = &amp;lt;DATA_SOURCE_NAME&amp;gt;
  forward_to       = [&amp;lt;LOKI_RECEIVERS&amp;gt;]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;p&gt;You can use the following arguments with &lt;code&gt;database_observability.mysql&lt;/code&gt;:&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;data_source_name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;secret&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;https://github.com/go-sql-driver/mysql#dsn-data-source-name&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Data Source Name&lt;/a&gt; for the MySQL server to connect to. Required when no &lt;code&gt;database_instance&lt;/code&gt; blocks are defined.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;forward_to&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(LogsReceiver)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Where to forward log entries after processing.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;targets&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(map(string))&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;List of external targets to scrape.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;disable_collectors&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(string)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;A list of collectors to disable from the default set.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;enable_collectors&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(string)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;A list of collectors to enable on top of the default set.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;exclude_schemas&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(string)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;A list of schemas to exclude from monitoring.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;[&amp;quot;alloydbadmin&amp;quot;, &amp;quot;alloydbmetadata&amp;quot;, &amp;quot;azure_maintenance&amp;quot;, &amp;quot;azure_sys&amp;quot;, &amp;quot;cloudsqladmin&amp;quot;, &amp;quot;rdsadmin&amp;quot;]&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;allow_update_performance_schema_settings&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;boolean&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Whether to allow updates to &lt;code&gt;performance_schema&lt;/code&gt; settings in any collector. Enable this in conjunction with other collector-specific settings where required.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;The following collectors are configurable:&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;Name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Enabled by default&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;query_details&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect queries information.&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;schema_details&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect schemas and tables from &lt;code&gt;information_schema&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;query_samples&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect query samples.&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;setup_consumers&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect enabled &lt;code&gt;performance_schema.setup_consumers&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;setup_actors&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Check and update &lt;code&gt;performance_schema.setup_actors&lt;/code&gt; settings.&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;locks&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect queries that are waiting/blocking other queries.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;explain_plans&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect explain plans information.&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;table_stats&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect table-level index usage statistics.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;index_stats&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect per-index usage statistics.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;blocks&#34;&gt;Blocks&lt;/h2&gt;
&lt;p&gt;You can use the following blocks with &lt;code&gt;database_observability.mysql&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;config-app&#34; style=&#34;--config-tree-row-count: 17;&#34; x3-data=&#34;configVisualizer(&amp;#34;\u003csection class=\&amp;#34;expand-table-wrapper\&amp;#34;\u003e\u003cdiv class=\&amp;#34;button-div\&amp;#34;\u003e\n      \u003cbutton class=\&amp;#34;expand-table-btn\&amp;#34;\u003eExpand table\u003c/button\u003e\n    \u003c/div\u003e\u003cdiv class=\&amp;#34;responsive-table-wrapper\&amp;#34;\u003e\n    \u003ctable\u003e\n      \u003cthead\u003e\n          \u003ctr\u003e\n              \u003cth\u003eBlock\u003c/th\u003e\n              \u003cth\u003eDescription\u003c/th\u003e\n              \u003cth\u003eRequired\u003c/th\u003e\n          \u003c/tr\u003e\n      \u003c/thead\u003e\n      \u003ctbody\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#cloud_provider\&amp;#34;\u003e\u003ccode\u003ecloud_provider\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eProvide Cloud Provider information.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ccode\u003ecloud_provider\u003c/code\u003e \u0026gt; \u003ca href=\&amp;#34;#aws\&amp;#34;\u003e\u003ccode\u003eaws\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eProvide AWS database host information.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ccode\u003ecloud_provider\u003c/code\u003e \u0026gt; \u003ca href=\&amp;#34;#azure\&amp;#34;\u003e\u003ccode\u003eazure\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eProvide Azure database host information.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ccode\u003ecloud_provider\u003c/code\u003e \u0026gt; \u003ca href=\&amp;#34;#gcp\&amp;#34;\u003e\u003ccode\u003egcp\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eProvide GCP database host information.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#database_instance\&amp;#34;\u003e\u003ccode\u003edatabase_instance\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eDefine one database to monitor. Repeat the block to monitor several databases.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ccode\u003edatabase_instance\u003c/code\u003e \u0026gt; \u003ca href=\&amp;#34;#cloud_provider\&amp;#34;\u003e\u003ccode\u003ecloud_provider\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eProvide Cloud Provider information for one database.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ccode\u003edatabase_instance\u003c/code\u003e \u0026gt; \u003ca href=\&amp;#34;#rule\&amp;#34;\u003e\u003ccode\u003erule\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eRelabel the metrics and logs of one database.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#clustering\&amp;#34;\u003e\u003ccode\u003eclustering\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the component for when Alloy is running in clustered mode.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#setup_consumers\&amp;#34;\u003e\u003ccode\u003esetup_consumers\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the \u003ccode\u003esetup_consumers\u003c/code\u003e collector.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#setup_actors\&amp;#34;\u003e\u003ccode\u003esetup_actors\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the \u003ccode\u003esetup_actors\u003c/code\u003e collector.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#query_details\&amp;#34;\u003e\u003ccode\u003equery_details\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the queries collector.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#schema_details\&amp;#34;\u003e\u003ccode\u003eschema_details\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the schema and table details collector.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#explain_plans\&amp;#34;\u003e\u003ccode\u003eexplain_plans\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the explain plans collector.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#locks\&amp;#34;\u003e\u003ccode\u003elocks\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the locks collector.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#query_samples\&amp;#34;\u003e\u003ccode\u003equery_samples\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the query samples collector.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#health_check\&amp;#34;\u003e\u003ccode\u003ehealth_check\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the health check collector.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#prometheus_exporter\&amp;#34;\u003e\u003ccode\u003eprometheus_exporter\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the embedded mysqld_exporter.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n      \u003c/tbody\u003e\n    \u003c/table\u003e\n  \u003c/div\u003e\n\u003c/section\u003e&amp;#34;)&#34;&gt;
  &lt;noscript&gt;
    &lt;div class=&#34;config-app__noscript&#34;&gt;&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Block&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#cloud_provider&#34;&gt;&lt;code&gt;cloud_provider&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Provide Cloud Provider information.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;cloud_provider&lt;/code&gt; &amp;gt; &lt;a href=&#34;#aws&#34;&gt;&lt;code&gt;aws&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Provide AWS database host information.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;cloud_provider&lt;/code&gt; &amp;gt; &lt;a href=&#34;#azure&#34;&gt;&lt;code&gt;azure&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Provide Azure database host information.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;cloud_provider&lt;/code&gt; &amp;gt; &lt;a href=&#34;#gcp&#34;&gt;&lt;code&gt;gcp&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Provide GCP database host information.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#database_instance&#34;&gt;&lt;code&gt;database_instance&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Define one database to monitor. Repeat the block to monitor several databases.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;database_instance&lt;/code&gt; &amp;gt; &lt;a href=&#34;#cloud_provider&#34;&gt;&lt;code&gt;cloud_provider&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Provide Cloud Provider information for one database.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;database_instance&lt;/code&gt; &amp;gt; &lt;a href=&#34;#rule&#34;&gt;&lt;code&gt;rule&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Relabel the metrics and logs of one database.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#clustering&#34;&gt;&lt;code&gt;clustering&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the component for when Alloy is running in clustered mode.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#setup_consumers&#34;&gt;&lt;code&gt;setup_consumers&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the &lt;code&gt;setup_consumers&lt;/code&gt; collector.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#setup_actors&#34;&gt;&lt;code&gt;setup_actors&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the &lt;code&gt;setup_actors&lt;/code&gt; collector.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#query_details&#34;&gt;&lt;code&gt;query_details&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the queries collector.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#schema_details&#34;&gt;&lt;code&gt;schema_details&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the schema and table details collector.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#explain_plans&#34;&gt;&lt;code&gt;explain_plans&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the explain plans collector.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#locks&#34;&gt;&lt;code&gt;locks&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the locks collector.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#query_samples&#34;&gt;&lt;code&gt;query_samples&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the query samples collector.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#health_check&#34;&gt;&lt;code&gt;health_check&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the health check collector.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#prometheus_exporter&#34;&gt;&lt;code&gt;prometheus_exporter&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the embedded mysqld_exporter.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;/div&gt;
  &lt;/noscript&gt;
  &lt;main class=&#34;config-app__main&#34;&gt;
    &lt;template x3-if=&#34;flatBlocks.length === 0&#34;&gt;
      &lt;div class=&#34;empty-state&#34;&gt;
        &lt;div class=&#34;empty-state__icon&#34; x3-html=&#34;icons.AlertCircle&#34;&gt;&lt;/div&gt;
        &lt;p&gt;No valid configuration blocks found.&lt;/p&gt;
      &lt;/div&gt;
    &lt;/template&gt;

    &lt;template x3-if=&#34;flatBlocks.length &gt; 0&#34;&gt;
      &lt;div class=&#34;config-tree&#34;&gt;
        &lt;div class=&#34;config-tree__toolbar&#34;&gt;
          &lt;div class=&#34;config-tree__title&#34;&gt;&lt;/div&gt;
          &lt;button
            class=&#34;tree-explorer__button w-130 text-right&#34;
            x3-on:click=&#34;toggleExpandAll&#34;
            x3-bind:title=&#34;allExpanded ? &#39;Collapse all&#39; : &#39;Expand all&#39;&#34;
          &gt;
            &lt;span x3-text=&#34;allExpanded ? &#39;Collapse all&#39; : &#39;Expand all&#39;&#34;&gt;&lt;/span&gt;
            &lt;svg class=&#34;api-icon&#34; viewBox=&#34;0 0 24 24&#34;&gt;
              &lt;path x3-show=&#34;!allExpanded&#34; d=&#34;m6 9 6 6 6-6&#34; /&gt;
              &lt;path x3-show=&#34;allExpanded&#34; d=&#34;m18 15-6-6-6 6&#34; /&gt;
            &lt;/svg&gt;
          &lt;/button&gt;
        &lt;/div&gt;

        &lt;div class=&#34;nodes-container&#34;&gt;
          &lt;template x3-for=&#34;block in flatBlocks&#34; x3-bind:key=&#34;block.id&#34;&gt;
            &lt;div class=&#34;node&#34; x3-bind:class=&#34;isNodeVisible(block) ? &#39;node--visible&#39; : &#39;node--hidden&#39;&#34;&gt;
              &lt;div
                class=&#34;node__row&#34;
                x3-bind:class=&#34;getRowClass(block)&#34;
                x3-bind:style=&#34;`padding-left: ${block.level * 24 &#43; 16}px`&#34;
                x3-on:click=&#34;toggleNode(block.id)&#34;
              &gt;
                &lt;div class=&#34;node__left&#34;&gt;
                  &lt;div class=&#34;node__indicator&#34;&gt;
                    &lt;template x3-if=&#34;block.hasChildren&#34;&gt;
                      &lt;button type=&#34;button&#34; class=&#34;node__toggle&#34; x3-on:click.stop=&#34;toggleNode(block.id)&#34;&gt;
                        &lt;div
                          class=&#34;node__toggle-icon&#34;
                          x3-bind:class=&#34;block.expanded ? &#39;node__toggle-icon--expanded&#39; : &#39;&#39;&#34;
                          x3-html=&#34;icons.ChevronDown&#34;
                        &gt;&lt;/div&gt;
                      &lt;/button&gt;
                    &lt;/template&gt;
                    &lt;template x3-if=&#34;!block.hasChildren&#34;&gt;
                      &lt;div class=&#34;node__toggle-spacer&#34;&gt;&lt;/div&gt;
                    &lt;/template&gt;
                  &lt;/div&gt;

                  &lt;div class=&#34;node__content&#34;&gt;
                    &lt;div
                      class=&#34;node__title prose&#34;
                      x3-bind:class=&#34;block.level === 0 ? &#39;node__title--root&#39; : &#39;node__title--nested&#39;&#34;
                      x3-html=&#34;block.displayName&#34;
                    &gt;&lt;/div&gt;
                    &lt;div class=&#34;node__description body-xsmall&#34; x3-html=&#34;block.description&#34;&gt;&lt;/div&gt;
                  &lt;/div&gt;
                &lt;/div&gt;

                &lt;div class=&#34;node__meta&#34;&gt;
                  &lt;span
                    class=&#34;badge&#34;
                    x3-bind:class=&#34;block.required ? &#39;badge--required&#39; : &#39;badge--optional&#39;&#34;
                    x3-text=&#34;block.required ? &#39;Required&#39; : &#39;Optional&#39;&#34;
                  &gt;&lt;/span&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/template&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/template&gt;
  &lt;/main&gt;
&lt;/div&gt;

&lt;h3 id=&#34;cloud_provider&#34;&gt;&lt;code&gt;cloud_provider&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;cloud_provider&lt;/code&gt; block has no attributes.
It contains zero or one of the &lt;a href=&#34;#aws&#34;&gt;&lt;code&gt;aws&lt;/code&gt;&lt;/a&gt;, &lt;a href=&#34;#azure&#34;&gt;&lt;code&gt;azure&lt;/code&gt;&lt;/a&gt;, or &lt;a href=&#34;#gcp&#34;&gt;&lt;code&gt;gcp&lt;/code&gt;&lt;/a&gt; blocks.
You use the &lt;code&gt;cloud_provider&lt;/code&gt; block to provide information related to the cloud provider that hosts the database under observation.
This information is appended as labels to the collected metrics.
The labels make it easier for you to filter and group your metrics.&lt;/p&gt;
&lt;h3 id=&#34;aws&#34;&gt;&lt;code&gt;aws&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;aws&lt;/code&gt; block supplies the &lt;a href=&#34;https://docs.aws.amazon.com/IAM/latest/UserGuide/reference-arns.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;ARN&lt;/a&gt; identifier for the database being monitored.&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;arn&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The ARN associated with the database under observation.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;azure&#34;&gt;&lt;code&gt;azure&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;azure&lt;/code&gt; block supplies the identifying information for the database being monitored.&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;subscription_id&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The Subscription ID for your Azure account.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;resource_group&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The Resource Group that holds the database resource.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;server_name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The database server name, for example &lt;code&gt;orders-db&lt;/code&gt; for the host &lt;code&gt;orders-db.mysql.database.azure.com&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;gcp&#34;&gt;&lt;code&gt;gcp&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;gcp&lt;/code&gt; block supplies the identifying information for the GCP Cloud SQL database being monitored.&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;connection_name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The Cloud SQL instance connection name in the format &lt;code&gt;project:region:instance&lt;/code&gt;, for example &lt;code&gt;my-project:us-central1:my-db&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;database_instance&#34;&gt;&lt;code&gt;database_instance&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;database_instance&lt;/code&gt; block defines one database server to monitor.
Repeat the block to monitor several databases with a single component.
The block label must be unique across &lt;code&gt;database_instance&lt;/code&gt; blocks and identifies the database in the component&amp;rsquo;s metrics endpoint path.
Each &lt;code&gt;database_instance&lt;/code&gt; block must also point to a distinct server: two blocks that resolve to the same host, port, and database name are rejected.&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;data_source_name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;secret&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;https://github.com/go-sql-driver/mysql#dsn-data-source-name&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Data Source Name&lt;/a&gt; for the MySQL server to connect to.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Each &lt;code&gt;database_instance&lt;/code&gt; block can also contain a [&lt;code&gt;cloud_provider&lt;/code&gt;][cloud_provider] block that applies to that database only, and [&lt;code&gt;rule&lt;/code&gt;][rule] blocks that relabel the metrics and logs of that database only.&lt;/p&gt;
&lt;p&gt;The component always embeds a &lt;code&gt;mysqld_exporter&lt;/code&gt; for each &lt;code&gt;database_instance&lt;/code&gt; block and serves its metrics on the block&amp;rsquo;s metrics path.
Use the [&lt;code&gt;prometheus_exporter&lt;/code&gt;][prometheus_exporter] block to configure it.
External exporter targets are only supported in the top-level single-DSN form.&lt;/p&gt;
&lt;p&gt;When you define &lt;code&gt;database_instance&lt;/code&gt; blocks, don&amp;rsquo;t set the top-level &lt;code&gt;data_source_name&lt;/code&gt;, &lt;code&gt;targets&lt;/code&gt;, and &lt;code&gt;cloud_provider&lt;/code&gt; arguments.
They&amp;rsquo;re mutually exclusive with &lt;code&gt;database_instance&lt;/code&gt; blocks.
All other arguments and blocks, such as collector settings and &lt;code&gt;prometheus_exporter&lt;/code&gt;, apply to every configured database.&lt;/p&gt;
&lt;p&gt;The metrics for each database are served on a separate &lt;code&gt;/db/&amp;lt;LABEL&amp;gt;/metrics&lt;/code&gt; path under the component&amp;rsquo;s HTTP endpoint, and the exported targets point to the corresponding path.
When you don&amp;rsquo;t define &lt;code&gt;database_instance&lt;/code&gt; blocks, the component serves metrics on its historical &lt;code&gt;/metrics&lt;/code&gt; path.
The metrics endpoints are served exactly at those paths: requests to any other path under the component&amp;rsquo;s HTTP endpoint return HTTP 404.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;

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

  database_instance &amp;#34;orders&amp;#34; {
    data_source_name = sys.env(&amp;#34;ORDERS_DSN&amp;#34;)

    cloud_provider {
      aws {
        arn = &amp;#34;orders-rds-db-arn&amp;#34;
      }
    }

    rule {
      target_label = &amp;#34;environment&amp;#34;
      replacement  = &amp;#34;production&amp;#34;
    }
  }

  database_instance &amp;#34;billing&amp;#34; {
    data_source_name = sys.env(&amp;#34;BILLING_DSN&amp;#34;)

    rule {
      target_label = &amp;#34;environment&amp;#34;
      replacement  = &amp;#34;staging&amp;#34;
    }
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In this example, the metrics and logs of the &lt;code&gt;orders&lt;/code&gt; database carry &lt;code&gt;environment=&amp;quot;production&amp;quot;&lt;/code&gt;, and those of the &lt;code&gt;billing&lt;/code&gt; database carry &lt;code&gt;environment=&amp;quot;staging&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;rule&#34;&gt;&lt;code&gt;rule&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;rule&lt;/code&gt; block relabels the metrics and the logs of the &lt;code&gt;database_instance&lt;/code&gt; block that contains it.
Use it to tell the data of each monitored database apart, for example by environment, team, or tier.&lt;/p&gt;


&lt;div data-shared=&#34;reference/components/rule-block-database-observability.md&#34;&gt;
            &lt;p&gt;The &lt;code&gt;rule&lt;/code&gt; block defines a relabeling rule applied to the metrics and the logs of a single monitored database.
If you define more than one &lt;code&gt;rule&lt;/code&gt; block, the rules are applied in top-down order, after the labels the component sets itself, so a rule can read those labels with &lt;code&gt;source_labels&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It takes the same arguments as the 
    &lt;a href=&#34;/docs/alloy/v1.21/reference/components/prometheus/prometheus.relabel/#rule&#34;&gt;&lt;code&gt;rule&lt;/code&gt; block&lt;/a&gt; used elsewhere in Alloy, in a restricted form: because one rule set applies to two signal paths, it supports the labelling actions only, and it can&amp;rsquo;t overwrite most of the labels the component sets.
Alloy refuses to load a configuration containing a rule that breaks either restriction, so such a rule is never silently ignored.&lt;/p&gt;
&lt;p&gt;Two further constraints are specific to a &lt;code&gt;database_instance&lt;/code&gt; block:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;target_label&lt;/code&gt; must be a literal label name&lt;/strong&gt;: Alloy checks it against the reserved labels when it loads the configuration, so it can&amp;rsquo;t contain a capture group reference.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;hashmod&lt;/code&gt; requires &lt;code&gt;source_labels&lt;/code&gt;, and can&amp;rsquo;t target &lt;code&gt;instance&lt;/code&gt;&lt;/strong&gt;: hashing the empty value gives every database the same result, and hashing into &lt;code&gt;instance&lt;/code&gt; buckets several databases onto one value even when the source is present.&lt;/li&gt;
&lt;/ul&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;A relabeling rule that computes an empty value &lt;em&gt;removes&lt;/em&gt; its target label instead of setting it, and the default &lt;code&gt;replacement&lt;/code&gt; of &lt;code&gt;&amp;quot;$1&amp;quot;&lt;/code&gt; computes an empty value when a rule has no &lt;code&gt;source_labels&lt;/code&gt;.
So &lt;code&gt;rule { target_label = &amp;quot;environment&amp;quot; }&lt;/code&gt; removes &lt;code&gt;environment&lt;/code&gt; rather than setting it, and Alloy rejects it.
Always set &lt;code&gt;replacement&lt;/code&gt; alongside a &lt;code&gt;target_label&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Alloy can only reject such a rule where the outcome is certain.
A rule that reads &lt;code&gt;source_labels&lt;/code&gt; depends on the labels present at runtime, so a missing or misspelled source label still removes the target label, except for the reserved labels and &lt;code&gt;instance&lt;/code&gt;, which keep their previous value.
Only removal is prevented: a rule that computes a &lt;em&gt;non-empty&lt;/em&gt; value still overwrites those labels, which is why &lt;code&gt;hashmod&lt;/code&gt; can&amp;rsquo;t target &lt;code&gt;instance&lt;/code&gt; at all.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;You can use the &lt;code&gt;hashmod&lt;/code&gt;, &lt;code&gt;labeldrop&lt;/code&gt;, &lt;code&gt;lowercase&lt;/code&gt;, &lt;code&gt;replace&lt;/code&gt;, and &lt;code&gt;uppercase&lt;/code&gt; actions.
The rest aren&amp;rsquo;t supported:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;drop&lt;/code&gt;, &lt;code&gt;dropequal&lt;/code&gt;, &lt;code&gt;keep&lt;/code&gt;, and &lt;code&gt;keepequal&lt;/code&gt; filter rather than label, and filtering means two different things on the two signal paths. Dropping a metrics target stops the database exporting metrics entirely, whereas dropping a log entry discards one line. To filter one database&amp;rsquo;s logs, use a 
    &lt;a href=&#34;/docs/alloy/v1.21/reference/components/loki/loki.relabel/&#34;&gt;&lt;code&gt;loki.relabel&lt;/code&gt;&lt;/a&gt; component on the receiver named in &lt;code&gt;forward_to&lt;/code&gt;, with a &lt;code&gt;drop&lt;/code&gt; rule that matches that database&amp;rsquo;s &lt;code&gt;instance&lt;/code&gt; or &lt;code&gt;server_id&lt;/code&gt;. Every database the component monitors forwards to the same receivers, so the rule has to identify the one it applies to. To filter one database&amp;rsquo;s metrics, use a 
    &lt;a href=&#34;/docs/alloy/v1.21/reference/components/discovery/discovery.relabel/&#34;&gt;&lt;code&gt;discovery.relabel&lt;/code&gt;&lt;/a&gt; component on the component&amp;rsquo;s exported targets.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;labelmap&lt;/code&gt; builds label names from &lt;code&gt;replacement&lt;/code&gt; at runtime, so Alloy can&amp;rsquo;t check them against the reserved labels when it loads the configuration.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;labelkeep&lt;/code&gt; removes every label its &lt;code&gt;regex&lt;/code&gt; doesn&amp;rsquo;t match, so a rule that preserves the reserved labels would have to match all of them. Use &lt;code&gt;labeldrop&lt;/code&gt; to remove specific labels instead.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Because the rules run after the component&amp;rsquo;s own labels, and those are protected, a &lt;code&gt;labeldrop&lt;/code&gt; rule can only remove a label that an earlier rule in the same block created.&lt;/p&gt;
&lt;h4 id=&#34;reserved-labels&#34;&gt;Reserved labels&lt;/h4&gt;
&lt;p&gt;A rule can&amp;rsquo;t write to the following labels, and a &lt;code&gt;labeldrop&lt;/code&gt; regular expression can&amp;rsquo;t match them:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Both metrics and logs&lt;/strong&gt;: &lt;code&gt;job&lt;/code&gt; and &lt;code&gt;server_id&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Logs only&lt;/strong&gt;: &lt;code&gt;engine&lt;/code&gt; and &lt;code&gt;op&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Metrics only&lt;/strong&gt;: &lt;code&gt;provider_name&lt;/code&gt;, &lt;code&gt;provider_region&lt;/code&gt;, &lt;code&gt;provider_account&lt;/code&gt;, &lt;code&gt;__address__&lt;/code&gt;, &lt;code&gt;__scheme__&lt;/code&gt;, and &lt;code&gt;__metrics_path__&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This applies to &lt;code&gt;rule&lt;/code&gt; blocks only.
A downstream &lt;code&gt;discovery.relabel&lt;/code&gt; or &lt;code&gt;loki.relabel&lt;/code&gt; component can still overwrite any of them, but it applies to every database the component monitors rather than one.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;instance&lt;/code&gt; label is a special case: a rule can rewrite its value, which is a common reason to use a &lt;code&gt;rule&lt;/code&gt; block, because a friendly name such as &lt;code&gt;orders_db&lt;/code&gt; then applies to that database&amp;rsquo;s metrics and logs together.
A rule can&amp;rsquo;t remove it, because metrics and logs are correlated on it, and because an empty &lt;code&gt;instance&lt;/code&gt; on a metrics target makes Prometheus fill it in from &lt;code&gt;__address__&lt;/code&gt;, which every database in one component shares, collapsing them all onto one series.&lt;/p&gt;
&lt;p&gt;For the same reason, two &lt;code&gt;database_instance&lt;/code&gt; blocks can&amp;rsquo;t rewrite &lt;code&gt;instance&lt;/code&gt; to the same value.
Alloy rejects that when both values are fixed in the configuration, but it can&amp;rsquo;t when the value comes from a label the databases share: &lt;code&gt;source_labels = [&amp;quot;job&amp;quot;]&lt;/code&gt; gives every database the same &lt;code&gt;instance&lt;/code&gt;, since they all carry the same &lt;code&gt;job&lt;/code&gt;.
Derive &lt;code&gt;instance&lt;/code&gt; from something that differs per database, or set a literal value in each block.&lt;/p&gt;
&lt;h4 id=&#34;labels-set-on-only-one-signal-path&#34;&gt;Labels set on only one signal path&lt;/h4&gt;
&lt;p&gt;Some of the labels above exist on one signal path and not the other, and a rule that reads one with &lt;code&gt;source_labels&lt;/code&gt; behaves differently on each path: where the label is absent the rule computes an empty value, which &lt;em&gt;removes&lt;/em&gt; its &lt;code&gt;target_label&lt;/code&gt; rather than setting it to an empty string.&lt;/p&gt;
&lt;p&gt;A rule reading &lt;code&gt;provider_region&lt;/code&gt;, which a database with a &lt;a href=&#34;#cloud_provider&#34;&gt;&lt;code&gt;cloud_provider&lt;/code&gt;&lt;/a&gt; block carries on its metrics targets but not on its log entries, sets &lt;code&gt;region&lt;/code&gt; on that database&amp;rsquo;s metrics and removes &lt;code&gt;region&lt;/code&gt; from its logs.
Reading a logs-only label such as &lt;code&gt;op&lt;/code&gt; does the same in reverse.
Only &lt;code&gt;job&lt;/code&gt;, &lt;code&gt;server_id&lt;/code&gt;, and &lt;code&gt;instance&lt;/code&gt; are set on both paths, so prefer those as &lt;code&gt;source_labels&lt;/code&gt;, or a label an earlier rule in the same block created.&lt;/p&gt;
&lt;/div&gt;

        
&lt;h3 id=&#34;clustering&#34;&gt;&lt;code&gt;clustering&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;enabled&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;bool&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Enables distributing databases with other cluster nodes.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;When Alloy is &lt;a href=&#34;../../../../get-started/clustering/&#34;&gt;using clustering&lt;/a&gt;, and &lt;code&gt;enabled&lt;/code&gt; is set to true, then this &lt;code&gt;database_observability.mysql&lt;/code&gt; component instance opts-in to distributing its configured databases between all cluster nodes.&lt;/p&gt;
&lt;p&gt;Clustering assumes that all cluster nodes are running with the same configuration file.
All component instances opting in to clustering use the instance key of each configured database, &lt;code&gt;&amp;lt;network&amp;gt;(&amp;lt;host&amp;gt;:&amp;lt;port&amp;gt;)/&amp;lt;dbname&amp;gt;&lt;/code&gt;, and a consistent hashing algorithm to determine ownership of each database between the cluster peers.
Each peer then only collects from the subset of databases it&amp;rsquo;s responsible for, and only exports the targets of those databases, so &lt;code&gt;prometheus.scrape&lt;/code&gt; components on the same node scrape exactly the databases the node owns.
When a node joins or leaves the cluster, every peer recalculates ownership: expect a short gap or a brief duplicate collection for a database while its ownership moves.
This includes the collectors that update &lt;code&gt;performance_schema&lt;/code&gt; settings, such as &lt;code&gt;setup_actors&lt;/code&gt; and &lt;code&gt;setup_consumers&lt;/code&gt;, which can briefly run from two nodes during the move: their updates are idempotent.
While the cluster isn&amp;rsquo;t yet ready to admit traffic, for example while it&amp;rsquo;s still forming and waiting for the minimum cluster size, the component doesn&amp;rsquo;t collect from any database.&lt;/p&gt;
&lt;p&gt;Clustering is also useful with a single database: when several cluster nodes run an identical configuration, exactly one node collects from the database at a time, which gives you a highly available setup without duplicate collection.&lt;/p&gt;
&lt;p&gt;If Alloy is &lt;em&gt;not&lt;/em&gt; running in clustered mode, then the block is a no-op and &lt;code&gt;database_observability.mysql&lt;/code&gt; collects from every configured database.&lt;/p&gt;
&lt;h3 id=&#34;setup_consumers&#34;&gt;&lt;code&gt;setup_consumers&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;collect_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How frequently to collect &lt;code&gt;performance_schema.setup_consumers&lt;/code&gt; information from the database.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;1h&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;query_details&#34;&gt;&lt;code&gt;query_details&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;collect_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How frequently to collect information from database.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;1m&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;statements_limit&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;integer&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Max number of recent queries to collect details for.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;250&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;schema_details&#34;&gt;&lt;code&gt;schema_details&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;collect_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How frequently to collect information from database.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;1m&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;cache_enabled&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;boolean&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Deprecated. Whether to enable caching of table definitions.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;true&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;cache_size&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;integer&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Deprecated. Cache size.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;256&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;cache_ttl&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Deprecated. Cache TTL.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;10m&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;The &lt;code&gt;cache_enabled&lt;/code&gt;, &lt;code&gt;cache_size&lt;/code&gt;, and &lt;code&gt;cache_ttl&lt;/code&gt; settings are deprecated: they are accepted for backward compatibility, but ignored.&lt;/p&gt;
&lt;h3 id=&#34;explain_plans&#34;&gt;&lt;code&gt;explain_plans&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;collect_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How frequently to collect information from database.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;1m&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;initial_lookback&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How far back to look for explain plan queries on the first collection interval.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;24h&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;per_collect_ratio&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;float&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Ratio of explain plan queries to collect per collect interval.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;1.0&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;locks&#34;&gt;&lt;code&gt;locks&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;collect_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How frequently to collect information from database.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;30s&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;threshold&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Threshold for locks to be considered slow. Locks that exceed this duration are logged.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;1s&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;query_samples&#34;&gt;&lt;code&gt;query_samples&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;collect_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How frequently to collect information from database.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;10s&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;disable_query_redaction&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;bool&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect unredacted SQL query text (including query parameters) and query error messages.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;auto_enable_setup_consumers&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;boolean&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Enables specific &lt;code&gt;performance_schema.setup_consumers&lt;/code&gt; options. You must also enable &lt;code&gt;allow_update_performance_schema_settings&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;setup_consumers_check_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How frequently to check if &lt;code&gt;setup_consumers&lt;/code&gt; are correctly enabled.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;1h&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;sample_min_duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Minimum duration for query samples to be collected. Set to &amp;ldquo;0s&amp;rdquo; to disable filtering and collect all samples regardless of their duration.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;0s&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;wait_event_min_duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Minimum duration for a wait event to be collected. Set to &amp;ldquo;0s&amp;rdquo; to disable filtering and collect all wait events regardless of their duration.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;1us&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;enable_pre_classified_wait_events&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;boolean&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;When &lt;code&gt;true&lt;/code&gt;, emits telemetry data with pre-classified wait event information.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;setup_actors&#34;&gt;&lt;code&gt;setup_actors&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;auto_update_setup_actors&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;boolean&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Enables updates to &lt;code&gt;performance_schema.setup_actors&lt;/code&gt; settings. You must also enable &lt;code&gt;allow_update_performance_schema_settings&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;collect_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How frequently to check if &lt;code&gt;setup_actors&lt;/code&gt; are configured correctly.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;1h&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;health_check&#34;&gt;&lt;code&gt;health_check&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;collect_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How frequently to run health checks.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;1h&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;prometheus_exporter&#34;&gt;&lt;code&gt;prometheus_exporter&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;prometheus_exporter&lt;/code&gt; block configures the embedded mysqld_exporter scrapers.
The &lt;code&gt;data_source_name&lt;/code&gt; is inherited from the parent block.&lt;/p&gt;
&lt;p&gt;Refer to &lt;a href=&#34;../../prometheus/prometheus.exporter.mysql/&#34;&gt;&lt;code&gt;prometheus.exporter.mysql&lt;/code&gt;&lt;/a&gt; docs for the full list of supported arguments and sub-blocks.&lt;/p&gt;
&lt;h2 id=&#34;example&#34;&gt;Example&lt;/h2&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;database_observability.mysql &amp;#34;orders_db&amp;#34; {
  data_source_name = &amp;#34;user:pass@tcp(mysql:3306)/&amp;#34;
  forward_to       = [loki.relabel.orders_db.receiver]
  targets          = prometheus.exporter.mysql.orders_db.targets

  enable_collectors = [&amp;#34;query_samples&amp;#34;, &amp;#34;explain_plans&amp;#34;]

  cloud_provider {
    aws {
      arn = &amp;#34;your-rds-db-arn&amp;#34;
    }
  }
}

prometheus.exporter.mysql &amp;#34;orders_db&amp;#34; {
  data_source_name  = &amp;#34;user:pass@tcp(mysql:3306)/&amp;#34;
  enable_collectors = [&amp;#34;perf_schema.eventsstatements&amp;#34;]
}

loki.relabel &amp;#34;orders_db&amp;#34; {
  forward_to = [loki.write.logs_service.receiver]
  rule {
    target_label = &amp;#34;job&amp;#34;
    replacement  = &amp;#34;integrations/db-o11y&amp;#34;
  }
  rule {
    target_label = &amp;#34;instance&amp;#34;
    replacement  = &amp;#34;orders_db&amp;#34;
  }
}

discovery.relabel &amp;#34;orders_db&amp;#34; {
  targets = database_observability.mysql.orders_db.targets

  rule {
    target_label = &amp;#34;job&amp;#34;
    replacement  = &amp;#34;integrations/db-o11y&amp;#34;
  }
  rule {
    target_label = &amp;#34;instance&amp;#34;
    replacement  = &amp;#34;orders_db&amp;#34;
  }
}

prometheus.scrape &amp;#34;orders_db&amp;#34; {
  targets    = discovery.relabel.orders_db.targets
  job_name   = &amp;#34;integrations/db-o11y&amp;#34;
  forward_to = [prometheus.remote_write.metrics_service.receiver]
}

prometheus.remote_write &amp;#34;metrics_service&amp;#34; {
  endpoint {
    url = sys.env(&amp;#34;&amp;lt;GRAFANA_CLOUD_HOSTED_METRICS_URL&amp;gt;&amp;#34;)
    basic_auth {
      username = sys.env(&amp;#34;&amp;lt;GRAFANA_CLOUD_HOSTED_METRICS_ID&amp;gt;&amp;#34;)
      password = sys.env(&amp;#34;&amp;lt;GRAFANA_CLOUD_RW_API_KEY&amp;gt;&amp;#34;)
    }
  }
}

loki.write &amp;#34;logs_service&amp;#34; {
  endpoint {
    url = sys.env(&amp;#34;&amp;lt;GRAFANA_CLOUD_HOSTED_LOGS_URL&amp;gt;&amp;#34;)
    basic_auth {
      username = sys.env(&amp;#34;&amp;lt;GRAFANA_CLOUD_HOSTED_LOGS_ID&amp;gt;&amp;#34;)
      password = sys.env(&amp;#34;&amp;lt;GRAFANA_CLOUD_RW_API_KEY&amp;gt;&amp;#34;)
    }
  }
}&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;GRAFANA_CLOUD_HOSTED_METRICS_URL&amp;gt;&lt;/code&gt;&lt;/em&gt;: The URL for your Grafana Cloud hosted metrics.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;GRAFANA_CLOUD_HOSTED_METRICS_ID&amp;gt;&lt;/code&gt;&lt;/em&gt;: The user ID for your Grafana Cloud hosted metrics.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;GRAFANA_CLOUD_RW_API_KEY&amp;gt;&lt;/code&gt;&lt;/em&gt;: Your Grafana Cloud API key.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;GRAFANA_CLOUD_HOSTED_LOGS_URL&amp;gt;&lt;/code&gt;&lt;/em&gt;: The URL for your Grafana Cloud hosted logs.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;GRAFANA_CLOUD_HOSTED_LOGS_ID&amp;gt;&lt;/code&gt;&lt;/em&gt;: The user ID for your Grafana Cloud hosted logs.&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- START GENERATED COMPATIBLE COMPONENTS --&gt;
&lt;h2 id=&#34;compatible-components&#34;&gt;Compatible components&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;database_observability.mysql&lt;/code&gt; can accept arguments from the following components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Components that export &lt;a href=&#34;../../../compatibility/#targets-exporters&#34;&gt;Targets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Components that export &lt;a href=&#34;../../../compatibility/#loki-logsreceiver-exporters&#34;&gt;Loki &lt;code&gt;LogsReceiver&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;database_observability.mysql&lt;/code&gt; has exports that can be consumed by the following components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Components that consume &lt;a href=&#34;../../../compatibility/#targets-consumers&#34;&gt;Targets&lt;/a&gt;&lt;/li&gt;
&lt;/ul&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;Connecting some components may not be sensible or components may require further configuration to make the connection work correctly.
Refer to the linked documentation for more details.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;!-- END GENERATED COMPATIBLE COMPONENTS --&gt;
]]></content><description>&lt;h1 id="database_observabilitymysql">&lt;code>database_observability.mysql&lt;/code>&lt;/h1>
&lt;p>&lt;code>database_observability.mysql&lt;/code> connects to a MySQL database and collects observability data from the &lt;code>performance_schema&lt;/code> and &lt;code>information_schema&lt;/code>.
The component collects query details, schema information, explain plans, query samples, and lock information.
It forwards this data as log entries to Loki receivers and exports targets for Prometheus scraping.&lt;/p></description></item><item><title>database_observability.postgres</title><link>https://grafana.com/docs/alloy/v1.21/reference/components/database_observability/database_observability.postgres/</link><pubDate>Mon, 19 Oct 2026 11:17:26 +0000</pubDate><guid>https://grafana.com/docs/alloy/v1.21/reference/components/database_observability/database_observability.postgres/</guid><content><![CDATA[&lt;h1 id=&#34;database_observabilitypostgres&#34;&gt;&lt;code&gt;database_observability.postgres&lt;/code&gt;&lt;/h1&gt;
&lt;p&gt;&lt;code&gt;database_observability.postgres&lt;/code&gt; connects to a PostgreSQL database and collects observability data from system catalogs and the &lt;code&gt;pg_stat_statements&lt;/code&gt; extension.
The component collects query details, schema information, explain plans, query samples, and processes PostgreSQL logs.
It forwards this data as log entries to Loki receivers and exports targets for Prometheus scraping.&lt;/p&gt;
&lt;h2 id=&#34;usage&#34;&gt;Usage&lt;/h2&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;database_observability.postgres &amp;#34;&amp;lt;LABEL&amp;gt;&amp;#34; {
  data_source_name = &amp;lt;DATA_SOURCE_NAME&amp;gt;
  forward_to       = [&amp;lt;LOKI_RECEIVERS&amp;gt;]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;p&gt;You can use the following arguments with &lt;code&gt;database_observability.postgres&lt;/code&gt;:&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;data_source_name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;secret&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;https://pkg.go.dev/github.com/lib/pq#hdr-URL_connection_strings-NewConfig&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Data Source Name&lt;/a&gt; for the Postgres server to connect to. Required when no &lt;code&gt;database_instance&lt;/code&gt; blocks are defined.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;forward_to&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(LogsReceiver)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Where to forward log entries after processing.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;targets&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(map(string))&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;List of external targets to scrape for Prometheus metrics.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;disable_collectors&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(string)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;A list of collectors to disable from the default set.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;enable_collectors&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(string)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;A list of collectors to enable on top of the default set.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;exclude_databases&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(string)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;A list of databases to exclude from monitoring.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;[&amp;quot;alloydbadmin&amp;quot;, &amp;quot;alloydbmetadata&amp;quot;, &amp;quot;azure_maintenance&amp;quot;, &amp;quot;azure_sys&amp;quot;, &amp;quot;cloudsqladmin&amp;quot;, &amp;quot;rdsadmin&amp;quot;]&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;exclude_users&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(string)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;A list of users to exclude from monitoring.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;[&amp;quot;azuresu&amp;quot;, &amp;quot;cloudsqladmin&amp;quot;, &amp;quot;db-o11y&amp;quot;, &amp;quot;rdsadmin&amp;quot;]&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;exclude_current_user&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;bool&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Exclude from activity monitoring the user that Alloy uses to connect to the database. The resolved username is automatically added to &lt;code&gt;exclude_users&lt;/code&gt;, if not already present.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;true&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Refer to the &lt;a href=&#34;https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;PostgreSQL documentation&lt;/a&gt; for more information about the format of the connection strings in &lt;code&gt;data_source_name&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;exports&#34;&gt;Exports&lt;/h2&gt;
&lt;p&gt;The following fields are exported and can be referenced by other components:&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;Name&lt;/th&gt;
              &lt;th&gt;Type&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;logs_receiver&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;LogsReceiver&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Receiver for PostgreSQL logs that processes and exports error metrics. Exported in the single-DSN form only.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;logs_receivers&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;map(LogsReceiver)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;One logs receiver per [&lt;code&gt;database_instance&lt;/code&gt;][database_instance] block, keyed by block label. Empty in the single-DSN form.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;targets&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(map(string))&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Targets that can be used to collect metrics from the component.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;The following collectors are configurable:&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;Name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Enabled by default&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;explain_plans&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect query explain plans.&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;table_stats&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect table-level scan statistics.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;index_stats&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect per-index usage statistics.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;query_details&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect queries information.&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;query_samples&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect query samples and wait events information.&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;schema_details&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect schemas, tables, and columns from PostgreSQL system catalogs.&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;blocks&#34;&gt;Blocks&lt;/h2&gt;
&lt;p&gt;You can use the following blocks with &lt;code&gt;database_observability.postgres&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;config-app&#34; style=&#34;--config-tree-row-count: 15;&#34; x3-data=&#34;configVisualizer(&amp;#34;\u003csection class=\&amp;#34;expand-table-wrapper\&amp;#34;\u003e\u003cdiv class=\&amp;#34;button-div\&amp;#34;\u003e\n      \u003cbutton class=\&amp;#34;expand-table-btn\&amp;#34;\u003eExpand table\u003c/button\u003e\n    \u003c/div\u003e\u003cdiv class=\&amp;#34;responsive-table-wrapper\&amp;#34;\u003e\n    \u003ctable\u003e\n      \u003cthead\u003e\n          \u003ctr\u003e\n              \u003cth\u003eBlock\u003c/th\u003e\n              \u003cth\u003eDescription\u003c/th\u003e\n              \u003cth\u003eRequired\u003c/th\u003e\n          \u003c/tr\u003e\n      \u003c/thead\u003e\n      \u003ctbody\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#cloud_provider\&amp;#34;\u003e\u003ccode\u003ecloud_provider\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eProvide Cloud Provider information.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ccode\u003ecloud_provider\u003c/code\u003e \u0026gt; \u003ca href=\&amp;#34;#aws\&amp;#34;\u003e\u003ccode\u003eaws\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eProvide AWS database host information.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ccode\u003ecloud_provider\u003c/code\u003e \u0026gt; \u003ca href=\&amp;#34;#azure\&amp;#34;\u003e\u003ccode\u003eazure\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eProvide Azure database host information.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ccode\u003ecloud_provider\u003c/code\u003e \u0026gt; \u003ca href=\&amp;#34;#gcp\&amp;#34;\u003e\u003ccode\u003egcp\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eProvide GCP database host information.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#database_instance\&amp;#34;\u003e\u003ccode\u003edatabase_instance\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eDefine one database to monitor. Repeat the block to monitor several databases.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ccode\u003edatabase_instance\u003c/code\u003e \u0026gt; \u003ca href=\&amp;#34;#cloud_provider\&amp;#34;\u003e\u003ccode\u003ecloud_provider\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eProvide Cloud Provider information for one database.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ccode\u003edatabase_instance\u003c/code\u003e \u0026gt; \u003ca href=\&amp;#34;#rule\&amp;#34;\u003e\u003ccode\u003erule\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eRelabel the metrics and logs of one database.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#clustering\&amp;#34;\u003e\u003ccode\u003eclustering\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the component for when Alloy is running in clustered mode.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#query_details\&amp;#34;\u003e\u003ccode\u003equery_details\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the queries collector.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#query_samples\&amp;#34;\u003e\u003ccode\u003equery_samples\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the query samples collector.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#schema_details\&amp;#34;\u003e\u003ccode\u003eschema_details\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the schema and table details collector.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#explain_plans\&amp;#34;\u003e\u003ccode\u003eexplain_plans\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the explain plans collector.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#logs\&amp;#34;\u003e\u003ccode\u003elogs\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the logs collector.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#health_check\&amp;#34;\u003e\u003ccode\u003ehealth_check\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the health check collector.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#prometheus_exporter\&amp;#34;\u003e\u003ccode\u003eprometheus_exporter\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the embedded \u003ccode\u003epostgres_exporter\u003c/code\u003e.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n      \u003c/tbody\u003e\n    \u003c/table\u003e\n  \u003c/div\u003e\n\u003c/section\u003e&amp;#34;)&#34;&gt;
  &lt;noscript&gt;
    &lt;div class=&#34;config-app__noscript&#34;&gt;&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Block&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#cloud_provider&#34;&gt;&lt;code&gt;cloud_provider&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Provide Cloud Provider information.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;cloud_provider&lt;/code&gt; &amp;gt; &lt;a href=&#34;#aws&#34;&gt;&lt;code&gt;aws&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Provide AWS database host information.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;cloud_provider&lt;/code&gt; &amp;gt; &lt;a href=&#34;#azure&#34;&gt;&lt;code&gt;azure&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Provide Azure database host information.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;cloud_provider&lt;/code&gt; &amp;gt; &lt;a href=&#34;#gcp&#34;&gt;&lt;code&gt;gcp&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Provide GCP database host information.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#database_instance&#34;&gt;&lt;code&gt;database_instance&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Define one database to monitor. Repeat the block to monitor several databases.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;database_instance&lt;/code&gt; &amp;gt; &lt;a href=&#34;#cloud_provider&#34;&gt;&lt;code&gt;cloud_provider&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Provide Cloud Provider information for one database.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;database_instance&lt;/code&gt; &amp;gt; &lt;a href=&#34;#rule&#34;&gt;&lt;code&gt;rule&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Relabel the metrics and logs of one database.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#clustering&#34;&gt;&lt;code&gt;clustering&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the component for when Alloy is running in clustered mode.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#query_details&#34;&gt;&lt;code&gt;query_details&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the queries collector.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#query_samples&#34;&gt;&lt;code&gt;query_samples&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the query samples collector.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#schema_details&#34;&gt;&lt;code&gt;schema_details&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the schema and table details collector.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#explain_plans&#34;&gt;&lt;code&gt;explain_plans&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the explain plans collector.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#logs&#34;&gt;&lt;code&gt;logs&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the logs collector.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#health_check&#34;&gt;&lt;code&gt;health_check&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the health check collector.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#prometheus_exporter&#34;&gt;&lt;code&gt;prometheus_exporter&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the embedded &lt;code&gt;postgres_exporter&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;/div&gt;
  &lt;/noscript&gt;
  &lt;main class=&#34;config-app__main&#34;&gt;
    &lt;template x3-if=&#34;flatBlocks.length === 0&#34;&gt;
      &lt;div class=&#34;empty-state&#34;&gt;
        &lt;div class=&#34;empty-state__icon&#34; x3-html=&#34;icons.AlertCircle&#34;&gt;&lt;/div&gt;
        &lt;p&gt;No valid configuration blocks found.&lt;/p&gt;
      &lt;/div&gt;
    &lt;/template&gt;

    &lt;template x3-if=&#34;flatBlocks.length &gt; 0&#34;&gt;
      &lt;div class=&#34;config-tree&#34;&gt;
        &lt;div class=&#34;config-tree__toolbar&#34;&gt;
          &lt;div class=&#34;config-tree__title&#34;&gt;&lt;/div&gt;
          &lt;button
            class=&#34;tree-explorer__button w-130 text-right&#34;
            x3-on:click=&#34;toggleExpandAll&#34;
            x3-bind:title=&#34;allExpanded ? &#39;Collapse all&#39; : &#39;Expand all&#39;&#34;
          &gt;
            &lt;span x3-text=&#34;allExpanded ? &#39;Collapse all&#39; : &#39;Expand all&#39;&#34;&gt;&lt;/span&gt;
            &lt;svg class=&#34;api-icon&#34; viewBox=&#34;0 0 24 24&#34;&gt;
              &lt;path x3-show=&#34;!allExpanded&#34; d=&#34;m6 9 6 6 6-6&#34; /&gt;
              &lt;path x3-show=&#34;allExpanded&#34; d=&#34;m18 15-6-6-6 6&#34; /&gt;
            &lt;/svg&gt;
          &lt;/button&gt;
        &lt;/div&gt;

        &lt;div class=&#34;nodes-container&#34;&gt;
          &lt;template x3-for=&#34;block in flatBlocks&#34; x3-bind:key=&#34;block.id&#34;&gt;
            &lt;div class=&#34;node&#34; x3-bind:class=&#34;isNodeVisible(block) ? &#39;node--visible&#39; : &#39;node--hidden&#39;&#34;&gt;
              &lt;div
                class=&#34;node__row&#34;
                x3-bind:class=&#34;getRowClass(block)&#34;
                x3-bind:style=&#34;`padding-left: ${block.level * 24 &#43; 16}px`&#34;
                x3-on:click=&#34;toggleNode(block.id)&#34;
              &gt;
                &lt;div class=&#34;node__left&#34;&gt;
                  &lt;div class=&#34;node__indicator&#34;&gt;
                    &lt;template x3-if=&#34;block.hasChildren&#34;&gt;
                      &lt;button type=&#34;button&#34; class=&#34;node__toggle&#34; x3-on:click.stop=&#34;toggleNode(block.id)&#34;&gt;
                        &lt;div
                          class=&#34;node__toggle-icon&#34;
                          x3-bind:class=&#34;block.expanded ? &#39;node__toggle-icon--expanded&#39; : &#39;&#39;&#34;
                          x3-html=&#34;icons.ChevronDown&#34;
                        &gt;&lt;/div&gt;
                      &lt;/button&gt;
                    &lt;/template&gt;
                    &lt;template x3-if=&#34;!block.hasChildren&#34;&gt;
                      &lt;div class=&#34;node__toggle-spacer&#34;&gt;&lt;/div&gt;
                    &lt;/template&gt;
                  &lt;/div&gt;

                  &lt;div class=&#34;node__content&#34;&gt;
                    &lt;div
                      class=&#34;node__title prose&#34;
                      x3-bind:class=&#34;block.level === 0 ? &#39;node__title--root&#39; : &#39;node__title--nested&#39;&#34;
                      x3-html=&#34;block.displayName&#34;
                    &gt;&lt;/div&gt;
                    &lt;div class=&#34;node__description body-xsmall&#34; x3-html=&#34;block.description&#34;&gt;&lt;/div&gt;
                  &lt;/div&gt;
                &lt;/div&gt;

                &lt;div class=&#34;node__meta&#34;&gt;
                  &lt;span
                    class=&#34;badge&#34;
                    x3-bind:class=&#34;block.required ? &#39;badge--required&#39; : &#39;badge--optional&#39;&#34;
                    x3-text=&#34;block.required ? &#39;Required&#39; : &#39;Optional&#39;&#34;
                  &gt;&lt;/span&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/template&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/template&gt;
  &lt;/main&gt;
&lt;/div&gt;

&lt;h3 id=&#34;cloud_provider&#34;&gt;&lt;code&gt;cloud_provider&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;cloud_provider&lt;/code&gt; block has no attributes.
It contains zero or one of the &lt;a href=&#34;#aws&#34;&gt;&lt;code&gt;aws&lt;/code&gt;&lt;/a&gt;, &lt;a href=&#34;#azure&#34;&gt;&lt;code&gt;azure&lt;/code&gt;&lt;/a&gt;, or &lt;a href=&#34;#gcp&#34;&gt;&lt;code&gt;gcp&lt;/code&gt;&lt;/a&gt; blocks.
You use the &lt;code&gt;cloud_provider&lt;/code&gt; block to provide information related to the cloud provider that hosts the database under observation.
This information is appended as labels to the collected metrics.
The labels make it easier for you to filter and group your metrics.&lt;/p&gt;
&lt;h3 id=&#34;aws&#34;&gt;&lt;code&gt;aws&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;aws&lt;/code&gt; block supplies the &lt;a href=&#34;https://docs.aws.amazon.com/IAM/latest/UserGuide/reference-arns.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;ARN&lt;/a&gt; identifier for the database being monitored.&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;arn&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The ARN associated with the database under observation.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;azure&#34;&gt;&lt;code&gt;azure&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;azure&lt;/code&gt; block supplies the identifying information for the database being monitored.&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;subscription_id&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The Subscription ID for your Azure account.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;resource_group&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The Resource Group that holds the database resource.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;server_name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The database server name, for example &lt;code&gt;orders-db&lt;/code&gt; for the host &lt;code&gt;orders-db.postgres.database.azure.com&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;gcp&#34;&gt;&lt;code&gt;gcp&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;gcp&lt;/code&gt; block supplies the identifying information for the GCP Cloud SQL database being monitored.&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;connection_name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The Cloud SQL instance connection name in the format &lt;code&gt;project:region:instance&lt;/code&gt;, for example &lt;code&gt;my-project:us-central1:my-db&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;database_instance&#34;&gt;&lt;code&gt;database_instance&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;database_instance&lt;/code&gt; block defines one database server to monitor.
Repeat the block to monitor several databases with a single component.
The block label must be unique across &lt;code&gt;database_instance&lt;/code&gt; blocks and identifies the database in the component&amp;rsquo;s metrics endpoint path and in the &lt;code&gt;logs_receivers&lt;/code&gt; export.
Each &lt;code&gt;database_instance&lt;/code&gt; block must also point to a distinct server: two blocks that resolve to the same host, port, and database name are rejected.&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;data_source_name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;secret&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;https://pkg.go.dev/github.com/lib/pq#hdr-URL_connection_strings-NewConfig&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Data Source Name&lt;/a&gt; for the Postgres server to connect to.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Each &lt;code&gt;database_instance&lt;/code&gt; block can also contain a [&lt;code&gt;cloud_provider&lt;/code&gt;][cloud_provider] block that applies to that database only, and [&lt;code&gt;rule&lt;/code&gt;][rule] blocks that relabel the metrics and logs of that database only.&lt;/p&gt;
&lt;p&gt;The component always embeds a &lt;code&gt;postgres_exporter&lt;/code&gt; for each &lt;code&gt;database_instance&lt;/code&gt; block and serves its metrics on the block&amp;rsquo;s metrics path.
Use the [&lt;code&gt;prometheus_exporter&lt;/code&gt;][prometheus_exporter] block to configure it.
External exporter targets are only supported in the top-level single-DSN form.&lt;/p&gt;
&lt;p&gt;When you define &lt;code&gt;database_instance&lt;/code&gt; blocks, don&amp;rsquo;t set the top-level &lt;code&gt;data_source_name&lt;/code&gt;, &lt;code&gt;targets&lt;/code&gt;, and &lt;code&gt;cloud_provider&lt;/code&gt; arguments.
They&amp;rsquo;re mutually exclusive with &lt;code&gt;database_instance&lt;/code&gt; blocks.
All other arguments and blocks, such as collector settings and &lt;code&gt;prometheus_exporter&lt;/code&gt;, apply to every configured database.&lt;/p&gt;
&lt;p&gt;The metrics for each database are served on a separate &lt;code&gt;/db/&amp;lt;LABEL&amp;gt;/metrics&lt;/code&gt; path under the component&amp;rsquo;s HTTP endpoint, and the exported targets point to the corresponding path.
When you don&amp;rsquo;t define &lt;code&gt;database_instance&lt;/code&gt; blocks, the component serves metrics on its historical &lt;code&gt;/metrics&lt;/code&gt; path.
The metrics endpoints are served exactly at those paths: requests to any other path under the component&amp;rsquo;s HTTP endpoint return HTTP 404.&lt;/p&gt;
&lt;p&gt;Each database also gets its own logs receiver in the &lt;code&gt;logs_receivers&lt;/code&gt; export, keyed by the block label.
Forward each database&amp;rsquo;s PostgreSQL logs to its own receiver so log-derived error metrics are attributed to the right database.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;

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

  database_instance &amp;#34;orders&amp;#34; {
    data_source_name = sys.env(&amp;#34;ORDERS_DSN&amp;#34;)

    cloud_provider {
      aws {
        arn = &amp;#34;orders-rds-db-arn&amp;#34;
      }
    }

    rule {
      target_label = &amp;#34;environment&amp;#34;
      replacement  = &amp;#34;production&amp;#34;
    }
  }

  database_instance &amp;#34;billing&amp;#34; {
    data_source_name = sys.env(&amp;#34;BILLING_DSN&amp;#34;)

    rule {
      target_label = &amp;#34;environment&amp;#34;
      replacement  = &amp;#34;staging&amp;#34;
    }
  }
}

loki.source.file &amp;#34;orders_db_logs&amp;#34; {
  targets    = local.file_match.orders_db_logs.targets
  forward_to = [database_observability.postgres.pool.logs_receivers[&amp;#34;orders&amp;#34;]]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In this example, the metrics and logs of the &lt;code&gt;orders&lt;/code&gt; database carry &lt;code&gt;environment=&amp;quot;production&amp;quot;&lt;/code&gt;, and those of the &lt;code&gt;billing&lt;/code&gt; database carry &lt;code&gt;environment=&amp;quot;staging&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The component doesn&amp;rsquo;t forward the raw PostgreSQL log lines it receives on &lt;code&gt;logs_receivers&lt;/code&gt;.
It reads them to derive error-message entries, and those derived entries are what the &lt;code&gt;rule&lt;/code&gt; blocks relabel.
Deriving them requires [&lt;code&gt;logs.enable_error_logs_processing&lt;/code&gt;][logs], which is disabled by default.&lt;/p&gt;
&lt;h3 id=&#34;rule&#34;&gt;&lt;code&gt;rule&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;rule&lt;/code&gt; block relabels the metrics and the logs of the &lt;code&gt;database_instance&lt;/code&gt; block that contains it.
Use it to tell the data of each monitored database apart, for example by environment, team, or tier.&lt;/p&gt;


&lt;div data-shared=&#34;reference/components/rule-block-database-observability.md&#34;&gt;
            &lt;p&gt;The &lt;code&gt;rule&lt;/code&gt; block defines a relabeling rule applied to the metrics and the logs of a single monitored database.
If you define more than one &lt;code&gt;rule&lt;/code&gt; block, the rules are applied in top-down order, after the labels the component sets itself, so a rule can read those labels with &lt;code&gt;source_labels&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It takes the same arguments as the 
    &lt;a href=&#34;/docs/alloy/v1.21/reference/components/prometheus/prometheus.relabel/#rule&#34;&gt;&lt;code&gt;rule&lt;/code&gt; block&lt;/a&gt; used elsewhere in Alloy, in a restricted form: because one rule set applies to two signal paths, it supports the labelling actions only, and it can&amp;rsquo;t overwrite most of the labels the component sets.
Alloy refuses to load a configuration containing a rule that breaks either restriction, so such a rule is never silently ignored.&lt;/p&gt;
&lt;p&gt;Two further constraints are specific to a &lt;code&gt;database_instance&lt;/code&gt; block:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;target_label&lt;/code&gt; must be a literal label name&lt;/strong&gt;: Alloy checks it against the reserved labels when it loads the configuration, so it can&amp;rsquo;t contain a capture group reference.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;hashmod&lt;/code&gt; requires &lt;code&gt;source_labels&lt;/code&gt;, and can&amp;rsquo;t target &lt;code&gt;instance&lt;/code&gt;&lt;/strong&gt;: hashing the empty value gives every database the same result, and hashing into &lt;code&gt;instance&lt;/code&gt; buckets several databases onto one value even when the source is present.&lt;/li&gt;
&lt;/ul&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;A relabeling rule that computes an empty value &lt;em&gt;removes&lt;/em&gt; its target label instead of setting it, and the default &lt;code&gt;replacement&lt;/code&gt; of &lt;code&gt;&amp;quot;$1&amp;quot;&lt;/code&gt; computes an empty value when a rule has no &lt;code&gt;source_labels&lt;/code&gt;.
So &lt;code&gt;rule { target_label = &amp;quot;environment&amp;quot; }&lt;/code&gt; removes &lt;code&gt;environment&lt;/code&gt; rather than setting it, and Alloy rejects it.
Always set &lt;code&gt;replacement&lt;/code&gt; alongside a &lt;code&gt;target_label&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Alloy can only reject such a rule where the outcome is certain.
A rule that reads &lt;code&gt;source_labels&lt;/code&gt; depends on the labels present at runtime, so a missing or misspelled source label still removes the target label, except for the reserved labels and &lt;code&gt;instance&lt;/code&gt;, which keep their previous value.
Only removal is prevented: a rule that computes a &lt;em&gt;non-empty&lt;/em&gt; value still overwrites those labels, which is why &lt;code&gt;hashmod&lt;/code&gt; can&amp;rsquo;t target &lt;code&gt;instance&lt;/code&gt; at all.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;You can use the &lt;code&gt;hashmod&lt;/code&gt;, &lt;code&gt;labeldrop&lt;/code&gt;, &lt;code&gt;lowercase&lt;/code&gt;, &lt;code&gt;replace&lt;/code&gt;, and &lt;code&gt;uppercase&lt;/code&gt; actions.
The rest aren&amp;rsquo;t supported:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;drop&lt;/code&gt;, &lt;code&gt;dropequal&lt;/code&gt;, &lt;code&gt;keep&lt;/code&gt;, and &lt;code&gt;keepequal&lt;/code&gt; filter rather than label, and filtering means two different things on the two signal paths. Dropping a metrics target stops the database exporting metrics entirely, whereas dropping a log entry discards one line. To filter one database&amp;rsquo;s logs, use a 
    &lt;a href=&#34;/docs/alloy/v1.21/reference/components/loki/loki.relabel/&#34;&gt;&lt;code&gt;loki.relabel&lt;/code&gt;&lt;/a&gt; component on the receiver named in &lt;code&gt;forward_to&lt;/code&gt;, with a &lt;code&gt;drop&lt;/code&gt; rule that matches that database&amp;rsquo;s &lt;code&gt;instance&lt;/code&gt; or &lt;code&gt;server_id&lt;/code&gt;. Every database the component monitors forwards to the same receivers, so the rule has to identify the one it applies to. To filter one database&amp;rsquo;s metrics, use a 
    &lt;a href=&#34;/docs/alloy/v1.21/reference/components/discovery/discovery.relabel/&#34;&gt;&lt;code&gt;discovery.relabel&lt;/code&gt;&lt;/a&gt; component on the component&amp;rsquo;s exported targets.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;labelmap&lt;/code&gt; builds label names from &lt;code&gt;replacement&lt;/code&gt; at runtime, so Alloy can&amp;rsquo;t check them against the reserved labels when it loads the configuration.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;labelkeep&lt;/code&gt; removes every label its &lt;code&gt;regex&lt;/code&gt; doesn&amp;rsquo;t match, so a rule that preserves the reserved labels would have to match all of them. Use &lt;code&gt;labeldrop&lt;/code&gt; to remove specific labels instead.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Because the rules run after the component&amp;rsquo;s own labels, and those are protected, a &lt;code&gt;labeldrop&lt;/code&gt; rule can only remove a label that an earlier rule in the same block created.&lt;/p&gt;
&lt;h4 id=&#34;reserved-labels&#34;&gt;Reserved labels&lt;/h4&gt;
&lt;p&gt;A rule can&amp;rsquo;t write to the following labels, and a &lt;code&gt;labeldrop&lt;/code&gt; regular expression can&amp;rsquo;t match them:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Both metrics and logs&lt;/strong&gt;: &lt;code&gt;job&lt;/code&gt; and &lt;code&gt;server_id&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Logs only&lt;/strong&gt;: &lt;code&gt;engine&lt;/code&gt; and &lt;code&gt;op&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Metrics only&lt;/strong&gt;: &lt;code&gt;provider_name&lt;/code&gt;, &lt;code&gt;provider_region&lt;/code&gt;, &lt;code&gt;provider_account&lt;/code&gt;, &lt;code&gt;__address__&lt;/code&gt;, &lt;code&gt;__scheme__&lt;/code&gt;, and &lt;code&gt;__metrics_path__&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This applies to &lt;code&gt;rule&lt;/code&gt; blocks only.
A downstream &lt;code&gt;discovery.relabel&lt;/code&gt; or &lt;code&gt;loki.relabel&lt;/code&gt; component can still overwrite any of them, but it applies to every database the component monitors rather than one.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;instance&lt;/code&gt; label is a special case: a rule can rewrite its value, which is a common reason to use a &lt;code&gt;rule&lt;/code&gt; block, because a friendly name such as &lt;code&gt;orders_db&lt;/code&gt; then applies to that database&amp;rsquo;s metrics and logs together.
A rule can&amp;rsquo;t remove it, because metrics and logs are correlated on it, and because an empty &lt;code&gt;instance&lt;/code&gt; on a metrics target makes Prometheus fill it in from &lt;code&gt;__address__&lt;/code&gt;, which every database in one component shares, collapsing them all onto one series.&lt;/p&gt;
&lt;p&gt;For the same reason, two &lt;code&gt;database_instance&lt;/code&gt; blocks can&amp;rsquo;t rewrite &lt;code&gt;instance&lt;/code&gt; to the same value.
Alloy rejects that when both values are fixed in the configuration, but it can&amp;rsquo;t when the value comes from a label the databases share: &lt;code&gt;source_labels = [&amp;quot;job&amp;quot;]&lt;/code&gt; gives every database the same &lt;code&gt;instance&lt;/code&gt;, since they all carry the same &lt;code&gt;job&lt;/code&gt;.
Derive &lt;code&gt;instance&lt;/code&gt; from something that differs per database, or set a literal value in each block.&lt;/p&gt;
&lt;h4 id=&#34;labels-set-on-only-one-signal-path&#34;&gt;Labels set on only one signal path&lt;/h4&gt;
&lt;p&gt;Some of the labels above exist on one signal path and not the other, and a rule that reads one with &lt;code&gt;source_labels&lt;/code&gt; behaves differently on each path: where the label is absent the rule computes an empty value, which &lt;em&gt;removes&lt;/em&gt; its &lt;code&gt;target_label&lt;/code&gt; rather than setting it to an empty string.&lt;/p&gt;
&lt;p&gt;A rule reading &lt;code&gt;provider_region&lt;/code&gt;, which a database with a &lt;a href=&#34;#cloud_provider&#34;&gt;&lt;code&gt;cloud_provider&lt;/code&gt;&lt;/a&gt; block carries on its metrics targets but not on its log entries, sets &lt;code&gt;region&lt;/code&gt; on that database&amp;rsquo;s metrics and removes &lt;code&gt;region&lt;/code&gt; from its logs.
Reading a logs-only label such as &lt;code&gt;op&lt;/code&gt; does the same in reverse.
Only &lt;code&gt;job&lt;/code&gt;, &lt;code&gt;server_id&lt;/code&gt;, and &lt;code&gt;instance&lt;/code&gt; are set on both paths, so prefer those as &lt;code&gt;source_labels&lt;/code&gt;, or a label an earlier rule in the same block created.&lt;/p&gt;
&lt;/div&gt;

        
&lt;h3 id=&#34;clustering&#34;&gt;&lt;code&gt;clustering&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;enabled&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;bool&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Enables distributing databases with other cluster nodes.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;When Alloy is &lt;a href=&#34;../../../../get-started/clustering/&#34;&gt;using clustering&lt;/a&gt;, and &lt;code&gt;enabled&lt;/code&gt; is set to true, then this &lt;code&gt;database_observability.postgres&lt;/code&gt; component instance opts-in to distributing its configured databases between all cluster nodes.&lt;/p&gt;
&lt;p&gt;Clustering assumes that all cluster nodes are running with the same configuration file.
All component instances opting in to clustering use the instance key of each configured database, &lt;code&gt;postgresql://&amp;lt;host&amp;gt;:&amp;lt;port&amp;gt;/&amp;lt;dbname&amp;gt;&lt;/code&gt;, and a consistent hashing algorithm to determine ownership of each database between the cluster peers.
Each peer then only collects from the subset of databases it&amp;rsquo;s responsible for, and only exports the targets of those databases, so &lt;code&gt;prometheus.scrape&lt;/code&gt; components on the same node scrape exactly the databases the node owns.
When a node joins or leaves the cluster, every peer recalculates ownership: expect a short gap or a brief duplicate collection for a database while its ownership moves.
While the cluster isn&amp;rsquo;t yet ready to admit traffic, for example while it&amp;rsquo;s still forming and waiting for the minimum cluster size, the component doesn&amp;rsquo;t collect from any database.&lt;/p&gt;
&lt;p&gt;Every node exports the logs receivers of all configured databases, whether it owns them or not: a node that doesn&amp;rsquo;t own a database accepts and discards entries sent to that database&amp;rsquo;s receiver.
Log pipelines that forward PostgreSQL logs to the exported receivers therefore work unchanged on every node, but only the owning node processes the logs into error metrics.&lt;/p&gt;
&lt;p&gt;Clustering is also useful with a single database: when several cluster nodes run an identical configuration, exactly one node collects from the database at a time, which gives you a highly available setup without duplicate collection.&lt;/p&gt;
&lt;p&gt;If Alloy is &lt;em&gt;not&lt;/em&gt; running in clustered mode, then the block is a no-op and &lt;code&gt;database_observability.postgres&lt;/code&gt; collects from every configured database.&lt;/p&gt;
&lt;h3 id=&#34;query_details&#34;&gt;&lt;code&gt;query_details&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;collect_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How frequently to collect information from database.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;1m&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;statements_limit&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;integer&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Max number of recent queries to collect details for.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;100&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;query_samples&#34;&gt;&lt;code&gt;query_samples&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;collect_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How frequently to collect information from database.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;10s&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;disable_query_redaction&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;bool&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect unredacted SQL query text (might include parameters).&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;exclude_current_user&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;bool&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Deprecated. Use the top-level &lt;code&gt;exclude_current_user&lt;/code&gt; argument instead. This setting takes precedence over the top-level setting.&lt;/td&gt;
              &lt;td&gt;(unset)&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;enable_pre_classified_wait_events&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;boolean&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;When &lt;code&gt;true&lt;/code&gt;, emits telemetry data with pre-classified wait event information.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;schema_details&#34;&gt;&lt;code&gt;schema_details&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;collect_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How frequently to collect information from database.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;1m&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;cache_enabled&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;boolean&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Deprecated. Whether to enable caching of table definitions.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;true&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;cache_size&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;integer&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Deprecated. Cache size.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;256&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;cache_ttl&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Deprecated. Cache TTL.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;10m&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;The &lt;code&gt;cache_enabled&lt;/code&gt;, &lt;code&gt;cache_size&lt;/code&gt;, and &lt;code&gt;cache_ttl&lt;/code&gt; settings are deprecated: they are accepted for backward compatibility, but ignored.&lt;/p&gt;
&lt;h3 id=&#34;explain_plans&#34;&gt;&lt;code&gt;explain_plans&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;collect_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How frequently to collect information from database.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;1m&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;per_collect_ratio&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;float64&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The ratio of queries to collect explain plans for.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;1.0&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;logs&#34;&gt;&lt;code&gt;logs&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;enable_error_logs_processing&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;bool&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Emit per-query error telemetry by pairing error and statement log lines.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;The &lt;code&gt;logs&lt;/code&gt; collector is always enabled and counts server errors from the PostgreSQL logs forwarded to &lt;code&gt;logs_receiver&lt;/code&gt;. When &lt;code&gt;enable_error_logs_processing&lt;/code&gt; is &lt;code&gt;true&lt;/code&gt;, the collector additionally emits per-query error telemetry that associates each error with the query that caused it.&lt;/p&gt;
&lt;h3 id=&#34;health_check&#34;&gt;&lt;code&gt;health_check&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;collect_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How frequently to collect information from database.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;1h&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;prometheus_exporter&#34;&gt;&lt;code&gt;prometheus_exporter&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;prometheus_exporter&lt;/code&gt; block configures the embedded postgres_exporter scrapers.
The &lt;code&gt;data_source_name&lt;/code&gt; is inherited from the parent block.&lt;/p&gt;
&lt;p&gt;Refer to &lt;a href=&#34;../../prometheus/prometheus.exporter.postgres/&#34;&gt;&lt;code&gt;prometheus.exporter.postgres&lt;/code&gt;&lt;/a&gt; docs for the full list of supported arguments and sub-blocks.&lt;/p&gt;
&lt;h2 id=&#34;logs-collector&#34;&gt;&lt;code&gt;logs&lt;/code&gt; collector&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;logs&lt;/code&gt; collector processes PostgreSQL logs received through the &lt;code&gt;logs_receiver&lt;/code&gt; entry point. It counts server errors and exposes them as a Prometheus metric on the component&amp;rsquo;s metrics endpoint. When &lt;a href=&#34;#logs&#34;&gt;&lt;code&gt;enable_error_logs_processing&lt;/code&gt;&lt;/a&gt; is &lt;code&gt;true&lt;/code&gt;, it also emits per-query error telemetry as Loki log entries, so each error can be associated with the query that caused it.
When you define [&lt;code&gt;database_instance&lt;/code&gt;][database_instance] blocks, each database has its own entry point in the &lt;code&gt;logs_receivers&lt;/code&gt; export instead, keyed by block label.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;logs_receiver&lt;/code&gt; entry point must be fed by &lt;code&gt;loki&lt;/code&gt; log source components, for example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;loki.source.file&lt;/code&gt;: to read and process PostgreSQL log files from a self-managed database instance&lt;/li&gt;
&lt;li&gt;&lt;code&gt;otelcol.receiver.awscloudwatch&lt;/code&gt; and &lt;code&gt;otelcol.exporter.loki&lt;/code&gt;: to read and process CloudWatch Logs for an AWS RDS instance&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;PostgreSQL must be configured with a specific &lt;code&gt;log_line_prefix&lt;/code&gt; so the collector can parse the logs.&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;Refer to the &lt;a href=&#34;/docs/grafana-cloud/monitor-applications/database-observability/set-up/postgres/&#34;&gt;PostgreSQL setup documentation&lt;/a&gt; for the required &lt;code&gt;log_line_prefix&lt;/code&gt; and detailed log configuration options.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;example&#34;&gt;Example&lt;/h2&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;database_observability.postgres &amp;#34;orders_db&amp;#34; {
  data_source_name = &amp;#34;postgres://user:pass@localhost:5432/dbname&amp;#34;
  forward_to       = [loki.relabel.orders_db.receiver]
  targets          = prometheus.exporter.postgres.orders_db.targets

  // Enable per-query error telemetry from the processed PostgreSQL logs.
  logs {
    enable_error_logs_processing = true
  }
}

prometheus.exporter.postgres &amp;#34;orders_db&amp;#34; {
  data_source_name   = &amp;#34;postgres://user:pass@localhost:5432/dbname&amp;#34;
  enabled_collectors = [&amp;#34;stat_statements&amp;#34;]
}

// OPTIONAL: read PostgreSQL log files and forward to logs collector
loki.source.file &amp;#34;postgres_logs&amp;#34; {
  targets = [{
    __path__ = &amp;#34;/var/log/postgresql/postgresql-*.log&amp;#34;,
    job      = &amp;#34;postgres-logs&amp;#34;,
  }]

  forward_to = [database_observability.postgres.orders_db.logs_receiver]
}

loki.relabel &amp;#34;orders_db&amp;#34; {
  forward_to = [loki.write.logs_service.receiver]
  rule {
    target_label = &amp;#34;job&amp;#34;
    replacement  = &amp;#34;integrations/db-o11y&amp;#34;
  }
  rule {
    target_label = &amp;#34;instance&amp;#34;
    replacement  = &amp;#34;orders_db&amp;#34;
  }
}

discovery.relabel &amp;#34;orders_db&amp;#34; {
  targets = database_observability.postgres.orders_db.targets

  rule {
    target_label = &amp;#34;job&amp;#34;
    replacement  = &amp;#34;integrations/db-o11y&amp;#34;
  }
  rule {
    target_label = &amp;#34;instance&amp;#34;
    replacement  = &amp;#34;orders_db&amp;#34;
  }
}

prometheus.scrape &amp;#34;orders_db&amp;#34; {
  targets    = discovery.relabel.orders_db.targets
  job_name   = &amp;#34;integrations/db-o11y&amp;#34;
  forward_to = [prometheus.remote_write.metrics_service.receiver]
}

prometheus.remote_write &amp;#34;metrics_service&amp;#34; {
  endpoint {
    url = sys.env(&amp;#34;&amp;lt;GRAFANA_CLOUD_HOSTED_METRICS_URL&amp;gt;&amp;#34;)
    basic_auth {
      username = sys.env(&amp;#34;&amp;lt;GRAFANA_CLOUD_HOSTED_METRICS_ID&amp;gt;&amp;#34;)
      password = sys.env(&amp;#34;&amp;lt;GRAFANA_CLOUD_RW_API_KEY&amp;gt;&amp;#34;)
    }
  }
}

loki.write &amp;#34;logs_service&amp;#34; {
  endpoint {
    url = sys.env(&amp;#34;&amp;lt;GRAFANA_CLOUD_HOSTED_LOGS_URL&amp;gt;&amp;#34;)
    basic_auth {
      username = sys.env(&amp;#34;&amp;lt;GRAFANA_CLOUD_HOSTED_LOGS_ID&amp;gt;&amp;#34;)
      password = sys.env(&amp;#34;&amp;lt;GRAFANA_CLOUD_RW_API_KEY&amp;gt;&amp;#34;)
    }
  }
}&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;GRAFANA_CLOUD_HOSTED_METRICS_URL&amp;gt;&lt;/code&gt;&lt;/em&gt;: The URL for your Grafana Cloud hosted metrics.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;GRAFANA_CLOUD_HOSTED_METRICS_ID&amp;gt;&lt;/code&gt;&lt;/em&gt;: The user ID for your Grafana Cloud hosted metrics.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;GRAFANA_CLOUD_RW_API_KEY&amp;gt;&lt;/code&gt;&lt;/em&gt;: Your Grafana Cloud API key.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;GRAFANA_CLOUD_HOSTED_LOGS_URL&amp;gt;&lt;/code&gt;&lt;/em&gt;: The URL for your Grafana Cloud hosted logs.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;GRAFANA_CLOUD_HOSTED_LOGS_ID&amp;gt;&lt;/code&gt;&lt;/em&gt;: The user ID for your Grafana Cloud hosted logs.&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- START GENERATED COMPATIBLE COMPONENTS --&gt;
&lt;h2 id=&#34;compatible-components&#34;&gt;Compatible components&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;database_observability.postgres&lt;/code&gt; can accept arguments from the following components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Components that export &lt;a href=&#34;../../../compatibility/#targets-exporters&#34;&gt;Targets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Components that export &lt;a href=&#34;../../../compatibility/#loki-logsreceiver-exporters&#34;&gt;Loki &lt;code&gt;LogsReceiver&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;database_observability.postgres&lt;/code&gt; has exports that can be consumed by the following components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Components that consume &lt;a href=&#34;../../../compatibility/#targets-consumers&#34;&gt;Targets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Components that consume &lt;a href=&#34;../../../compatibility/#loki-logsreceiver-consumers&#34;&gt;Loki &lt;code&gt;LogsReceiver&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&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;Connecting some components may not be sensible or components may require further configuration to make the connection work correctly.
Refer to the linked documentation for more details.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;!-- END GENERATED COMPATIBLE COMPONENTS --&gt;
]]></content><description>&lt;h1 id="database_observabilitypostgres">&lt;code>database_observability.postgres&lt;/code>&lt;/h1>
&lt;p>&lt;code>database_observability.postgres&lt;/code> connects to a PostgreSQL database and collects observability data from system catalogs and the &lt;code>pg_stat_statements&lt;/code> extension.
The component collects query details, schema information, explain plans, query samples, and processes PostgreSQL logs.
It forwards this data as log entries to Loki receivers and exports targets for Prometheus scraping.&lt;/p></description></item><item><title>database_observability.sql_server</title><link>https://grafana.com/docs/alloy/v1.21/reference/components/database_observability/database_observability.sql_server/</link><pubDate>Mon, 19 Oct 2026 11:17:26 +0000</pubDate><guid>https://grafana.com/docs/alloy/v1.21/reference/components/database_observability/database_observability.sql_server/</guid><content><![CDATA[&lt;h1 id=&#34;database_observabilitysql_server&#34;&gt;&lt;code&gt;database_observability.sql_server&lt;/code&gt;&lt;/h1&gt;


&lt;div data-shared=&#34;stability/experimental.md&#34;&gt;
            &lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;EXPERIMENTAL&lt;/strong&gt;: This is an &lt;a href=&#34;/docs/release-life-cycle/&#34;&gt;experimental&lt;/a&gt; component.
Experimental components are subject to frequent breaking changes, and may be removed with no equivalent replacement.
To enable and use an experimental component, you must set the &lt;code&gt;stability.level&lt;/code&gt; 
    &lt;a href=&#34;/docs/alloy/v1.21/reference/cli/run/&#34;&gt;flag&lt;/a&gt; to &lt;code&gt;experimental&lt;/code&gt;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;/div&gt;

        
&lt;p&gt;&lt;code&gt;database_observability.sql_server&lt;/code&gt; connects to a Microsoft SQL Server instance and collects observability data across every accessible user database on that instance.
The component forwards this data as log entries to Loki receivers and exports targets for Prometheus scraping.&lt;/p&gt;
&lt;h2 id=&#34;usage&#34;&gt;Usage&lt;/h2&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;database_observability.sql_server &amp;#34;&amp;lt;LABEL&amp;gt;&amp;#34; {
  data_source_name = &amp;lt;DATA_SOURCE_NAME&amp;gt;
  forward_to       = [&amp;lt;LOKI_RECEIVERS&amp;gt;]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;p&gt;You can use the following arguments with &lt;code&gt;database_observability.sql_server&lt;/code&gt;:&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;data_source_name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;secret&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;https://github.com/microsoft/go-mssqldb#connection-parameters-and-dsn&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Data Source Name&lt;/a&gt; for the SQL Server instance to connect to. Required when no &lt;code&gt;database_instance&lt;/code&gt; blocks are defined.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;forward_to&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(LogsReceiver)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Where to forward log entries after processing.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;targets&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(map(string))&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;List of external targets to scrape.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;disable_collectors&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(string)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;A list of collectors to disable from the default set.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;enable_collectors&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(string)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;A list of collectors to enable on top of the default set.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;exclude_current_user&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;bool&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Exclude query samples from sessions opened with the login that Alloy uses.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;true&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;exclude_schemas&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(string)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;A list of schemas to exclude from monitoring, on top of the always-excluded system schemas &lt;code&gt;sys&lt;/code&gt; and &lt;code&gt;information_schema&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;[&amp;quot;alloydbadmin&amp;quot;, &amp;quot;alloydbmetadata&amp;quot;, &amp;quot;azure_maintenance&amp;quot;, &amp;quot;azure_sys&amp;quot;, &amp;quot;cloudsqladmin&amp;quot;, &amp;quot;rdsadmin&amp;quot;]&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;exclude_databases&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(string)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;A list of databases to exclude from monitoring, on top of the always-excluded system databases &lt;code&gt;master&lt;/code&gt;, &lt;code&gt;model&lt;/code&gt;, &lt;code&gt;msdb&lt;/code&gt;, and &lt;code&gt;tempdb&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;[&amp;quot;alloydbadmin&amp;quot;, &amp;quot;alloydbmetadata&amp;quot;, &amp;quot;azure_maintenance&amp;quot;, &amp;quot;azure_sys&amp;quot;, &amp;quot;cloudsqladmin&amp;quot;, &amp;quot;rdsadmin&amp;quot;]&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;exclude_users&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(string)&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;A list of original SQL Server login names to exclude from query samples.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;[&amp;quot;azuresu&amp;quot;, &amp;quot;cloudsqladmin&amp;quot;, &amp;quot;db-o11y&amp;quot;, &amp;quot;rdsadmin&amp;quot;]&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;query_timeout&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Timeout for each SQL statement.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;10s&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;The &lt;code&gt;query_timeout&lt;/code&gt; applies separately to each SQL statement.
The timeout includes waiting for an available connection and reading the statement results.
A collection cycle can run multiple statements and can take longer than &lt;code&gt;query_timeout&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The following collectors are configurable:&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;Name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Enabled by default&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;explain_plans&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect and parse query execution plans already captured by Query Store.&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;query_details&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect query text and parsed table names from Query Store.&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;query_metrics&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect per-query executions, errors, and duration counters from Query Store.&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;query_samples&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect query samples and wait events for tracked queries.&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;schema_details&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect schemas and tables from &lt;code&gt;information_schema&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;blocks&#34;&gt;Blocks&lt;/h2&gt;
&lt;p&gt;You can use the following blocks with &lt;code&gt;database_observability.sql_server&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;config-app&#34; style=&#34;--config-tree-row-count: 14;&#34; x3-data=&#34;configVisualizer(&amp;#34;\u003csection class=\&amp;#34;expand-table-wrapper\&amp;#34;\u003e\u003cdiv class=\&amp;#34;button-div\&amp;#34;\u003e\n      \u003cbutton class=\&amp;#34;expand-table-btn\&amp;#34;\u003eExpand table\u003c/button\u003e\n    \u003c/div\u003e\u003cdiv class=\&amp;#34;responsive-table-wrapper\&amp;#34;\u003e\n    \u003ctable\u003e\n      \u003cthead\u003e\n          \u003ctr\u003e\n              \u003cth\u003eBlock\u003c/th\u003e\n              \u003cth\u003eDescription\u003c/th\u003e\n              \u003cth\u003eRequired\u003c/th\u003e\n          \u003c/tr\u003e\n      \u003c/thead\u003e\n      \u003ctbody\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#cloud_provider\&amp;#34;\u003e\u003ccode\u003ecloud_provider\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eProvide Cloud Provider information.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ccode\u003ecloud_provider\u003c/code\u003e \u0026gt; \u003ca href=\&amp;#34;#aws\&amp;#34;\u003e\u003ccode\u003eaws\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eProvide AWS database host information.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ccode\u003ecloud_provider\u003c/code\u003e \u0026gt; \u003ca href=\&amp;#34;#azure\&amp;#34;\u003e\u003ccode\u003eazure\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eProvide Azure database host information.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ccode\u003ecloud_provider\u003c/code\u003e \u0026gt; \u003ca href=\&amp;#34;#gcp\&amp;#34;\u003e\u003ccode\u003egcp\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eProvide GCP database host information.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#database_instance\&amp;#34;\u003e\u003ccode\u003edatabase_instance\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eDefine one SQL Server instance to monitor. Repeat the block to monitor several instances.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ccode\u003edatabase_instance\u003c/code\u003e \u0026gt; \u003ca href=\&amp;#34;#cloud_provider\&amp;#34;\u003e\u003ccode\u003ecloud_provider\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eProvide Cloud Provider information for one instance.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ccode\u003edatabase_instance\u003c/code\u003e \u0026gt; \u003ca href=\&amp;#34;#rule\&amp;#34;\u003e\u003ccode\u003erule\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eRelabel the metrics and logs of one instance.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#clustering\&amp;#34;\u003e\u003ccode\u003eclustering\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the component for when Alloy is running in clustered mode.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#explain_plans\&amp;#34;\u003e\u003ccode\u003eexplain_plans\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the query execution plan collector.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#health_check\&amp;#34;\u003e\u003ccode\u003ehealth_check\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the health check collector.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#query_details\&amp;#34;\u003e\u003ccode\u003equery_details\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the Query Store query text collector.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#query_metrics\&amp;#34;\u003e\u003ccode\u003equery_metrics\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the Query Store metrics collector.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#query_samples\&amp;#34;\u003e\u003ccode\u003equery_samples\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the query samples collector.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n          \u003ctr\u003e\n              \u003ctd\u003e\u003ca href=\&amp;#34;#schema_details\&amp;#34;\u003e\u003ccode\u003eschema_details\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n              \u003ctd\u003eConfigure the schema and table details collector.\u003c/td\u003e\n              \u003ctd\u003eno\u003c/td\u003e\n          \u003c/tr\u003e\n      \u003c/tbody\u003e\n    \u003c/table\u003e\n  \u003c/div\u003e\n\u003c/section\u003e&amp;#34;)&#34;&gt;
  &lt;noscript&gt;
    &lt;div class=&#34;config-app__noscript&#34;&gt;&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Block&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#cloud_provider&#34;&gt;&lt;code&gt;cloud_provider&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Provide Cloud Provider information.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;cloud_provider&lt;/code&gt; &amp;gt; &lt;a href=&#34;#aws&#34;&gt;&lt;code&gt;aws&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Provide AWS database host information.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;cloud_provider&lt;/code&gt; &amp;gt; &lt;a href=&#34;#azure&#34;&gt;&lt;code&gt;azure&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Provide Azure database host information.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;cloud_provider&lt;/code&gt; &amp;gt; &lt;a href=&#34;#gcp&#34;&gt;&lt;code&gt;gcp&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Provide GCP database host information.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#database_instance&#34;&gt;&lt;code&gt;database_instance&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Define one SQL Server instance to monitor. Repeat the block to monitor several instances.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;database_instance&lt;/code&gt; &amp;gt; &lt;a href=&#34;#cloud_provider&#34;&gt;&lt;code&gt;cloud_provider&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Provide Cloud Provider information for one instance.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;database_instance&lt;/code&gt; &amp;gt; &lt;a href=&#34;#rule&#34;&gt;&lt;code&gt;rule&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Relabel the metrics and logs of one instance.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#clustering&#34;&gt;&lt;code&gt;clustering&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the component for when Alloy is running in clustered mode.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#explain_plans&#34;&gt;&lt;code&gt;explain_plans&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the query execution plan collector.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#health_check&#34;&gt;&lt;code&gt;health_check&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the health check collector.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#query_details&#34;&gt;&lt;code&gt;query_details&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the Query Store query text collector.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#query_metrics&#34;&gt;&lt;code&gt;query_metrics&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the Query Store metrics collector.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#query_samples&#34;&gt;&lt;code&gt;query_samples&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the query samples collector.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href=&#34;#schema_details&#34;&gt;&lt;code&gt;schema_details&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Configure the schema and table details collector.&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;/div&gt;
  &lt;/noscript&gt;
  &lt;main class=&#34;config-app__main&#34;&gt;
    &lt;template x3-if=&#34;flatBlocks.length === 0&#34;&gt;
      &lt;div class=&#34;empty-state&#34;&gt;
        &lt;div class=&#34;empty-state__icon&#34; x3-html=&#34;icons.AlertCircle&#34;&gt;&lt;/div&gt;
        &lt;p&gt;No valid configuration blocks found.&lt;/p&gt;
      &lt;/div&gt;
    &lt;/template&gt;

    &lt;template x3-if=&#34;flatBlocks.length &gt; 0&#34;&gt;
      &lt;div class=&#34;config-tree&#34;&gt;
        &lt;div class=&#34;config-tree__toolbar&#34;&gt;
          &lt;div class=&#34;config-tree__title&#34;&gt;&lt;/div&gt;
          &lt;button
            class=&#34;tree-explorer__button w-130 text-right&#34;
            x3-on:click=&#34;toggleExpandAll&#34;
            x3-bind:title=&#34;allExpanded ? &#39;Collapse all&#39; : &#39;Expand all&#39;&#34;
          &gt;
            &lt;span x3-text=&#34;allExpanded ? &#39;Collapse all&#39; : &#39;Expand all&#39;&#34;&gt;&lt;/span&gt;
            &lt;svg class=&#34;api-icon&#34; viewBox=&#34;0 0 24 24&#34;&gt;
              &lt;path x3-show=&#34;!allExpanded&#34; d=&#34;m6 9 6 6 6-6&#34; /&gt;
              &lt;path x3-show=&#34;allExpanded&#34; d=&#34;m18 15-6-6-6 6&#34; /&gt;
            &lt;/svg&gt;
          &lt;/button&gt;
        &lt;/div&gt;

        &lt;div class=&#34;nodes-container&#34;&gt;
          &lt;template x3-for=&#34;block in flatBlocks&#34; x3-bind:key=&#34;block.id&#34;&gt;
            &lt;div class=&#34;node&#34; x3-bind:class=&#34;isNodeVisible(block) ? &#39;node--visible&#39; : &#39;node--hidden&#39;&#34;&gt;
              &lt;div
                class=&#34;node__row&#34;
                x3-bind:class=&#34;getRowClass(block)&#34;
                x3-bind:style=&#34;`padding-left: ${block.level * 24 &#43; 16}px`&#34;
                x3-on:click=&#34;toggleNode(block.id)&#34;
              &gt;
                &lt;div class=&#34;node__left&#34;&gt;
                  &lt;div class=&#34;node__indicator&#34;&gt;
                    &lt;template x3-if=&#34;block.hasChildren&#34;&gt;
                      &lt;button type=&#34;button&#34; class=&#34;node__toggle&#34; x3-on:click.stop=&#34;toggleNode(block.id)&#34;&gt;
                        &lt;div
                          class=&#34;node__toggle-icon&#34;
                          x3-bind:class=&#34;block.expanded ? &#39;node__toggle-icon--expanded&#39; : &#39;&#39;&#34;
                          x3-html=&#34;icons.ChevronDown&#34;
                        &gt;&lt;/div&gt;
                      &lt;/button&gt;
                    &lt;/template&gt;
                    &lt;template x3-if=&#34;!block.hasChildren&#34;&gt;
                      &lt;div class=&#34;node__toggle-spacer&#34;&gt;&lt;/div&gt;
                    &lt;/template&gt;
                  &lt;/div&gt;

                  &lt;div class=&#34;node__content&#34;&gt;
                    &lt;div
                      class=&#34;node__title prose&#34;
                      x3-bind:class=&#34;block.level === 0 ? &#39;node__title--root&#39; : &#39;node__title--nested&#39;&#34;
                      x3-html=&#34;block.displayName&#34;
                    &gt;&lt;/div&gt;
                    &lt;div class=&#34;node__description body-xsmall&#34; x3-html=&#34;block.description&#34;&gt;&lt;/div&gt;
                  &lt;/div&gt;
                &lt;/div&gt;

                &lt;div class=&#34;node__meta&#34;&gt;
                  &lt;span
                    class=&#34;badge&#34;
                    x3-bind:class=&#34;block.required ? &#39;badge--required&#39; : &#39;badge--optional&#39;&#34;
                    x3-text=&#34;block.required ? &#39;Required&#39; : &#39;Optional&#39;&#34;
                  &gt;&lt;/span&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/template&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/template&gt;
  &lt;/main&gt;
&lt;/div&gt;

&lt;h3 id=&#34;cloud_provider&#34;&gt;&lt;code&gt;cloud_provider&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;cloud_provider&lt;/code&gt; block has no attributes.
It contains zero or one of the &lt;a href=&#34;#aws&#34;&gt;&lt;code&gt;aws&lt;/code&gt;&lt;/a&gt;, &lt;a href=&#34;#azure&#34;&gt;&lt;code&gt;azure&lt;/code&gt;&lt;/a&gt;, or &lt;a href=&#34;#gcp&#34;&gt;&lt;code&gt;gcp&lt;/code&gt;&lt;/a&gt; blocks.
You use the &lt;code&gt;cloud_provider&lt;/code&gt; block to provide information related to the cloud provider that hosts the database under observation.
This information is appended as labels to the collected metrics.
The labels make it easier for you to filter and group your metrics.&lt;/p&gt;
&lt;p&gt;When you don&amp;rsquo;t configure a &lt;code&gt;cloud_provider&lt;/code&gt; block, Alloy attempts to detect AWS RDS and Azure SQL hosts from the &lt;code&gt;data_source_name&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;aws&#34;&gt;&lt;code&gt;aws&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;aws&lt;/code&gt; block supplies the &lt;a href=&#34;https://docs.aws.amazon.com/IAM/latest/UserGuide/reference-arns.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;ARN&lt;/a&gt; identifier for the database being monitored.&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;arn&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The ARN associated with the database under observation.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;azure&#34;&gt;&lt;code&gt;azure&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;azure&lt;/code&gt; block supplies the identifying information for the database being monitored.&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;subscription_id&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The Subscription ID for your Azure account.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;resource_group&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The Resource Group that holds the database resource.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;server_name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The database server name, for example &lt;code&gt;orders-db&lt;/code&gt; for the host &lt;code&gt;orders-db.database.windows.net&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;gcp&#34;&gt;&lt;code&gt;gcp&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;gcp&lt;/code&gt; block supplies the identifying information for the GCP Cloud SQL database being monitored.&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;connection_name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The Cloud SQL instance connection name in the format &lt;code&gt;project:region:instance&lt;/code&gt;, for example &lt;code&gt;my-project:us-central1:my-db&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;database_instance&#34;&gt;&lt;code&gt;database_instance&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;database_instance&lt;/code&gt; block defines one SQL Server instance to monitor.
Repeat the block to monitor several instances with a single component.
The block label must be unique across &lt;code&gt;database_instance&lt;/code&gt; blocks and identifies the instance in the component&amp;rsquo;s metrics endpoint path.
Each &lt;code&gt;database_instance&lt;/code&gt; block must also point to a distinct server: two blocks that resolve to the same host, port or named instance, and database name are rejected.&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;data_source_name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;secret&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;https://github.com/microsoft/go-mssqldb#connection-parameters-and-dsn&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Data Source Name&lt;/a&gt; for the SQL Server instance to connect to.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Each &lt;code&gt;database_instance&lt;/code&gt; block can also contain a [&lt;code&gt;cloud_provider&lt;/code&gt;][cloud_provider] block that applies to that instance only, and [&lt;code&gt;rule&lt;/code&gt;][rule] blocks that relabel the metrics and logs of that instance only.&lt;/p&gt;
&lt;p&gt;When you define &lt;code&gt;database_instance&lt;/code&gt; blocks, don&amp;rsquo;t set the top-level &lt;code&gt;data_source_name&lt;/code&gt;, &lt;code&gt;targets&lt;/code&gt;, and &lt;code&gt;cloud_provider&lt;/code&gt; arguments.
They&amp;rsquo;re mutually exclusive with &lt;code&gt;database_instance&lt;/code&gt; blocks.
All other arguments and blocks, such as collector settings, apply to every configured instance.&lt;/p&gt;
&lt;p&gt;The metrics for each instance are served on a separate &lt;code&gt;/db/&amp;lt;LABEL&amp;gt;/metrics&lt;/code&gt; path under the component&amp;rsquo;s HTTP endpoint, and the exported targets point to the corresponding path.
When you don&amp;rsquo;t define &lt;code&gt;database_instance&lt;/code&gt; blocks, the component serves metrics on its historical &lt;code&gt;/metrics&lt;/code&gt; path.
The metrics endpoints are served exactly at those paths: requests to any other path under the component&amp;rsquo;s HTTP endpoint return HTTP 404.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;

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

  database_instance &amp;#34;orders&amp;#34; {
    data_source_name = sys.env(&amp;#34;ORDERS_DSN&amp;#34;)

    cloud_provider {
      aws {
        arn = &amp;#34;orders-rds-db-arn&amp;#34;
      }
    }

    rule {
      target_label = &amp;#34;environment&amp;#34;
      replacement  = &amp;#34;production&amp;#34;
    }
  }

  database_instance &amp;#34;billing&amp;#34; {
    data_source_name = sys.env(&amp;#34;BILLING_DSN&amp;#34;)

    rule {
      target_label = &amp;#34;environment&amp;#34;
      replacement  = &amp;#34;staging&amp;#34;
    }
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In this example, the metrics and logs of the &lt;code&gt;orders&lt;/code&gt; instance carry &lt;code&gt;environment=&amp;quot;production&amp;quot;&lt;/code&gt;, and those of the &lt;code&gt;billing&lt;/code&gt; instance carry &lt;code&gt;environment=&amp;quot;staging&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;rule&#34;&gt;&lt;code&gt;rule&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;rule&lt;/code&gt; block relabels the metrics and the logs of the &lt;code&gt;database_instance&lt;/code&gt; block that contains it.
Use it to tell the data of each monitored instance apart, for example by environment, team, or tier.&lt;/p&gt;


&lt;div data-shared=&#34;reference/components/rule-block-database-observability.md&#34;&gt;
            &lt;p&gt;The &lt;code&gt;rule&lt;/code&gt; block defines a relabeling rule applied to the metrics and the logs of a single monitored database.
If you define more than one &lt;code&gt;rule&lt;/code&gt; block, the rules are applied in top-down order, after the labels the component sets itself, so a rule can read those labels with &lt;code&gt;source_labels&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It takes the same arguments as the 
    &lt;a href=&#34;/docs/alloy/v1.21/reference/components/prometheus/prometheus.relabel/#rule&#34;&gt;&lt;code&gt;rule&lt;/code&gt; block&lt;/a&gt; used elsewhere in Alloy, in a restricted form: because one rule set applies to two signal paths, it supports the labelling actions only, and it can&amp;rsquo;t overwrite most of the labels the component sets.
Alloy refuses to load a configuration containing a rule that breaks either restriction, so such a rule is never silently ignored.&lt;/p&gt;
&lt;p&gt;Two further constraints are specific to a &lt;code&gt;database_instance&lt;/code&gt; block:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;target_label&lt;/code&gt; must be a literal label name&lt;/strong&gt;: Alloy checks it against the reserved labels when it loads the configuration, so it can&amp;rsquo;t contain a capture group reference.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;hashmod&lt;/code&gt; requires &lt;code&gt;source_labels&lt;/code&gt;, and can&amp;rsquo;t target &lt;code&gt;instance&lt;/code&gt;&lt;/strong&gt;: hashing the empty value gives every database the same result, and hashing into &lt;code&gt;instance&lt;/code&gt; buckets several databases onto one value even when the source is present.&lt;/li&gt;
&lt;/ul&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;A relabeling rule that computes an empty value &lt;em&gt;removes&lt;/em&gt; its target label instead of setting it, and the default &lt;code&gt;replacement&lt;/code&gt; of &lt;code&gt;&amp;quot;$1&amp;quot;&lt;/code&gt; computes an empty value when a rule has no &lt;code&gt;source_labels&lt;/code&gt;.
So &lt;code&gt;rule { target_label = &amp;quot;environment&amp;quot; }&lt;/code&gt; removes &lt;code&gt;environment&lt;/code&gt; rather than setting it, and Alloy rejects it.
Always set &lt;code&gt;replacement&lt;/code&gt; alongside a &lt;code&gt;target_label&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Alloy can only reject such a rule where the outcome is certain.
A rule that reads &lt;code&gt;source_labels&lt;/code&gt; depends on the labels present at runtime, so a missing or misspelled source label still removes the target label, except for the reserved labels and &lt;code&gt;instance&lt;/code&gt;, which keep their previous value.
Only removal is prevented: a rule that computes a &lt;em&gt;non-empty&lt;/em&gt; value still overwrites those labels, which is why &lt;code&gt;hashmod&lt;/code&gt; can&amp;rsquo;t target &lt;code&gt;instance&lt;/code&gt; at all.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;You can use the &lt;code&gt;hashmod&lt;/code&gt;, &lt;code&gt;labeldrop&lt;/code&gt;, &lt;code&gt;lowercase&lt;/code&gt;, &lt;code&gt;replace&lt;/code&gt;, and &lt;code&gt;uppercase&lt;/code&gt; actions.
The rest aren&amp;rsquo;t supported:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;drop&lt;/code&gt;, &lt;code&gt;dropequal&lt;/code&gt;, &lt;code&gt;keep&lt;/code&gt;, and &lt;code&gt;keepequal&lt;/code&gt; filter rather than label, and filtering means two different things on the two signal paths. Dropping a metrics target stops the database exporting metrics entirely, whereas dropping a log entry discards one line. To filter one database&amp;rsquo;s logs, use a 
    &lt;a href=&#34;/docs/alloy/v1.21/reference/components/loki/loki.relabel/&#34;&gt;&lt;code&gt;loki.relabel&lt;/code&gt;&lt;/a&gt; component on the receiver named in &lt;code&gt;forward_to&lt;/code&gt;, with a &lt;code&gt;drop&lt;/code&gt; rule that matches that database&amp;rsquo;s &lt;code&gt;instance&lt;/code&gt; or &lt;code&gt;server_id&lt;/code&gt;. Every database the component monitors forwards to the same receivers, so the rule has to identify the one it applies to. To filter one database&amp;rsquo;s metrics, use a 
    &lt;a href=&#34;/docs/alloy/v1.21/reference/components/discovery/discovery.relabel/&#34;&gt;&lt;code&gt;discovery.relabel&lt;/code&gt;&lt;/a&gt; component on the component&amp;rsquo;s exported targets.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;labelmap&lt;/code&gt; builds label names from &lt;code&gt;replacement&lt;/code&gt; at runtime, so Alloy can&amp;rsquo;t check them against the reserved labels when it loads the configuration.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;labelkeep&lt;/code&gt; removes every label its &lt;code&gt;regex&lt;/code&gt; doesn&amp;rsquo;t match, so a rule that preserves the reserved labels would have to match all of them. Use &lt;code&gt;labeldrop&lt;/code&gt; to remove specific labels instead.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Because the rules run after the component&amp;rsquo;s own labels, and those are protected, a &lt;code&gt;labeldrop&lt;/code&gt; rule can only remove a label that an earlier rule in the same block created.&lt;/p&gt;
&lt;h4 id=&#34;reserved-labels&#34;&gt;Reserved labels&lt;/h4&gt;
&lt;p&gt;A rule can&amp;rsquo;t write to the following labels, and a &lt;code&gt;labeldrop&lt;/code&gt; regular expression can&amp;rsquo;t match them:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Both metrics and logs&lt;/strong&gt;: &lt;code&gt;job&lt;/code&gt; and &lt;code&gt;server_id&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Logs only&lt;/strong&gt;: &lt;code&gt;engine&lt;/code&gt; and &lt;code&gt;op&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Metrics only&lt;/strong&gt;: &lt;code&gt;provider_name&lt;/code&gt;, &lt;code&gt;provider_region&lt;/code&gt;, &lt;code&gt;provider_account&lt;/code&gt;, &lt;code&gt;__address__&lt;/code&gt;, &lt;code&gt;__scheme__&lt;/code&gt;, and &lt;code&gt;__metrics_path__&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This applies to &lt;code&gt;rule&lt;/code&gt; blocks only.
A downstream &lt;code&gt;discovery.relabel&lt;/code&gt; or &lt;code&gt;loki.relabel&lt;/code&gt; component can still overwrite any of them, but it applies to every database the component monitors rather than one.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;instance&lt;/code&gt; label is a special case: a rule can rewrite its value, which is a common reason to use a &lt;code&gt;rule&lt;/code&gt; block, because a friendly name such as &lt;code&gt;orders_db&lt;/code&gt; then applies to that database&amp;rsquo;s metrics and logs together.
A rule can&amp;rsquo;t remove it, because metrics and logs are correlated on it, and because an empty &lt;code&gt;instance&lt;/code&gt; on a metrics target makes Prometheus fill it in from &lt;code&gt;__address__&lt;/code&gt;, which every database in one component shares, collapsing them all onto one series.&lt;/p&gt;
&lt;p&gt;For the same reason, two &lt;code&gt;database_instance&lt;/code&gt; blocks can&amp;rsquo;t rewrite &lt;code&gt;instance&lt;/code&gt; to the same value.
Alloy rejects that when both values are fixed in the configuration, but it can&amp;rsquo;t when the value comes from a label the databases share: &lt;code&gt;source_labels = [&amp;quot;job&amp;quot;]&lt;/code&gt; gives every database the same &lt;code&gt;instance&lt;/code&gt;, since they all carry the same &lt;code&gt;job&lt;/code&gt;.
Derive &lt;code&gt;instance&lt;/code&gt; from something that differs per database, or set a literal value in each block.&lt;/p&gt;
&lt;h4 id=&#34;labels-set-on-only-one-signal-path&#34;&gt;Labels set on only one signal path&lt;/h4&gt;
&lt;p&gt;Some of the labels above exist on one signal path and not the other, and a rule that reads one with &lt;code&gt;source_labels&lt;/code&gt; behaves differently on each path: where the label is absent the rule computes an empty value, which &lt;em&gt;removes&lt;/em&gt; its &lt;code&gt;target_label&lt;/code&gt; rather than setting it to an empty string.&lt;/p&gt;
&lt;p&gt;A rule reading &lt;code&gt;provider_region&lt;/code&gt;, which a database with a &lt;a href=&#34;#cloud_provider&#34;&gt;&lt;code&gt;cloud_provider&lt;/code&gt;&lt;/a&gt; block carries on its metrics targets but not on its log entries, sets &lt;code&gt;region&lt;/code&gt; on that database&amp;rsquo;s metrics and removes &lt;code&gt;region&lt;/code&gt; from its logs.
Reading a logs-only label such as &lt;code&gt;op&lt;/code&gt; does the same in reverse.
Only &lt;code&gt;job&lt;/code&gt;, &lt;code&gt;server_id&lt;/code&gt;, and &lt;code&gt;instance&lt;/code&gt; are set on both paths, so prefer those as &lt;code&gt;source_labels&lt;/code&gt;, or a label an earlier rule in the same block created.&lt;/p&gt;
&lt;/div&gt;

        
&lt;h3 id=&#34;clustering&#34;&gt;&lt;code&gt;clustering&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;enabled&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;bool&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Enables distributing instances with other cluster nodes.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;When Alloy is &lt;a href=&#34;../../../../get-started/clustering/&#34;&gt;using clustering&lt;/a&gt;, and &lt;code&gt;enabled&lt;/code&gt; is set to true, then this &lt;code&gt;database_observability.sql_server&lt;/code&gt; component instance opts-in to distributing its configured instances between all cluster nodes.&lt;/p&gt;
&lt;p&gt;Clustering assumes that all cluster nodes are running with the same configuration file.
All component instances opting in to clustering use the instance key of each configured instance, &lt;code&gt;&amp;lt;host&amp;gt;:&amp;lt;port&amp;gt;/&amp;lt;database&amp;gt;&lt;/code&gt;, and a consistent hashing algorithm to determine ownership of each instance between the cluster peers.
Each peer then only collects from the subset of instances it&amp;rsquo;s responsible for, and only exports the targets of those instances, so &lt;code&gt;prometheus.scrape&lt;/code&gt; components on the same node scrape exactly the instances the node owns.
When a node joins or leaves the cluster, every peer recalculates ownership: expect a short gap or a brief duplicate collection for an instance while its ownership moves.
While the cluster isn&amp;rsquo;t yet ready to admit traffic, for example while it&amp;rsquo;s still forming and waiting for the minimum cluster size, the component doesn&amp;rsquo;t collect from any instance.&lt;/p&gt;
&lt;p&gt;Clustering is also useful with a single instance: when several cluster nodes run an identical configuration, exactly one node collects from the instance at a time, which gives you a highly available setup without duplicate collection.&lt;/p&gt;
&lt;p&gt;If Alloy is &lt;em&gt;not&lt;/em&gt; running in clustered mode, then the block is a no-op and &lt;code&gt;database_observability.sql_server&lt;/code&gt; collects from every configured instance.&lt;/p&gt;
&lt;h3 id=&#34;explain_plans&#34;&gt;&lt;code&gt;explain_plans&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;collect_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How frequently to check for a changed execution plan.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;1m&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;The &lt;code&gt;explain_plans&lt;/code&gt; collector reads the execution plan &lt;a href=&#34;https://learn.microsoft.com/sql/relational-databases/performance/monitoring-performance-by-using-the-query-store&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Query Store&lt;/a&gt; already captured for each query tracked by the &lt;code&gt;query_metrics&lt;/code&gt; collector.
It doesn&amp;rsquo;t compile or run a fresh plan.
Only queries that &lt;code&gt;query_metrics&lt;/code&gt; is currently tracking are eligible.
When &lt;code&gt;query_metrics&lt;/code&gt; is disabled, &lt;code&gt;explain_plans&lt;/code&gt; produces no output.&lt;/p&gt;
&lt;p&gt;The collector checks for a changed plan every &lt;code&gt;collect_interval&lt;/code&gt;.
It forwards a log entry only when the plan&amp;rsquo;s shape has changed since the last entry.
It also forwards a log entry when 30 minutes have passed since the last entry.
This keeps log volume low and ensures a fresh entry at least every 30 minutes.&lt;/p&gt;
&lt;h3 id=&#34;health_check&#34;&gt;&lt;code&gt;health_check&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;collect_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How frequently to run health checks.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;1h&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;The &lt;code&gt;health_check&lt;/code&gt; collector periodically verifies that the login has the required grants (&lt;code&gt;VIEW DEFINITION&lt;/code&gt;, plus &lt;code&gt;VIEW DATABASE STATE&lt;/code&gt; or its SQL Server 2022&#43; equivalent &lt;code&gt;VIEW DATABASE PERFORMANCE STATE&lt;/code&gt;) and that &lt;a href=&#34;https://learn.microsoft.com/sql/relational-databases/performance/monitoring-performance-by-using-the-query-store&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Query Store&lt;/a&gt; is enabled and populated, on every database the login can access on the instance. Each check emits a log entry with &lt;code&gt;op=&amp;quot;health_status&amp;quot;&lt;/code&gt; and a &lt;code&gt;check&lt;/code&gt; field identifying it: &lt;code&gt;AlloyVersion&lt;/code&gt;, &lt;code&gt;RequiredGrantsPresent&lt;/code&gt;, &lt;code&gt;QueryStoreEnabled&lt;/code&gt;, or &lt;code&gt;QueryStoreHasRows&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;RequiredGrantsPresent&lt;/code&gt; and &lt;code&gt;QueryStoreEnabled&lt;/code&gt; pass only when true on every database the login can access; when they fail, the log entry&amp;rsquo;s value lists the non-compliant databases. &lt;code&gt;QueryStoreHasRows&lt;/code&gt; passes as soon as any accessible database has Query Store data, since it&amp;rsquo;s expected for a low-traffic database to have none.&lt;/p&gt;
&lt;h3 id=&#34;query_details&#34;&gt;&lt;code&gt;query_details&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;collect_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How frequently to collect query text from Query Store.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;1m&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;The &lt;code&gt;query_details&lt;/code&gt; collector reads &lt;a href=&#34;https://learn.microsoft.com/sql/relational-databases/performance/monitoring-performance-by-using-the-query-store&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Query Store&lt;/a&gt; query text for the database selected in the &lt;code&gt;data_source_name&lt;/code&gt;, not every database on the instance.&lt;/p&gt;
&lt;h3 id=&#34;query_metrics&#34;&gt;&lt;code&gt;query_metrics&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;collect_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How frequently to collect metrics from Query Store.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;1m&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;statements_limit&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;int&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Maximum number of queries to track, ranked by recent duration.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;50&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;statements_lookback&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Only queries executed within this window are eligible for tracking.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;1h&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;The &lt;code&gt;query_metrics&lt;/code&gt; collector reads &lt;a href=&#34;https://learn.microsoft.com/sql/relational-databases/performance/monitoring-performance-by-using-the-query-store&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Query Store&lt;/a&gt; for the database selected in the &lt;code&gt;data_source_name&lt;/code&gt;, not every database on the instance.
Configure the &lt;code&gt;data_source_name&lt;/code&gt; to select a user database that has Query Store enabled.
When the connected database is a system database such as &lt;code&gt;master&lt;/code&gt;, or Query Store is disabled or read-only, the collector skips collection and remains healthy.&lt;/p&gt;
&lt;p&gt;The login requires &lt;code&gt;VIEW DATABASE STATE&lt;/code&gt; on the connected database. On SQL Server 2022 and later, &lt;code&gt;VIEW DATABASE PERFORMANCE STATE&lt;/code&gt; is also sufficient.&lt;/p&gt;
&lt;h3 id=&#34;query_samples&#34;&gt;&lt;code&gt;query_samples&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;collect_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How frequently to collect query samples.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;10s&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;disable_query_redaction&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;bool&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Collect unredacted SQL query text (might include parameters).&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;The &lt;code&gt;query_samples&lt;/code&gt; collector only collects requests whose query hash is tracked by the &lt;code&gt;query_metrics&lt;/code&gt; collector.&lt;/p&gt;
&lt;p&gt;The collector polls live requests and can miss queries shorter than &lt;code&gt;collect_interval&lt;/code&gt;, wait events that start and finish between collections, and a query&amp;rsquo;s first execution before Query Store admits its hash.
For completed requests, the emitted resource counters contain the values from the final observation and can omit work performed after that observation.&lt;/p&gt;
&lt;p&gt;The login requires &lt;code&gt;VIEW SERVER STATE&lt;/code&gt; on SQL Server 2019 and earlier. On SQL Server 2022 and later, &lt;code&gt;VIEW SERVER PERFORMANCE STATE&lt;/code&gt; is also sufficient. Azure SQL Database can restrict the dynamic management views to the current session. In that case, the collector can&amp;rsquo;t observe other sessions.&lt;/p&gt;
&lt;h3 id=&#34;schema_details&#34;&gt;&lt;code&gt;schema_details&lt;/code&gt;&lt;/h3&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;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;collect_interval&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How frequently to collect information from database.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;1m&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;The collector scans every database that the login can access on the instance and collects schema details from each. Only databases where the login has &lt;code&gt;CONNECT&lt;/code&gt; access to catalog views are collected.&lt;/p&gt;
&lt;h2 id=&#34;example&#34;&gt;Example&lt;/h2&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;database_observability.sql_server &amp;#34;orders_db&amp;#34; {
  data_source_name = &amp;#34;sqlserver://user:pass@server:1433&amp;#34;
  forward_to       = [loki.write.logs_service.receiver]
}

loki.write &amp;#34;logs_service&amp;#34; {
  endpoint {
    url = sys.env(&amp;#34;&amp;lt;GRAFANA_CLOUD_HOSTED_LOGS_URL&amp;gt;&amp;#34;)
    basic_auth {
      username = sys.env(&amp;#34;&amp;lt;GRAFANA_CLOUD_HOSTED_LOGS_ID&amp;gt;&amp;#34;)
      password = sys.env(&amp;#34;&amp;lt;GRAFANA_CLOUD_RW_API_KEY&amp;gt;&amp;#34;)
    }
  }
}&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;GRAFANA_CLOUD_HOSTED_LOGS_URL&amp;gt;&lt;/code&gt;&lt;/em&gt;: The URL for your Grafana Cloud hosted logs.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;GRAFANA_CLOUD_HOSTED_LOGS_ID&amp;gt;&lt;/code&gt;&lt;/em&gt;: The user ID for your Grafana Cloud hosted logs.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;GRAFANA_CLOUD_RW_API_KEY&amp;gt;&lt;/code&gt;&lt;/em&gt;: Your Grafana Cloud API key.&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- START GENERATED COMPATIBLE COMPONENTS --&gt;
&lt;h2 id=&#34;compatible-components&#34;&gt;Compatible components&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;database_observability.sql_server&lt;/code&gt; can accept arguments from the following components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Components that export &lt;a href=&#34;../../../compatibility/#targets-exporters&#34;&gt;Targets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Components that export &lt;a href=&#34;../../../compatibility/#loki-logsreceiver-exporters&#34;&gt;Loki &lt;code&gt;LogsReceiver&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;database_observability.sql_server&lt;/code&gt; has exports that can be consumed by the following components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Components that consume &lt;a href=&#34;../../../compatibility/#targets-consumers&#34;&gt;Targets&lt;/a&gt;&lt;/li&gt;
&lt;/ul&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;Connecting some components may not be sensible or components may require further configuration to make the connection work correctly.
Refer to the linked documentation for more details.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;!-- END GENERATED COMPATIBLE COMPONENTS --&gt;
]]></content><description>&lt;h1 id="database_observabilitysql_server">&lt;code>database_observability.sql_server&lt;/code>&lt;/h1>
&lt;div data-shared="stability/experimental.md">
&lt;blockquote>
&lt;p>&lt;strong>EXPERIMENTAL&lt;/strong>: This is an &lt;a href="/docs/release-life-cycle/">experimental&lt;/a> component.
Experimental components are subject to frequent breaking changes, and may be removed with no equivalent replacement.
To enable and use an experimental component, you must set the &lt;code>stability.level&lt;/code>
&lt;a href="/docs/alloy/v1.21/reference/cli/run/">flag&lt;/a> to &lt;code>experimental&lt;/code>.&lt;/p></description></item></channel></rss>