Prometheus exporter


原文链接: Prometheus exporter

git@github.com:roman-vynar/pmm.docker.git

mysqld Exporter

MySQL privileges:

GRANT REPLICATION CLIENT, PROCESS, SUPER, SELECT ON . TO 'pmm'@'10.%' IDENTIFIED BY 'percona2018';
GRANT SELECT, UPDATE, DELETE, DROP ON performance_schema.* TO 'pmm'@'10.%';

mysqld-exporter:

docker rm -f db-exporter || true

docker run -d --name db-exporter -p 9104:9104 -e DATA_SOURCE_NAME="pmm:percona2018@(10.114.0.10:3306)/test" prom/mysqld-exporter
go get github.com/prometheus/mysqld_exporter
export DATA_SOURCE_NAME='login:password@(hostname:port)/'
mysqld_exporter

Node Exporter 节点监控

node_exporter:

docker run -d -p 9100:9100 --name node-exporter -v "/proc:/host/proc" -v "/sys:/host/sys" -v "/:/rootfs" --net="host" prom/node-exporter -collector.procfs /host/proc -collector.sysfs /host/sys -collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)"

go get -u -v github.com/prometheus/node_exporter
cd ~/gp/src/github.com/prometheus/node_exporter
make
./node_exporter

Redis Exporter

go get github.com/oliver006/redis_exporter
redis_exporter
# Prometheus Redis https://grafana.net/dashboards/763

docker run -p 9104:9104 -v /sys/fs/cgroup:/cgroup -v /var/run/docker.sock:/var/run/docker.sock prom/container-exporter

服务|默认端口|监控面板
----|----
prometheus| 9090
grafana| 3000
mysqld-exporter| 9104
redis-exporter| 9121|Prometheus Redis
node-exporter| 9100|Node Exporter Server Metrics
Node exporter single server
container-exporter| 9104|Docker Dashboard
nginx-lua-prometheus|n/a|Nginx Overview

# Get start
go get -v -u github.com/prometheus/prometheus/cmd/...


docker pull prom/prometheus
docker pull prom/alertmanager
# 需要挂载 /proc
docker pull prom/node-exporter
docker pull prom/blackbox-exporter
docker pull prom/container-exporter
docker pull prom/mysqld-exporter

# node_exporter 在容器中运行的不太好
go get github.com/prometheus/node_exporter

# 默认账号密码为 admin/admin
docker pull grafana/grafana

docker network create --subnet=172.18.0.0/16 mon-net

docker run --net mon-net --ip 172.18.0.10 -i -p 12000:3000 grafana/grafana
docker run --net mon-net --ip 172.18.0.20 -i -p 12001:9090 prom/prometheus

# docker run -d --restart always -v /etc/localtime:/etc/localtime:ro \

docker run -i -p 12000:3000 \
  -e "GF_SERVER_ROOT_URL=http://grafana.server.name"  \
  -e "GF_SECURITY_ADMIN_PASSWORD=secret"  \
  grafana/grafana

mysqld-exporter

    MYSQL_IP=127.0.0.1
    MYSQL_PORT=3306
    USER_ACCOUNT=foo
    PASSWORD=bar
    EXPORT_PORT=9104

    docker run --name mysql_exporter -d \
    -p ${EXPORT_PORT}:9104 \
    -e DATA_SOURCE_NAME="${USER_ACCOUNT}:${PASSWORD}@(${MYSQL_IP}:${MYSQL_PORT})/" \
    prom/mysqld-exporter \
    -e
`