I try to run postgres_exporter version 0.12.0 on my linux machine. And cant figured out the reason of error "SSL is not enabled on the server". Because I already set sslmode = disable. Here is example of my postgres_exporter.service:
[Unit]
Description=Prometheus PostgreSQL Exporter
After=network.target
[Service]
Type=simple
Restart=always
User=postgres
Group=postgres
Environment=DATA_SOURCE_NAME="user=postgres host=/var/run/postgresql/ sslmode=disable"
ExecStart=/usr/local/bin/postgres_exporter --config.file=/usr/local/bin/postgres_exporter.yml --log.level=debug
[Install]
WantedBy=multi-user.target
And my postgres_exporter.yml:
auth_modules:
foo1: # Set this to any name you want
type: userpass
userpass:
username: postgres
password: postgres
options:
sslmode: disable
So the sslmode is disable, but I get error: caller=postgres_exporter.go:716 level=error err="Error opening connection to database (%22user=postgres): pq: SSL is not enabled on the server"
I found the solution: You need to pass DATA_SOURCE_NAME
clearly without quotation marks, otherwise it can’t read DATA_SOURCE_NAME
and uses default params instead where sslmode
is not disabled.
Environment=DATA_SOURCE_NAME=postgresql://postgres:password@localhost:5432/postgres?sslmode=disable