prometheus-community / postgres_exporter

A PostgreSQL metric exporter for Prometheus
Apache License 2.0
2.64k stars 712 forks source link

Metrics are not visible for Azure Postgress PaaS service #401

Open nikbhadane opened 4 years ago

nikbhadane commented 4 years ago

Hi all, We are using postgres_exporter in Kubernetes environment to fetch postgres metrics. And for monitoring we are using Grafana with Prometheus as a data source. In Postgres-exporter DATA_SOURCE_NAME we are putting Azure PostgreSQL PaaS service details with "ssmode=require".

But the metrics are not able to showing any data when we execute any pg_* in Prometheus. don't know why it is happening.

Also in postgres_exporter there in no such error or warning message.

Can someone please help?

alexinthesky commented 4 years ago

Hi how can actually have the exporter connect correctly to managed postgres? no luck here because user format is "postgres@DB_NAME" and postgres_exporter does not seam happy with @ char

nadley commented 3 years ago

Hi how can actually have the exporter connect correctly to managed postgres? no luck here because user format is "postgres@DB_NAME" and postgres_exporter does not seam happy with @ char

Did you find a solution for that ?

mbanck commented 2 years ago

For the record, the new (still in preview) Azure Flexible Server no longer has that user@instance login thing. We were using postgres_exporter with the old/current Azure Single Server successfully for a long time, I think the trick is to HTML-encode the @ in the username, i.e. replace it with %40

songleo commented 2 years ago

when I try to connect the Postgres on Azure, I get the following error:

ts=2022-04-07T09:23:03.681Z caller=main.go:123 level=info msg="Listening on address" address=:9187
ts=2022-04-07T09:23:03.682Z caller=tls_config.go:195 level=info msg="TLS is disabled." http2=false
ts=2022-04-07T09:23:08.099Z caller=server.go:74 level=info msg="Established new database connection" fingerprint=test.postgres.database.azure.com:5432
ts=2022-04-07T09:23:09.139Z caller=postgres_exporter.go:731 level=error err="Error opening connection to database (postgres://user1:PASSWORD_REMOVED@test.postgres.database.azure.com/postgres?sslmode=disable): pq: no pg_hba.conf entry for host \"66.187.232.127\", user \"user1\", database \"postgres\", SSL off"

so that means the postgres-exorter can not support the Azure Postgres? thanks

mbanck commented 2 years ago

@songleo it seems you haven't whitelisted the IP the exporter is connecting from, so Azure rejects it: pq: no pg_hba.conf entry for host \"66.187.232.127\",

alexinthesky commented 2 years ago

You also have to set ssl to required

Le jeu. 7 avr. 2022 à 12:05, Michael Banck @.***> a écrit :

@songleo https://github.com/songleo it seems you haven't whitelisted the IP the exporter is connecting from, so Azure rejects it: pq: no pg_hba.conf entry for host \"66.187.232.127\",

— Reply to this email directly, view it on GitHub https://github.com/prometheus-community/postgres_exporter/issues/401#issuecomment-1091476563, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADRP4PPREILTOXKNTPABQ6TVD2XODANCNFSM4NRODGOA . You are receiving this because you commented.Message ID: @.***>

songleo commented 2 years ago

@mbanck thank you so much, but the IP is dynamic. so do you know how to handle this case?

songleo commented 2 years ago

You also have to set ssl to required Le jeu. 7 avr. 2022 à 12:05, Michael Banck @.> a écrit : @songleo https://github.com/songleo it seems you haven't whitelisted the IP the exporter is connecting from, so Azure rejects it: pq: no pg_hba.conf entry for host \"66.187.232.127\", — Reply to this email directly, view it on GitHub <#401 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADRP4PPREILTOXKNTPABQ6TVD2XODANCNFSM4NRODGOA . You are receiving this because you commented.Message ID: @.>

thanks, let me try it with the SSL

songleo commented 2 years ago

@mbanck do we have a doc or guide I can follow with? thanks

mbanck commented 2 years ago

There's nothing to follow and this is not postgres_exporter specific, this is basic managed postgres - You need to use a VPN or deploy postgres_exporter on a VM with stable IP or something.