Fix PostgreSQL metrics by URL-encoding password in alloy config

The password contained special characters (@, !, *) that broke the
connection string URL parsing. Added urlencode filter to the template.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Erich Blume 2026-01-16 12:02:52 -08:00
commit cce4c3776e

View file

@ -40,7 +40,7 @@ prometheus.remote_write "prometheus" {
// PostgreSQL exporter (read-only metrics via pg_monitor role)
prometheus.exporter.postgres "postgresql" {
data_source_names = ["postgresql://{{ alloy_postgres_user }}:{{ alloy_postgres_password }}@{{ alloy_postgres_host }}:{{ alloy_postgres_port }}/{{ alloy_postgres_database }}?sslmode=disable"]
data_source_names = ["postgresql://{{ alloy_postgres_user }}:{{ alloy_postgres_password | urlencode }}@{{ alloy_postgres_host }}:{{ alloy_postgres_port }}/{{ alloy_postgres_database }}?sslmode=disable"]
}
// Scrape PostgreSQL metrics