[Unit]
# forget default config file location
ConditionPathExists=
# wait for PostgreSQL to start up
After=postgresql.service
# If no PostgreSQL cluster exist, we dont't start.
ConditionPathExistsGlob=/etc/postgresql/*/*/postgresql.conf

[Service]
# before starting the sql exporter, generate config (as root)
PermissionsStartOnly=true
ExecStartPre=/usr/bin/update-prometheus-sql-exporter-config /etc/prometheus-sql-exporter /var/run/postgresql/prometheus-sql-exporter.yml
Environment="ARGS=-config.file /var/run/postgresql/prometheus-sql-exporter.yml"
Environment="GOMAXPROCS=1"
