---
title: "Troubleshoot Alloy components | Database Observability documentation"
description: "Troubleshoot Alloy configuration for Database Observability metrics and logs."
---

# Troubleshoot Alloy components

Identify and resolve issues in the Alloy configuration used by the MySQL and PostgreSQL set up guides. These checks help you validate each component without repeating setup. If a check fails, open the corresponding get started article to apply the fix.

## What you’ll achieve

In this article, you:

- Validate DSN secrets, exporters, and Database Observability components.
- Confirm relabeling, scrape jobs, and remote write endpoints.

## Before you begin

Ensure you can access your Alloy deployment, view logs, and update configuration. Keep the get started articles open to apply fixes:

- [Set up MySQL](/docs/grafana-cloud/monitor-applications/database-observability/set-up/mysql/)
- [Set up PostgreSQL](/docs/grafana-cloud/monitor-applications/database-observability/set-up/postgres/)

## Verify Alloy version

Confirm you run Alloy version `1.15.0` or later. Refer to the [Run the latest Alloy version](/docs/grafana-cloud/monitor-applications/database-observability/set-up/mysql/mysql/#run-the-latest-alloy-version) section in the set up guides to update the runtime options in your deployment.

## Validate DSN secrets for MySQL and PostgreSQL

Ensure your configuration contains valid data source name strings:

- For MySQL, the DSN follows `user:password@tcp(hostname:port)/`.
- For PostgreSQL, the DSN follows `postgresql://user:password@(hostname:port)/dbname?sslmode=require`.

If the secret file is missing or the content is malformed, refer to the MySQL [Add the MySQL configuration blocks](/docs/grafana-cloud/monitor-applications/database-observability/set-up/mysql/mysql/#add-the-mysql-configuration-blocks) or PostgreSQL [Add the PostgreSQL configuration blocks](/docs/grafana-cloud/monitor-applications/database-observability/set-up/postgres/postgres/#add-the-postgresql-configuration-blocks) section to recreate the file with a correct DSN.

## Confirm MySQL exporter collectors

Validate that `prometheus.exporter.mysql` exists and has the Performance Schema collector enabled.

- Ensure `enable_collectors` includes `perf_schema.eventsstatements`.
- Ensure that `limit` is set to `100`.
- Ensure that `text_limit` is set to `0`.

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
prometheus.exporter.mysql "mysql_<DB_NAME>" {
  data_source_name  = local.file.mysql_secret_<DB_NAME>.content
  enable_collectors = ["perf_schema.eventsstatements"]
  perf_schema.eventsstatements {
    limit      = 100
    text_limit = 0
  }
}
```

If metrics for statements are missing, refer to the [Add the MySQL configuration blocks](/docs/grafana-cloud/monitor-applications/database-observability/set-up/mysql/mysql/#add-the-mysql-configuration-blocks) section to correct the collectors list.

## Confirm PostgreSQL exporter collectors and `autodiscovery`

Validate that `prometheus.exporter.postgres` exists and exposes statement statistics:

- Ensure `enabled_collectors` includes `stat_statements`.
- Ensure `autodiscovery.enabled` is `true`.
- If you run on AWS RDS, ensure `database_denylist` includes `rdsadmin`.

If exporter targets are empty or metrics lack statement stats, refer to the [Add the PostgreSQL configuration blocks](/docs/grafana-cloud/monitor-applications/database-observability/set-up/postgres/postgres/#add-the-postgresql-configuration-blocks) section to correct the exporter configuration.

## Check Database Observability components

Validate the `database_observability.mysql` and `database_observability.postgres` components.

- Ensure `data_source_name` points to the matching secret.
- Ensure `forward_to` targets the appropriate `loki.relabel` receiver.
- Ensure `targets` reference the matching exporter targets.
- If you enabled `query_samples`, confirm optional settings like `disable_query_redaction`, `sample_min_duration`, and `wait_event_min_duration` are intentional.
- If you rely on auto-enabling MySQL Performance Schema consumers (`auto_enable_setup_consumers`), ensure update permissions are granted and `allow_update_performance_schema_settings` is set.
- If you rely on auto-updating MySQL Performance Schema actors (`auto_update_setup_actors`), ensure update permissions are granted and `allow_update_performance_schema_settings` is set.

If some of your database telemetry data is missing, refer to the MySQL [Add the MySQL configuration blocks](/docs/grafana-cloud/monitor-applications/database-observability/set-up/mysql/mysql/#add-the-mysql-configuration-blocks) or PostgreSQL [Add the PostgreSQL configuration blocks](/docs/grafana-cloud/monitor-applications/database-observability/set-up/postgres/postgres/#add-the-postgresql-configuration-blocks) section to check the wiring between secrets, exporters, and Database Observability components.

## Validate relabeling rules consistency

Ensure `loki.relabel` and `discovery.relabel` rules stay consistent, especially for labels you add.

- Keep custom label keys and values consistent in both components.
- Ensure the `instance` and any custom labels are mirrored across rules.
- Do not modify the `job` or `server_id` label, as these are used to associate and query telemetry in the app.
- Do not modify the `provider_region`, `provider_accout` or `provider_name` label, as these are used to associate telemetry with cloud provider data.

If labels differ between logs and metrics, refer to the MySQL [Add the MySQL configuration blocks](/docs/grafana-cloud/monitor-applications/database-observability/set-up/mysql/mysql/#add-the-mysql-configuration-blocks) or PostgreSQL [Add the PostgreSQL configuration blocks](/docs/grafana-cloud/monitor-applications/database-observability/set-up/postgres/postgres/#add-the-postgresql-configuration-blocks) section to align the relabel rules.

## Confirm discovery targets and job label

Verify that `discovery.relabel` outputs the correct targets and sets the job label.

- Use the Database Observability component targets.
- Ensure the `job` label is `integrations/db-o11y`.

If the scrape job shows no targets or the job label is incorrect, refer to the MySQL [Add the MySQL configuration blocks](/docs/grafana-cloud/monitor-applications/database-observability/set-up/mysql/mysql/#add-the-mysql-configuration-blocks) or PostgreSQL [Add the PostgreSQL configuration blocks](/docs/grafana-cloud/monitor-applications/database-observability/set-up/postgres/postgres/#add-the-postgresql-configuration-blocks) section to correct `discovery.relabel` rules and targets.

## Verify Prometheus scrape configuration

Confirm Prometheus scrapes the output of `discovery.relabel` and forwards metrics to remote write.

- Ensure `targets` reference `discovery.relabel.<name>.output`.
- Ensure `job_name` is `integrations/db-o11y`.
- Ensure `forward_to` points to `prometheus.remote_write.metrics_service.receiver`.

If metrics do not arrive in Grafana Cloud, refer to the MySQL [Add the MySQL configuration blocks](/docs/grafana-cloud/monitor-applications/database-observability/set-up/mysql/mysql/#add-the-mysql-configuration-blocks) or PostgreSQL [Add the PostgreSQL configuration blocks](/docs/grafana-cloud/monitor-applications/database-observability/set-up/postgres/postgres/#add-the-postgresql-configuration-blocks) section to verify these three settings.

## Verify Prometheus remote write endpoint

Confirm the Prometheus remote write endpoint and credentials exist as environment variables.

- Ensure `GCLOUD_HOSTED_METRICS_URL` contains your Grafana Cloud Prometheus URL.
- Ensure `GCLOUD_HOSTED_METRICS_ID` contains your Prometheus instance ID.
- Ensure `GCLOUD_RW_API_KEY` contains a valid Grafana Cloud API token with metrics write permissions.

If remote write fails, refer to the [Add Prometheus and Loki write configuration](/docs/grafana-cloud/monitor-applications/database-observability/set-up/mysql/mysql/#add-prometheus-and-loki-write-configuration) section in the set up guides to validate the values and token permissions.

## Verify Loki write endpoint

Confirm the Loki write endpoint and credentials exist as environment variables.

- Ensure `GCLOUD_HOSTED_LOGS_URL` contains your Grafana Cloud Loki URL.
- Ensure `GCLOUD_HOSTED_LOGS_ID` contains your Loki instance ID.
- Ensure `GCLOUD_RW_API_KEY` contains a valid Grafana Cloud API token with logs write permissions.

If logs do not appear in Grafana Cloud, refer to the [Add Prometheus and Loki write configuration](/docs/grafana-cloud/monitor-applications/database-observability/set-up/mysql/mysql/#add-prometheus-and-loki-write-configuration) section in the set up guides to validate the values and token permissions.

## Next steps

Read [Get started](/docs/grafana-cloud/monitor-applications/database-observability/set-up/) to apply configuration fixes.
