> 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-keycloak.md).

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

## Ссылки

Configuring the Management Interface: [www.keycloak.org](https://www.keycloak.org/server/management-interface)

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

Экспортер для предоставления метрик keycloak устанавливается совместно с самим keycloak в том же Docker контейнере.

Включается с помощью параметра окружения:

```yaml
    environment:
      KC_METRICS_ENABLED: true
      KC_METRICS_PROMETHEUS: true
      KC_METRICS_EXPORTER_PROMETHEUS: true
      KC_HTTP_MANAGEMENT_PORT: 9000
```

И доступ осуществляется чере порт 9000

<http://192.168.4.0:9000/metrics>

## Настройка 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: 'keycloak_exporter'
        scheme: http
        metrics_path: '/metrics'
        static_configs:
          - targets:
            - 192.168.4.0:9000
```

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

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

</details>

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

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

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

### Импорт дашбордов из 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:
    - name: 'keycloak'
      orgId: 1
      folder: 'Keycloak'
      type: file
      disableDeletion: false
      editable: true
      options:
        path: /var/lib/grafana/dashboards/keycloak
        foldersFromFilesStructure: false
```

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

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

</details>

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

<details>

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

#### KeyCloak Metrics

Ссылка: [grafana.com](https://grafana.com/grafana/dashboards/14390-keycloak-metrics/)

ID: 14390

<figure><img src="/files/6F7ZtkEuPVAX9eJVPx21" alt=""><figcaption></figcaption></figure>

</details>

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

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

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

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

<details>

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

Пока нет

</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-keycloak.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.
