Saturday, May 25, 2019

Node_exporter Installation as service


This Article tells you to deploy node_expoter on RPM-based systems.

1. download Node_exporter from https://prometheus.io/download/#node_exporter

2. Create a dedicated user say node_exporter to run Node_exporter as a service.
adduser --no-create-home -s /sbin/nologin node_exporter

3. Create a Unit file for Node_exporter
touch /usr/lib/systemd/system/node_exporter.service
Add the below content to the file created above
[Unit]
Description=Node Exporter

[Service]
User=node_exporter
EnvironmentFile=/etc/sysconfig/node_exporter
ExecStart=/usr/sbin/node_exporter $OPTIONS

[Install]
WantedBy=multi-user.target

4. Create the configuration file specified in unit file
vim /etc/sysconfig/node_exporter
Add the below content to the file created above
OPTIONS="--collector.systemd --collector.mountstats --collector.textfile.directory /var/lib/node_exporter/textfile_collector"


5. Create directories specified in the configuration file and owner node_exporter.
mkdir -p /var/lib/node_exporter/textfile_collector 
chown -Rv /var/lib/node_exporter

6. Start Node_exporter as service by running the below command 
systemctl daemon-reload
systemctl start node_exporter.service
systemctl status node_exporter -l

Node_exporter setup as service has been completed successfully.


Note: Node_exporter default port is 9100 and can be used other like port 1234 with the option --web.listen-address
So /etc/sysconfig/node_exporter will become as follows.

OPTIONS="--collector.systemd --collector.mountstats --collector.textfile.directory /var/lib/node_exporter/textfile_collecto--web.listen-address=:1234"

No comments:

Post a Comment

Linux Tutorial - 12. Process Management

  Process Management! The wheels are in motion Introduction Linux in general is a fairly stable system. Occasionally, things do go wrong how...