标签:cte inter etc line init source ons compose 操作
这篇文章本来是打算使用pmm 进行数据库监控的,但是居然参考官方文档使用docker 运行起来有点问题,所以直接改用
exporter 进行处理,但是比pmm 弱好多
说明,以上图比较早了, 实际上也可以监控mongodb,同时也是使用exporter处理的,只是pmm 基于grafanna 的扩展比较多
对于系统分析指标更全
version: "3"
services:
pgloader-mysql:
image: dimitri/pgloader
command: pgloader mysql://root:dalongrong@mysql/gogs postgresql://postgres:dalong@postgres:5432/appdemo
gogs:
image: gogs/gogs
ports:
- "10022:22"
- "3001:3000"
volumes:
- ./data/gogs:/data
mysqlexporter:
image: prom/mysqld-exporter
ports:
- "9104:9104"
environment:
- "DATA_SOURCE_NAME=root:dalongrong@(mysql:3306)/"
grafana:
image: grafana/grafana
ports:
- "3000:3000"
prometheus:
image: prom/prometheus
volumes:
- "./prometheus.yml:/etc/prometheus/prometheus.yml"
ports:
- "9090:9090"
mysql:
image: mysql:5.7.16
ports:
- 3306:3306
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
environment:
MYSQL_ROOT_PASSWORD: dalongrong
MYSQL_DATABASE: gogs
MYSQL_USER: gogs
MYSQL_PASSWORD: dalongrong
TZ: Asia/Shanghai
postgres:
build:
context: ./pg
dockerfile: Dockerfile
ports:
- "5432:5432"
environment:
- "POSTGRES_PASSWORD:dalong"
pgexporter:
image: wrouesnel/postgres_exporter:latest
ports:
- 9187:9187
environment:
- DATA_SOURCE_NAME=postgresql://postgres:dalong@postgres:5432/postgres_exporter?sslmode=disable
scrape_configs:
- job_name: pg
metrics_path: /metrics
scrape_interval: 10s
scrape_timeout: 10s
static_configs:
- targets: [‘pgexporter:9187‘]
- job_name: mysql
metrics_path: /metrics
scrape_interval: 10s
scrape_timeout: 10s
static_configs:
- targets: [‘mysqlexporter:9104‘]
FROM postgres:latest
RUN set -ex; \
apt-get update; \
apt-get install -y gnupg apt-transport-https; \
echo ‘deb https://repo.percona.com/apt stretch main‘ > /etc/apt/sources.list.d/percona.list; \
apt-get update && apt-get install -y --allow-unauthenticated pmm-client; \
apt-get remove --purge -y gnupg apt-transport-https; \
apt-get autoremove -y --purge; \
rm -rf /var/lib/apt/lists/* \
true
COPY init.sql /docker-entrypoint-initdb.d/
COPY initpmm.sh /root/
docker-compose up -d
以上是一个简单的集成,实际上pmm还是一个不错的选择,后边重新配置下,运行起来,pmm还是不错的数据库监控工具。
https://grafana.com/grafana/dashboards/6742/revisions
https://grafana.com/grafana/dashboards/6239/revisions
https://github.com/rongfengliang/mysql-pg-exporter-prometheus-grafana-docker-compose
promethues exporter+ grafana 监控pg+mysql
标签:cte inter etc line init source ons compose 操作
原文地址:https://www.cnblogs.com/rongfengliang/p/11305138.html