docker + grafana + prometheus + Mysql

1、prometheus 部署,系统架构图

2、prometheus 部署过程

1. docker pull  prom/prometheus
2. docker run -p 9090:9090 -v /prometheus-data \
       prom/prometheus --config.file=/prometheus-data/prometheus.yml
3. prometheus.yml
global:
  scrape_interval:     15s
  evaluation_interval: 15s

scrape_configs:
  - job_name: linux
    static_configs:
      - targets: ['host:9100']
        labels:
          instance: db1

  - job_name: mysql
    static_configs:
      - targets: ['host:9104']
        labels:
          instance: db1

 - job_name: 'consul-knowledge'
    metrics_path: '/actuator/prometheus'
    consul_sd_configs:
      - server: '10.1.204.114:8500'
        services: ['knowledge-service']

3、部署exporter

$ wget https://github.com/prometheus/node_exporter/releases/download/v0.16.0/node_exporter-0.16.0.linux-amd64.tar.gz
$ wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.10.0/mysqld_exporter-0.10.0.linux-amd64.tar.gz -O mysqld_exporter-0.10.0.linux-amd64.tar.gz
$ mkdir /usr/local/services/prometheus_exporters
$ tar zxf node_exporter-0.14.0.linux-amd64.tar.gz -C /usr/local/services/prometheus_exporters --strip-components=1
$ tar zxf mysqld_exporter-0.10.0.linux-amd64.tar.gz -C /usr/local/services/prometheus_exporters --strip-components=1


运行node_exporter
$ cd /usr/local/services/prometheus_exporters
$ ./node_exporter

 

4、mysqld_exporter需要连接到Mysql,所以需要Mysql的权限,我们先为它创建用户并赋予所需的权限:

mysql> GRANT REPLICATION CLIENT, PROCESS ON *.* TO 'prom'@'localhost' identified by 'abc123';
mysql> GRANT SELECT ON performance_schema.* TO 'prom'@'localhost';


cd /usr/local/services/prometheus_exporters
$ cat << EOF > .my.cnf
[client]
user=prom
password=abc123
EOF
$ ./mysqld_exporter -config.my-cnf=".my.cnf"  

5、部署grafana

docker pull grafana/grafana

docker run -d --name=grafana -p 3000:3000 grafana/grafana

server:
https://grafana.com/dashboards/8919
mysql:
https://grafana.com/dashboards/6239

 

6、访问地址:

http://10.1.204.108:3000/d/9CWBz0bik/1-node-exporter-0-16-jian-kong-zhan-shi-kan-ban-for-prometheus?orgId=1

 

 

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值