influxdata / telegraf

Agent for collecting, processing, aggregating, and writing metrics, logs, and other arbitrary data.
https://influxdata.com/telegraf
MIT License
14.63k stars 5.58k forks source link

postgresql input plugin does not honour the "~/.pgpass" file #4870

Closed exhuma closed 1 year ago

exhuma commented 6 years ago

Relevant telegraf.conf:

[[inputs.postgresql]]
address = ""

System info:

Steps to reproduce:

Expected behavior:

The connection should work without error

Actual behavior:

The following shows up in the logs:

2018-10-17T07:44:30Z E! Error in plugin [inputs.postgresql2]: FATAL: password authentication failed for user "exhuma" (SQLSTATE 28P01)

Additional info:

I think this may be related to the driver which is used. The postgresql plugin uses github.com/jackc/pgx. But there is also https://github.com/lib/pq which I think works a expected. I hav a local development copy of telegraf. I will try switching to lib/pq and if that works will submit a PR.

danielnelson commented 6 years ago

Thanks for the report, but just a warning on switching to lib/pq, it might be tricky. We switched from lib/pq to pgx a few years ago, and while I am open to switching back, we would need to make sure the original issues would need to be solved and behavior remains the same for all postgres plugins: postgresql, postgresql_extensible, cratedb, and pgbouncer

https://github.com/influxdata/telegraf/pull/1617

mjrussell commented 4 years ago

I'd really like to see a move to libpq. I found out that the input plugin also doesn't honor common env vars like PGPASSWORD, forcing people to stick passwords plaintext into their telegraf.conf which is an unfortunate choice. The postgres output plugin (https://github.com/influxdata/telegraf/pull/3428) uses libpq as has a much nicer set of options than the current telegraf plugins that work with postgres

srebhan commented 1 year ago

@mjrussell we now have support for environment variables in the config as-well-as secret-stores to handle sensitive data such as passwords. So I think you can do what you want with a recent version of Telegraf.

@exhuma are you still interested in this feature?

exhuma commented 1 year ago

@srebhan I will forward this to a colleague. I don't think we need this any longer since we moved to another solution to monitor postgres (due to this here issue IIRC). But I prefer to double-check.

exhuma commented 1 year ago

@srebhan Just got confirmation that we indeed no longer need this.

edit: Would still be a useful feature for others though.

srebhan commented 1 year ago

I agree, but keeping this open "just in case" lead us to the issue number we have. Furthermore, I would need someone to test the feature... So if someone finds this and wants this feature added, please reopen this issue and I will take a look.