> For the complete documentation index, see [llms.txt](https://utm-1.gitbook.io/utm-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://utm-1.gitbook.io/utm-docs/dokumentaciya/utm-it/programmnoe-obespechenie/virtualnye-servera/nastroiki/nastroika-monitoringa.md).

# Настройка мониторинга

## Ссылки

Установка Prometheus + Alertmanager + node\_exporter на Linux: [www.dmosk.ru](https://www.dmosk.ru/instruktions.php?object=prometheus-linux#node)

Шпаргалка по установке и настройке различных Prometheus exporter на Linux: [www.dmosk.ru](https://www.dmosk.ru/miniinstruktions.php?mini=exporter-prometheus)

Вас много, а я одна: обзорная система мониторинга на Prometheus и Grafana: [habr.com](https://habr.com/ru/companies/doubletapp/articles/736602/)

doubletapp / habr-dt-prometheus: [github.com](https://github.com/doubletapp/habr-dt-prometheus/blob/master/prometheus/alerts.yml)

Настройка правил алертинга в Grafana: [platform-docs.v-serv.ru](https://platform-docs.v-serv.ru/online-documentation/home/user/maintain-tools/monitoring/2.1.0/alerting/alert-plugin-configure/)

## Информация

Для подключения Linux сервера к мониторингу Prometheus необходимо выполнить несколько шагов:

1. На Linux сервер установить node\_exporter
2. В настройках Prometheus подключить target со ссылкой на Linux сервер который необходимо мониторить

## Установка node\_exporter

Действия выполняются на сервере Linux, который необходимо подключить к мониторингу

<details>

<summary>Выполнить следующие действия</summary>

На [странице ](https://prometheus.io/download/#node_exporter)получить ссылку для скачивания node\_exporter

{% hint style="info" %}
<https://github.com/prometheus/node_exporter/releases/download/v1.10.2/node_exporter-1.10.2.linux-amd64.tar.gz>
{% endhint %}

Выполнить на подключаемом Linux сервере:

```bash
sudo su
mkdir $HOME/tmp
cd $HOME/tmp
# Скачать дистрибутив
wget https://github.com/prometheus/node_exporter/releases/download/v1.10.2/node_exporter-1.10.2.linux-amd64.tar.gz
```

Выполнить установку

```bash
# Распакуем скачанный архив:
tar -zxf node_exporter-*.linux-amd64.tar.gz
# и перейдем в каталог с распакованными файлами:
cd node_exporter-*.linux-amd64
# Копируем исполняемый файл в bin:
cp node_exporter /usr/local/bin/
# Выходим из каталога и удаляем исходник:
cd .. && rm -rf node_exporter-*.linux-amd64/ && rm -f node_exporter-*.linux-amd64.tar.gz
```

Назначить права

```bash
# Создаем пользователя nodeusr:
useradd --no-create-home --shell /bin/false nodeusr
# Задаем владельца для исполняемого файла:
chown -R nodeusr:nodeusr /usr/local/bin/node_exporter
```

Настройка автозапуска

```bash
# Создаем файл node_exporter.service в systemd:
nano /etc/systemd/system/node_exporter.service
```

Содержимое файла `/etc/systemd/system/node_exporter.service`

```
[Unit]
Description=Node Exporter Service
After=network.target

[Service]
User=nodeusr
Group=nodeusr
Type=simple
ExecStart=/usr/local/bin/node_exporter --collector.systemd
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure

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

{% hint style="info" %}
Примечание:

Можно указать

* вариант 1 (сбор метрик в разрезе каждой службы systemd):

```
ExecStart=/usr/local/bin/node_exporter --collector.systemd
```

* вариант 2 (сбор метрик целиком по всему по серверу):

```
ExecStart=/usr/local/bin/node_exporter
```

Информация [отсюда](https://www.dmosk.ru/instruktions.php?object=prometheus-linux#metric)
{% endhint %}

Включаем:

```bash
# Разрешаем автозапуск:
systemctl enable node_exporter
# Запускаем службу:
systemctl start node_exporter

# Или если нужно перезапустить
systemctl daemon-reload
systemctl restart node_exporter
```

Проверка.

Открываем веб-браузер и переходим по адресу http\://\<IP-адрес сервера или клиента>:9100/metrics — мы увидим метрики, собранные node\_exporter:

![Метрики, собранные node\_exporter](https://www.dmosk.ru/img/instruktions/prometheus-linux-06.jpg)

```
http://192.168.4.0:9100/metrics
```

Установка завершена.

</details>

## Настройка Prometheus

### Регистрация target

В файле `argocd\env-prod\apps\monitoring\prometheus\values.yaml`&#x20;

<details>

<summary>Изменения в файле <code>argocd\env-prod\apps\monitoring\prometheus\values.yaml</code></summary>

Добавить ip сервера в секцию&#x20;

prometheus\prometheusSpec\additionalScrapeConfigs

```yaml
    additionalScrapeConfigs: |
      - job_name: 'node_exporter_clients'
        scrape_interval: 5s
        static_configs:
          - targets:
            - 192.168.4.0:9100
```

Сделать коммит в репозиторий GitHub с обновлением файла `values.yaml`&#x20;

Дождаться, когда Argo CD обновить приложение k8s-prometheus.

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://utm-1.gitbook.io/utm-docs/dokumentaciya/utm-it/programmnoe-obespechenie/virtualnye-servera/nastroiki/nastroika-monitoringa.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
