Thursday, September 5, 2019
A systemd service file for the Prometheus PostgreSQL storage adapter
The Prometheus PostgreSQL storage adapter does not seem amenable to being executed directly from a systemd service file.
As a workaround I created a wrapper script like this (adjust parameters as required):
#!/bin/bash # Wrapper to launch prometheus-postgresql-adapter, as calling # it directly from the systemd service file doesn't seem to work. # # Disclaimer: there is probably a better way of doing this. nohup /usr/local/bin/prometheus-postgresql-adapter \ -pg-host=... \ -pg-port=... \ -pg-database="..." \ -pg-user="..." \ >> /var/log/prometheus-postgresql-storage-adapter/prometheus-pg-adapter.log 2>&1
and a service file like this:
[Unit] Description=Prometheus PostgreSQL Storage Adapter Documentation=https://github.com/timescale/prometheus-postgresql-adapter Wants=network-online.target After=network-online.target [Service] Type=simple User=prometheus Group=prometheus ExecStart=/usr/local/bin/prometheus-postgresql-adapter-wrapper Restart=on-failure [Install] WantedBy=multi-user.target
which works fine (YMMV of course).
There may of course be a more elegant way of solving this issue, if so feel free to share.
Posted at 1:31 AM |Comments (0)
Post a comment