docker-compse.yml
version: '3'
services:
prometheus:
image: prom/prometheus:latest
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
- /etc/localtime:/etc/localtime:ro
ports:
- "9091:9090"
networks:
- "net"
depends_on:
- mysql
links:
- mysql:mysql
grafana:
image: grafana/grafana:latest
volumes:
- /etc/localtime:/etc/localtime:ro
ports:
- "3001:3000"
networks:
- "net"
depends_on:
- prometheus
links:
- prometheus:prometheus
mysql:
image: prom/mysqld-exporter:latest
volumes:
- /etc/localtime:/etc/localtime:ro
environment:
DATA_SOURCE_NAME: "mysql_monitor:123@(192.168.50.11:3306)/"
networks:
- "net"
networks:
net:
prometheus.yml
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'mysql'
static_configs:
- targets: ['mysql:9104']
mysqld-exporter logs
prometheus-mysql-1 | ts=2023-06-30T13:44:35.523Z caller=mysqld_exporter.go:220 level=info msg="Starting mysqld_exporter" version="(version=0.15.0, branch=HEAD, revision=6ca2a42f97f3403c7788ff4f374430aa267a6b6b)"
prometheus-mysql-1 | ts=2023-06-30T13:44:35.523Z caller=mysqld_exporter.go:221 level=info msg="Build context" build_context="(go=go1.20.5, platform=linux/amd64, user=root@c4fca471a5b1, date=20230624-04:09:04, tags=netgo)"
prometheus-mysql-1 | ts=2023-06-30T13:44:35.523Z caller=config.go:150 level=error msg="failed to validate config" section=client err="no user specified in section or parent"
prometheus-mysql-1 | ts=2023-06-30T13:44:35.523Z caller=mysqld_exporter.go:225 level=info msg="Error parsing host config" file=.my.cnf err="no configuration found"
prometheus-mysql-1 exited with code 1
i can connect mysql via mysql_monitor:123@(192.168.50.11:3306)/ so username passwd ip port was correct
please help ~