当前位置:   article > 正文

Docker安装Prometheus,Grafana展示数据_-e data_source_name

-e data_source_name
# 因为目录/data用户组和用户是jtserver,docker执行命令是root用户,先将/data/lib/prometheus给其他组权限才能执行
sudo mkdir /data/lib/prometheus
sudo chown 767 /data/lib/prometheus

docker run -d \
  -p 9090:9090 \
  --restart=always \
  --name prometheus \
  -v /data/lib/prometheus:/data/lib/prometheus \
  -v /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \
  prom/prometheus \
  --config.file=/etc/prometheus/prometheus.yml \
  --storage.tsdb.path=/data/lib/prometheus
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
docker run -d -p 9100:9100 \
  -v "/proc:/host/proc:ro" \
  -v "/sys:/host/sys:ro" \
  -v "/:/rootfs:ro" \
  --net="host" \
  --restart=always \
  prom/node-exporter \
    --collector.procfs /host/proc \
    --collector.sysfs /host/sys \
    --collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)"
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
docker run -d \
  -p 3000:3000 \
  --restart=always \
  --name=grafana \
  -e "GF_SECURITY_ADMIN_PASSWORD=admin" \
  -e "GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource,raintank-worldping-app,grafana-piechart-panel" \
  -v /data/lib/grafana:/var/lib/grafana \
  grafana/grafana
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

docker安装mysql_exporter

  • 下载mysql_exporter镜像
docker pull prom/mysqld-exporter
  • 1
  • mysql_exporter需要链接数据库,mysql创建mysql_monitor用户,添加PROCESS, REPLICATION CLIENT权限
mysql> INSERT INTO mysql.user(Host,User,Password) VALUES("localhost", "mysql_monitor", password("mysql_monitor")); 
mysql> GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'mysql_monitor'@'localhost' IDENTIFIED BY 'mysql_monitor';
mysql> GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'mysql_monitor'@'%' IDENTIFIED BY 'mysql_monitor';
mysql> FLUSH PRIVILEGES;
  • 1
  • 2
  • 3
  • 4
  • docker启动mysql_exporter镜像
docker run -d -p 9104:9104 \
  --name=mysqld-exporter \
  --restart=always \
  -e DATA_SOURCE_NAME="mysql_monitor:mysql_monitor@(172.17.0.1:3306)/" \
  prom/mysqld-exporter
  • 1
  • 2
  • 3
  • 4
  • 5

参考
- https://github.com/prometheus/node_exporter
- https://github.com/grafana/grafana-docker
- http://www.ywnds.com/?p=9668

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/428855?site
推荐阅读
相关标签
  

闽ICP备14008679号