version: “3.8”
services:
mariadb:
image: mariadb:alpine-${MYSQL_VERSION}
container_name: ${NAMESPACE}-mariadb
build:
context: .docker/bunkerized-mariadb
dockerfile: Dockerfile
args:
MARIABD_VERSION: ${MYSQL_VERSION}
environment:
ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
USER_DATABASE: ${MYSQL_DATABASE}
USER_NAME: ${MYSQL_USER}
USER_PASSWORD: ${MYSQL_PASSWORD}
USER_PRIVILEGES: ALTER, CREATE, DELETE, DROP, INDEX, INSERT, REFERENCES, SELECT, UPDATE
SKIP_SHOW_DATABASE: "OFF" # If set to ON, will deny the SHOW DATABASES statement to regular users.
PASSWORD_LENGTH: ${MYSQL_PASSWORD_LENGTH}
LOGROTATE_MINSIZE: 10M
LOGROTATE_MAXAGE: 7
ROOT_HOST: "%"
ports:
- 3307:3306
# - 80:80
networks:
- internal
- web
volumes:
- mysql-data:/var/lib/mysql
- mysql-logs:/var/log/mysql
- certs-data:/etc/letsencrypt
- ./shared/config/mysql:/custom.cnf.d
command:
- --slow_query_log=ON
- --slow_query_log_file=/var/log/mysql/slowlog.log
- --long_query_time=1
- --log_slow_verbosity=full
- --query_response_time_stats=ON
- --performance-schema=ON
- --innodb_monitor_enable=all
grafana used for graphing mysql data
grafana:
image: grafana/grafana
container_name: ${NAMESPACE}-grafana
ports:
- '3000:3000'
networks:
- internal
- web
depends_on:
- mariadb
- mysql_exporter
- prometheus
- clickhouse
volumes:
- grafana-data:/var/lib/grafana
- ./shared/config/grafana/provisioning/:/etc/grafana/provisioning/
- ./shared/config/grafana/dashboards/:/var/lib/grafana/dashboards/
environment:
GF_INSTALL_PLUGINS: "percona-percona-app,grafana-piechart-panel,vertamedia-clickhouse-datasource,isaozler-paretochart-panel,digiapulssi-breadcrumb-panel"
GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: "grafana-piechart-panel,vertamedia-clickhouse-datasource,digiapulssi-breadcrumb-panel"
# GF_SECURITY_ADMIN_USER: "admin"
# GF_SECURITY_ADMIN_PASSWORD: "admin"
restart: unless-stopped
clickhouse:
image: yandex/clickhouse-server
container_name: ${NAMESPACE}-clickhouse
networks:
- internal
# ports:
# - 8123:8123
# - "9000:9000"
# - "9009:9009"
ulimits:
nofile:
soft: 262144
hard: 262144
volumes:
- clickhouse-data:/var/lib/clickhouse
- ./shared/data/clickhouse:/dump
- ./shared/config/clickhouse/config.xml:/etc/clickhouse-server/config.xml:rw
# - ./shared/config/clickhouse/initdb:/docker-entrypoint-initdb.d
restart: unless-stopped
tool to connect to mysql instance, and allow prometheus to collect mysql stats
mysql_exporter:
image: prom/mysqld-exporter
container_name: ${NAMESPACE}-mysqld-exporter
environment:
DATA_SOURCE_NAME: root:${MYSQL_ROOT_PASSWORD}@(mariadb:3306)/${MYSQL_DATABASE}?
# ports:
# - '9104:9104'
networks:
- internal
command:
- --collect.auto_increment.columns
- --collect.binlog_size
- --collect.info_schema.processlist
- --collect.info_schema.query_response_time
- --collect.engine_innodb_status
- --collect.engine_tokudb_status
- --collect.global_status
restart: unless-stopped
prometheus stores and handles timeseries data for statistics around mysql
prometheus:
image: prom/prometheus
container_name: ${NAMESPACE}-prometheus
networks:
- internal
# ports:
# - 9090:9090
volumes:
- ./shared/config/prometheus:/etc/prometheus
restart: unless-stopped
# Percona monitoring tools
pmm-data:
image: percona/pmm-server:2
container_name: ${NAMESPACE}-pmm-data
hostname: pmm-data
volumes:
- pmm-data:/srv
networks:
- internal
entrypoint: /bin/true
restart: unless-stopped
pmm-server:
image: percona/pmm-server:2
hostname: pmm-server
container_name: ${NAMESPACE}-pmm-server
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
expose:
- "443"
# can't connect to the server trough proxy
ports:
- "4443:443"
networks:
- internal
volumes_from:
- pmm-data
restart: unless-stopped
pmm-client:
image: perconalab/pmm-client:2
hostname: pmm-client-zabbix
container_name: pmm-client
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
depends_on:
- mariadb
- pmm-server
environment:
- PMM_AGENT_CONFIG_FILE=/usr/local/percona/pmm2/pmm-agent.yaml
networks:
- internal
volumes:
- ./shared/config/pmm2/pmm-agent.yaml:/usr/local/percona/pmm2/pmm-agent.yaml
restart: unless-stopped
telegraf:
image: telegraf:1.16-alpine
container_name: ${NAMESPACE}-telegraf
depends_on:
- influxdb
# ports:
# - '8125:8125/udp'
volumes:
- ./shared/config/telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro
networks:
- internal
restart: unless-stopped
influxdb:
image: influxdb:1.8-alpine
container_name: ${NAMESPACE}-influxdb
env_file: .env
# ports:
# - '8086:8086'
networks:
- internal
volumes:
- ./shared/data/influxdb/imports:/imports
- influxdb-data:/var/lib/influxdb
restart: unless-stopped
networks:
internal:
driver: bridge
web:
external: true
volumes:
mysql-data:
clickhouse-data:
grafana-data:
influxdb-data:
pmm-data:
mysql-logs:
driver_opts:
type: none
o: bind
device: ${PWD}/shared/logs/mysql