how to make prometheus as system service

26 views
Skip to first unread message

Amari CH

unread,
Sep 17, 2020, 2:12:05 AM9/17/20
to promethe...@googlegroups.com
Currently I just nohup run the processes in backend, this is ugly.
I am using ubuntu 18.04 system, how to make those processes to
start/stop as system daemons?

Thank you.

sayf.eddi...@gmail.com

unread,
Sep 17, 2020, 2:35:16 AM9/17/20
to Prometheus Users

this is my systemd file 

```
[Unit]
After=network.target
Description=prometheus server
Documentation=http://prometheus.io

[Service]
User=prometheus
Type=simple
EnvironmentFile=/etc/sysconfig/prometheus
ExecStart=/usr/bin/prometheus --config.file=/etc/prometheus/prometheus.yml $EXTRA_ARGS
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartSec=10
SuccessExitStatus=0
LimitNOFILE=3000000

[Install]
WantedBy=multi-user.target
```

Notice this is for centos/rhel, by the standard the environment files are under `/etc/default/prometheus` for debian based OSs, the file should contain the rest of the config (tsdb path web address and port etc)
Drop this as /usr/lib/systemd/system/prometheus.service and run `systemctl enable prometheus`

Ben Kochie

unread,
Sep 17, 2020, 2:49:29 AM9/17/20
to Amari CH, Prometheus Users

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/f8588cc5-8963-4ed0-e9a0-99d3e02ddcae%40maddoghost.com.

Brian Candler

unread,
Sep 17, 2020, 3:06:51 AM9/17/20
to Prometheus Users
Under [Service] I'd also recommend

TimeoutStopSec=300

This is to give prometheus more time to finish writing out its WAL if you do "systemctl stop" or "systemctl restart".

sayf.eddi...@gmail.com

unread,
Sep 17, 2020, 3:29:51 AM9/17/20
to Prometheus Users
Nice tip, thanks !

Amari CH

unread,
Sep 17, 2020, 4:07:45 AM9/17/20
to promethe...@googlegroups.com
Is there an easy way to migrate prometheus into apt sources so that we
can run apt update and apt install|upgrade to upgrade them?

Thanks

--
Amari CH
https://maddoghost.com/

Brian Candler

unread,
Sep 17, 2020, 6:23:29 AM9/17/20
to Prometheus Users
On Thursday, 17 September 2020 09:07:45 UTC+1, Amari CH wrote:
Is there an easy way to migrate prometheus into apt sources so that we
can run apt update and apt install|upgrade to upgrade them?


There are existing prometheus packages in the Ubuntu repositories.  Beware they may be ancient: e.g. Ubuntu 18.04 has prometheus-node-exporter 0.15.2, and prometheus 2.1.0.  Still, they may be adequate.

All you really need to deploy is the node_exporter binary and the systemd unit file to each host.  You can just copy those two files, either manually or using whatever configuration management tools you may already be using.

Amari CH

unread,
Sep 17, 2020, 6:42:56 AM9/17/20
to promethe...@googlegroups.com
Brian Candler wrote:
>
> All you really need to deploy is the node_exporter binary and the
> systemd unit file to each host.  You can just copy those two files,
> either manually or using whatever configuration management tools you may
> already be using.

Brian, do you have a biz solution for hosting industry based on
prometheus? we can pay for it. thanks.

Brian Candler

unread,
Sep 17, 2020, 6:49:42 AM9/17/20
to Prometheus Users
Reply all
Reply to author
Forward
0 new messages