Всем привет!
Хочу Вам рассказать, как настроить мониторинг Atlassian Confluence с помощью Prometheus Exporter for Confluence плагина, Prometheus и Grafana.
Для того, чтобы воспроизвести все примеры, Вам понадобятся Git, Docker и Python. Вы можете посмотреть видео по этой статье вот здесь.
Мы будем запускать Confluence, Prometheus и Grafana в докере. Мы будем получать метрики не только из плагина Prometheus for Confluence, но и из cadviser и node-exporter. Это позволит нам мониторить такие параметры, как объем памяти в контейнере, загрузку cpu в контейнере и другие.
Вот структура папок после того, как все файлы из этой статьи будут созданы:
- tutorial
- confluence
docker-compose.yml
- dc-app-performance-toolkit
- monitoring
docker-compose.yml
- data
- prometheus
- config
prometheus.yml
Запускаем Confluence
Мы будем запускать Confluence в докере от Idalko. Создайте файл docker-compose.yml:
version: '3'
services:
confluence:
image: idalko/atlassian-confluence
environment:
- DISABLE_NOTIFICATIONS=TRUE
- JVM_MINIMUM_MEMORY=2G
- JVM_MAXIMUM_MEMORY=4G
- CONF_ARGS=-Datlassian.plugins.enable.wait=300
volumes:
- ./data/confluence:/opt/atlassian/confluence/data
ports:
- 8090:8090
restart: always
confluencedb:
image: postgres:9.6
environment:
- POSTGRES_PASSWORD=secret
- POSTGRES_USER=confluence
- POSTGRES_DB=confluence
volumes:
- ./data/db:/var/lib/postgresql/data
restart: always
Запустите в терминале вот такую команду:
docker-compose up
Зайди в браузере вот по такому адресу:
http://localhost:8090
При настройке Confluence введите вот такие данные для базы данных:
hostname = confluencedb
port = 5432
database name = confluence
username = confluence
password = confluence
Готовим тестовые данные
Мы будем использовать инструмент dc-app-performance-toolkit. Для его корректной работы нужно, чтобы в Confluence были страницы и блоги. Вы можете использовать свой бэкап или создать данные с помощью плагина Data Generator for Confluence.
Запускаем Prometheus и Grafana
Создайте еще один docker-compose.yml файл:
version: '3'
services:
prometheus:
image: prom/prometheus:latest
container_name: monitoring_prometheus
restart: unless-stopped
volumes:
- ./data/prometheus/config:/etc/prometheus/
- ./data/prometheus/data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
expose:
- 9090
ports:
- 9090:9090
links:
- cadvisor:cadvisor
- node-exporter:node-exporter
node-exporter:
image: prom/node-exporter:latest
container_name: monitoring_node_exporter
restart: unless-stopped
ports:
- 9100:9100
expose:
- 9100
cadvisor:
image: google/cadvisor:latest
container_name: monitoring_cadvisor
restart: unless-stopped
volumes:
- /:/rootfs:ro
- /var/run:/var/run:rw
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
ports:
- 8080:8080
expose:
- 8080
grafana:
image: grafana/grafana:latest
container_name: monitoring_grafana
restart: unless-stopped
links:
- prometheus:prometheus
volumes:
- ./data/grafana:/var/lib/grafana
ports:
- 3000:3000
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
- GF_USERS_ALLOW_SIGN_UP=false
Добавьте в hosts файл вот такую строчку:
127.0.0.1 host.docker.internal
Это нужно для того, что Вам придется обращаться к Confluence из Prometheus. Confluence работает к localhost:8090. Если Вы из контейнера Prometheus обратитесь по localhost:8090, то localhost будет рассматриваться как сам контейнер. Поэтому Вы будете обращаться по алиасу host.docker.internal:8090. В этом случае запрос дойдет куда нужно.
Создайте файл prometheus.yml в папке data/prometheus/config:
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090','cadvisor:8080','node-exporter:9100']
- job_name: 'confluence'
scheme: http
metrics_path: '/plugins/servlet/prometheus/metrics'
static_configs:
- targets: ['host.docker.internal:8090']
Теперь запустите:
docker-compose up
После этого перейдите в Grafana:
http://localhost:3000
И настройте источник данных Prometheus и добавьте дэшборд из этого json. Адрес Prometheus – http://prometheus:9090.
Запускаем тесты
Склонируйте репозиторий битбакет:
git clone https://github.com/atlassian/dc-app-performance-toolkit.git
Настройте Ваше окружение в соответствии с файлом Readme.
Внесите изменения в файл dc-app-performance-toolkit/app/confluence.yml:
env:
application_hostname: localhost
application_protocol: http
application_port: 8090
application_postfix:
admin_login: admin
admin_password: admin
concurrency: 5
test_duration: 1m
Запустите тесты:
bzt confluence.yml
Алексей привет, при запуске docker-compose.yml: и затем старте БД не стартует, пишет
PostgreSQL Database directory appears to contain a database; Skipping initialization
FATAL: data directory “/var/lib/postgresql/data” has wrong ownership
HINT: The server must be started by the user that owns the data directory.
+ у тебя database name = 5432 , а нужно
name = confluence
Спасибо! Поправил.
Установил заново, ошибка после инсталляции, похоже что прав не хватает
waiting for server to start….FATAL: data directory “/var/lib/postgresql/data” has wrong ownership
С Confluence проблем нет.
The files belonging to this database system will be owned by user “postgres”.
This user must also own the server process.
The database cluster will be initialized with locale “en_US.utf8”.
The default database encoding has accordingly been set to “UTF8”.
The default text search configuration will be set to “english”.
Data page checksums are disabled.
fixing permissions on existing directory /var/lib/postgresql/data … ok
creating subdirectories … ok
selecting default max_connections … 100
selecting default shared_buffers … 128MB
selecting default timezone … Etc/UTC
selecting dynamic shared memory implementation … posix
creating configuration files … ok
running bootstrap script … ok
performing post-bootstrap initialization … ok
syncing data to disk … ok
WARNING: enabling “trust” authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
–auth-local and –auth-host, the next time you run initdb.
Success. You can now start the database server using:
pg_ctl -D /var/lib/postgresql/data -l logfile start
waiting for server to start….FATAL: data directory “/var/lib/postgresql/data” has wrong ownership
HINT: The server must be started by the user that owns the data directory.
stopped waiting
pg_ctl: could not start server
Нашел решение, для БД нужно
вместо
volumes:
– ./data/db:/var/lib/postgresql/data
указать
volumes:
– /var/lib/postgresql/data
Связано с особенность разворачивания докера на window 10
Спасибо, что написал!