Что такое Node Exporter? Node Exporter — это экспортер Prometheus для сбора данных о состоянии сервера с подключаемыми коллекторами метрик.
Он позволяет измерять различные ресурсы машины, такие как использование памяти, диска и процессора.
В этой статье я покажу, как установить и настроить Node Exporter в Ubuntu и CentOS с помощью systemd сервис-менеджера.
Дельный Совет: Установка системы мониторинга Prometheus с помощью Docker в Ubuntu и CentOS! Читать Далее →
Node Exporter: Установка и Настройка
Создайте непривилегированного пользователя node_exporter
:
$ sudo useradd node_exporter -s /sbin/nologin
Откройте страницу загрузки и скачайте последнюю версию скомпилированного бинарника Node Exporter:
$ wget https://github.com/prometheus/node_exporter/releases/download/v*/node_exporter-*.*-amd64.tar.gz $ tar xvfz node_exporter-*.*-amd64.tar.gz $ sudo cp node_exporter-*.*-amd64/node_exporter /usr/sbin/
Создайте файл systemd-сервиса /etc/systemd/system/node_exporter.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
Создайте sysconfig файл:
$ sudo mkdir -p /etc/sysconfig $ sudo touch /etc/sysconfig/node_exporter
Используйте этот файл, чтобы прописать опции передаваемые сервису, например:
OPTIONS="--collector.textfile.directory /var/lib/node_exporter/textfile_collector"
Чтобы узнать все доступные опции, выполните:
$ /usr/sbin/node_exporter --help
Перезапустите systemd и настройте node_exporter
на автостарт при загрузке системы:
$ sudo systemctl daemon-reload $ sudo systemctl enable node_exporter
Запустите сервис node_exporter
:
$ sudo systemctl start node_exporter
После установки Node Exporter, проверьте что метрики экспортируются:
$ curl http://localhost:9100/metrics
Добавить Источник Node Exporter в Prometheus
Теперь все, что осталось сделать — объявить серверу Prometheus о новом источнике.Это необходимо сделать в конфигурации Prometheus, поскольку Node Exporter просто отдает метрики, а Prometheus собирает их из источников, о которых он знает.
Откройте конфигурационный файл Prometheus prometheus.yml
и добавьте свою машину в раздел scrape_configs
:
scrape_configs: - job_name: 'node' static_configs: - targets: ['$NODE_IP:9100']
Перезагрузите конфигурацию Prometheus и вы сможете получить доступ к метрикам своего сервера из Prometheus!
let’s say, I have apache in one machine but I want to install node exporter on another machine. Is it possible?
Yes node exporter can run independently away on a different machine than which is running Apache
If you want node exporter to expose metrics related to Apache, make sure those metrics are visible to node exporter via a shared drive
How to configure node_exporter on centos 6 as there is no systemd ?
hey, do i have to run node _expoter on the machine i want to expose metrics of ?
i have a different admin machine , where i am running prometheus and grafana.
for prometheus to be able to scrape metrics from node_expoter , does nodeexpo have to be run on my main instance ? or can i run it on admin and expose main instance metric to node via config files and then prome can scrape off of it.