{{ ansible_managed | comment }} [Unit] Description=postgres_exporter - Prometheus exporter for PostgreSQL Documentation=https://github.com/prometheus-community/postgres_exporter After=network-online.target Wants=network-online.target [Service] Type=simple Restart=on-failure RestartSec=5 User={{ psql_prometheus_exporter_user }} Group={{ psql_prometheus_exporter_user }} EnvironmentFile={{ psql_prometheus_exporter_env_file }} ExecStart={{ psql_prometheus_exporter_cmd }} \ --web.listen-address={{ psql_prometheus_exporter_listen_address }}:{{ psql_prometheus_exporter_port }} \ --web.telemetry-path={{ psql_prometheus_exporter_metrics_path }} \ {% if psql_prometheus_exporter_auto_discover_dbs %} --auto-discover-databases \ {% if psql_prometheus_exporter_exclude_dbs | length > 0 %} --exclude-databases={{ psql_prometheus_exporter_exclude_dbs | join(',') }} \ {% endif %} {% endif %} {% if psql_prometheus_exporter_stat_statements %} --collector.stat_statements \ {% endif %} {% for opt in psql_prometheus_exporter_extra_opts %} {{ opt }} \ {% endfor %} --log.format=logfmt # ProtectSystem=full and not strict: connecting to the PostgreSQL unix socket # needs a writable /run NoNewPrivileges=true PrivateTmp=true ProtectSystem=full ProtectHome=true ProtectKernelTunables=true ProtectControlGroups=true RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 [Install] WantedBy=multi-user.target