bind_exporter example

bind_exporter, from here: https://github.com/prometheus-community/bind_exporter/releases/

Create a prometheus user and group:

# groupadd --system prometheus

# useradd -s /sbin/nologin --system -g prometheus prometheus

Create the bind_exporter.service file for systemd:

# tee /etc/systemd/system/bind_exporter.service<<EOF

[Unit]

Description=Prometheus

Documentation=https://github.com/digitalocean/bind_exporter

Wants=network-online.target

After=network-online.target

[Service]

Type=simple

User=prometheus

Group=prometheus

ExecReload=/bin/kill -HUP $MAINPID

ExecStart=/usr/local/bin/bind_exporter --bind.pid-file=/var/run/named/named.pid --bind.timeout=20s --web.listen-address=0.0.0.0:9153 --web.telemetry-path=/metrics --bind.stats-url=http://localhost:8053/ --bind.stats-groups=server,view,tasks

SyslogIdentifier=prometheus

Restart=always

[Install]

WantedBy=multi-user.target

EOF

Enable the service at boot

# systemctl enable bind_exporter.service

node_exporter example

plain old node_exporter, from here: https://github.com/prometheus/node_exporter/releases

Create a prometheus user and group:

You can use different user accounts for different services, most of these run on different hosts for me, so i'm fine with a generic user, but assess the risk for your own use case.

# groupadd --system prometheus

# useradd -s /sbin/nologin --system -g prometheus prometheus

Create the node_exporter.service file for systemd:

# sudo tee /etc/systemd/system/node_exporter.service<<EOF

[Unit]

Description=Prometheus node_exporter

Documentation=https://github.com/prometheus/node_exporter/releases

Wants=network-online.target

After=network-online.target

[Service]

Type=simple

User=prometheus

Group=prometheus

ExecReload=/bin/kill -HUP $MAINPID

ExecStart=/usr/local/bin/node_exporter 20s --web.listen-address=0.0.0.0:9100 --web.telemetry-path=/metrics

SyslogIdentifier=prometheus

Restart=always

[Install]

WantedBy=multi-user.target

EOF

Enable the service at boot

# systemctl enable node_exporter.service