当前位置:   article > 正文

Docker下prometheus安装mysqld-exporter/redis_exporter/mongo-exporter【亲测可用】_docker redis-exporter

docker redis-exporter

一、安装mysqld-exporter

1、下载mysqld-exporter:docker pull prom/mysqld-exporter

2、根据自己配置的数据库用户名和密码进行启动

docker run -d --name mysqld_exporter -p 9104:9104 -e DATA_SOURCE_NAME="root:Newmysql55..(127.0.0.1:3306)/" prom/mysqld-exporter

3、查看启动过的容器实例:docker ps -a

4、自动启动:docker update --restart=always b3cfe4658581

5、切换root用户操作,修改prometheus配置文件

cd /usr/local/prometheus/data

编辑prometheus.yml文件:vim prometheus.yml,整下如下代码

  1. # A scrape configuration containing exactly one endpoint to scrape:
  2. # Here it's Prometheus itself.
  3. scrape_configs:
  4. # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  5. - job_name: 'prometheus'
  6. static_configs:
  7. - targets: ['192.168.184.130:9090']
  8. - job_name: 'mysql'
  9. static_configs:
  10. - targets: ['192.168.184.130:9104']

6、查看启动过的容器实例:docker ps -a

7、重启prometheus:docker restart e21b260d923d

8、重启mysqld-exporter:docker restart b3cfe4658581

9、登录prometheus进行查看:http://192.168.184.130:9090/

二、安装redis_exporter

1、下载:docker pull oliver006/redis_exporter

2、运行:docker run -d --name redis_exporter -p 9121:9121 oliver006/redis_exporter

3、自动启动:docker update --restart=always 448f012f6c68

4、切换root用户操作,修改prometheus配置文件

cd /usr/local/prometheus/data

编辑prometheus.yml文件:vim prometheus.yml,整下如下代码

  1. # A scrape configuration containing exactly one endpoint to scrape:
  2. # Here it's Prometheus itself.
  3. scrape_configs:
  4. # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  5. - job_name: 'prometheus'
  6. static_configs:
  7. - targets: ['192.168.184.130:9090']
  8. - job_name: 'mysql'
  9. static_configs:
  10. - targets: ['192.168.184.130:9104']
  11. - job_name: 'redis'
  12. static_configs:
  13. - targets: ['192.168.184.130:9121']

5、查看启动过的容器实例:docker ps -a

6、重启prometheus:docker restart e21b260d923d

三、安装mongo-exporter

mongo-exporter安装方法1:

下载:docker pull noenv/mongo-exporter:latest

创建账号密码是在navicat链接mongodb之后进行查询创建

use admin

db.createUser({user:"root",pwd:"Newmongodb55..",roles:[{role:'root',db:'admin'}]})

运行:

mkdir -p /root/docker_volume/mongodb/data

docker run -d --name mongo-explorer -p 30056:9104 noenv/mongo-exporter --mongodb.uri mongodb://root:Newmongodb55..@192.168.59.130:27017

注意:上面的9104端口是必须的,而且它与mysql-exporter的端口都是9104

查看启动过的容器实例:docker ps -a

自动启动:docker update --restart=always 436ac6f83c60

切换root用户操作,修改prometheus配置文件

cd /usr/local/prometheus/data

编辑prometheus.yml文件:vim prometheus.yml,整下如下代码

  1. # A scrape configuration containing exactly one endpoint to scrape:
  2. # Here it's Prometheus itself.
  3. scrape_configs:
  4. # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  5. - job_name: 'prometheus'
  6. static_configs:
  7. - targets: ['192.168.184.130:9090']
  8. - job_name: 'mysql'
  9. static_configs:
  10. - targets: ['192.168.184.130:9104']
  11. - job_name: 'redis'
  12. static_configs:
  13. - targets: ['192.168.184.130:9121']
  14. - job_name: 'mongo'
  15. static_configs:
  16. - targets: ['192.168.184.130:9104']

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

闽ICP备14008679号