1. Create user and directory
- user/group name : node_exporter
$ useradd --no-create-home --shell /bin/false node_exporter
$ cat /etc/passwd | grep node_exporter
node_exporter:x:1001:1001::/home/node_exporter:/bin/false
$ grep node_exporter /etc/group
node_exporter:x:1001:
2. Installing node_exporter install and creating config file/directory
- download node_exporter from https://prometheus.io/download/
$ tar zxvf node_exporter-1.6.0.linux-amd64.tar.gz
$ cd node_exporter-1.6.0.linux-amd64/
$ cp node_exporter /usr/sbin
$ touch touch /etc/sysconfig/node_exporter
$ mkdir -p /var/lib/node_exporter/textfile_collector/
3. Change ownership
$ chown node_exporter:node_exporter /usr/sbin/node_exporter
$ chown node_exporter:node_exporter /etc/sysconfig/node_exporter
$ chown node_exporter:node_exporter /var/lib/node_exporter
$ chown node_exporter:node_exporter /var/lib/node_exporter/textfile_collector
4. Creating systemd config
- systemd config
$ vi /etc/systemd/system/prometheus.service
[Unit]
Description=Node Exporter
[Service]
User=node_exporter
EnvironmentFile=/etc/sysconfig/node_exporter
ExecStart=/usr/sbin/node_exporter $OPTIONS
[Install]
WantedBy=multi-user.target
- environment config (ex OPTIONS)
$ vi /etc/sysconfig/node_exporter
OPTIONS="--collector.textfile.directory /var/lib/node_exporter/textfile_collector"
5. Enable/start service
$systemctl daemon-reload
$ systemctl enable node_exporter
Created symlink /etc/systemd/system/multi-user.target.wants/node_exporter.service → /etc/systemd/system/node_exporter.service.
$ systemctl start node_exporter
$ systemctl status node_exporter
● node_exporter.service - Node Exporter
Loaded: loaded (/etc/systemd/system/node_exporter.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2023-06-30 09:05:39 KST; 5s ago
Main PID: 3875 (node_exporter)
Tasks: 6 (limit: 50220)
Memory: 5.2M
CGroup: /system.slice/node_exporter.service
└─3875 /usr/sbin/node_exporter --collector.textfile.directory /var/lib/node_exporter/textfile_collector
Jun 30 09:05:39 nodeExporter node_exporter[3875]: ts=2023-06-30T00:05:39.869Z caller=node_exporter.go:117 level=info collector=thermal_zone
Jun 30 09:05:39 nodeExporter node_exporter[3875]: ts=2023-06-30T00:05:39.869Z caller=node_exporter.go:117 level=info collector=time
Jun 30 09:05:39 nodeExporter node_exporter[3875]: ts=2023-06-30T00:05:39.869Z caller=node_exporter.go:117 level=info collector=timex
Jun 30 09:05:39 nodeExporter node_exporter[3875]: ts=2023-06-30T00:05:39.869Z caller=node_exporter.go:117 level=info collector=udp_queues
Jun 30 09:05:39 nodeExporter node_exporter[3875]: ts=2023-06-30T00:05:39.869Z caller=node_exporter.go:117 level=info collector=uname
Jun 30 09:05:39 nodeExporter node_exporter[3875]: ts=2023-06-30T00:05:39.869Z caller=node_exporter.go:117 level=info collector=vmstat
Jun 30 09:05:39 nodeExporter node_exporter[3875]: ts=2023-06-30T00:05:39.869Z caller=node_exporter.go:117 level=info collector=xfs
Jun 30 09:05:39 nodeExporter node_exporter[3875]: ts=2023-06-30T00:05:39.869Z caller=node_exporter.go:117 level=info collector=zfs
Jun 30 09:05:39 nodeExporter node_exporter[3875]: ts=2023-06-30T00:05:39.870Z caller=tls_config.go:274 level=info msg="Listening on" address=[::]:9100
Jun 30 09:05:39 nodeExporter node_exporter[3875]: ts=2023-06-30T00:05:39.870Z caller=tls_config.go:277 level=info msg="TLS is disabled." http2=false address=[::]>
'IT > opensource' 카테고리의 다른 글
Grafana install on redhat / centos (0) | 2023.06.29 |
---|---|
Prometheus systemd / systemctl (0) | 2023.06.29 |