> 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/resheniya/monitoring/prometheus/monitoring-mysql.md).

# Мониторинг MySQL

## Ссылки

prometheus / mysqld\_exporter: [github.com](https://github.com/prometheus/mysqld_exporter)

Мониторинг MySQL и MariaDB с помощью Prometheus MySQL Exporter: [arenda-server.cloud](https://yandexwebcache.net/yandbtm?fmode=inject\&tm=1764425112\&tld=ru\&lang=ru\&la=1762412160\&text=mysql+exporter+prometheus\&url=https%3A//arenda-server.cloud/blog/monitoring-mysql-i-mariadb-s-pomoshhju-prometheus-mysql-exporter/\&l10n=ru\&mime=html\&sign=f4f26c92749493fc83026283b2e3817e\&keyno=0)

## Установка MySQL exporter

Описано [тут](https://utm-1.gitbook.io/utm-docs/~/revisions/K0NqCTNVpkF7jYirWV0q/instrukcii/dokumentaciya/subd/mysql/instansy/utm-mysql8-na-utm-db4-9)

## Настройка 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: 'mysql_exporter'
        static_configs:
          - targets:
            - 192.168.4.9:9104
            - <ip>:9104
```

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

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

</details>

### Настройка оповещений

{% hint style="info" %}
**ПРОРАБОТАТЬ!!!**
{% endhint %}

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

Каталог в дашбордах: `MySQL`

### Импорт дашбордов из Argo CD

В файле `argocd\env-prod\apps\monitoring\grafana\values.yaml` добавить

<details>

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

```yaml
dashboardProviders:
  dashboardproviders4.yaml:
    apiVersion: 1
    providers:
    - name: 'mysql'
      orgId: 1
      folder: 'MySQL'
      type: file
      disableDeletion: false
      editable: true
      options:
        path: /var/lib/grafana/dashboards/mysql
        foldersFromFilesStructure: false

dashboards:
  mysql:
    7362-mysql-overview:
      gnetId: 7362
      revision: 5
      datasource: Prometheus
    14057-mysql:
      gnetId: 14057
      revision: 1
      datasource: Prometheus
```

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

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

</details>

#### Дашборды

<details>

<summary>Описание импортируемых дашбордов</summary>

#### MySQL Overview

Ссылка: [grafana.com](https://grafana.com/grafana/dashboards/7362-mysql-overview/)

ID: 7362

<figure><img src="/files/A8dZTilSvYgCwpjkfRve" alt=""><figcaption></figcaption></figure>

#### MySQL Exporter Quickstart and Dashboard

Ссылка: [grafana.com](https://grafana.com/grafana/dashboards/14057-mysql/)

ID: 14057

<figure><img src="/files/019cmqtspJoSWEME3nsz" alt=""><figcaption></figcaption></figure>

</details>

### Ручной импорт дашбордов

В Grafana: Dashboards → Import → вставь ID  → выбери источник Prometheus.

#### Дашборды

<details>

<summary>Описание импортируемых дашбордов</summary>

#### MySQL Dashboard

Ссылка: [grafana.com](https://grafana.com/grafana/dashboards/14031-mysql-dashboard/)

ID: 14031

<figure><img src="/files/RcBZWxJxcYSjiT8vOT0A" alt=""><figcaption></figcaption></figure>

</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/resheniya/monitoring/prometheus/monitoring-mysql.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.
