I have a Telegraf (v1.32.3) configuration with which I connect my PostgreSQL.
If I store the password there in plain text, the connection works:
connection="host=HOST port=PORT user=USER password=PASSWORD sslmode=disable dbname=DB"
But as soon as I try to get the password from an environment variable:
connection="host=HOST port=PORT user=USER password=${PASSWORD} sslmode=disable dbname=DB"
or a file:
connection="host=HOST port=PORT user=USER password=@/run/secrets/password sslmode=disable dbname=DB"
I can no longer connect.
However, the environment variable itself contains the password. Also the file.
What am I doing wrong?
I have to say that I start PostgreSQL (more precisely TimescaleDB) and Telegraf in a container with Podman.
Hello @draekster,
Can you please share your telegraf config?
Youll want to do something like:
[[secretstores.files]]
id = "mystore"
directory = "/run/secrets"
[[inputs.postgresql]]
address = "host=HOST port=PORT user=USER password=@{mystore:password} sslmode=disable dbname=DB"
This blog could be useful:
I can finally answer 
The activation took a really long time…
With your information I have now adjusted my configuration. It looks like this:
[agent]
debug = true
interval = "10s"
hostname = "nase_telegraf"
[[secretstores.docker]]
id = "timescaledb_admin"
[[outputs.postgresql]]
connection="host=IP port=PORT user=USER password=@{timescaledb_admin:timescaledb_admin} sslmode=disable dbname=DB"
If I use secretstores.files
I get this error:
E! loading config file /etc/telegraf/telegraf.conf failed: error parsing files, undefined but requested secretstores: files
With secretstores.docker
it works. But I don’t use Docker. I use Podman. Why does this work and will it work in the future? Why secretstores.files
doesn’t work?