Prometheus 监控Rabbitmq

系统:CentOS6.6
安装 go语言
[root@server0 ~]# tar zxvf go1.8.1.linux-amd64.tar.gz -C /usr/local
[root@server0 ~]# mkdir /Golang
[root@server0 ~]# vim /etc/profile

export GOROOT=/usr/local/go 
export GOBIN=$GOROOT/bin
export GOPKG=$GOROOT/pkg/tool/linux_amd64 
export GOARCH=amd64
export GOOS=linux
export GOPATH=/Golang
export PATH=$PATH:$GOBIN:$GOPKG:$GOPATH/bin

[root@server0 ~]# source /etc/profile
[root@server0 ~]# go version
go version go1.8.1 linux/amd64
2、安装prometheus
[root@server0 ~]# tar zxvf prometheus-1.6.3.linux-amd64.tar.gz -C /usr/local
[root@server0 ~]# cd /usr/local/prometheus-1.6.3.linux-amd64
[root@server0 prometheus-1.6.3.linux-amd64]# nohup ./prometheus -config.file=prometheus.yml &
3、安装grafana
[root@server0 ~]# rpm -ivh grafana-4.3.0-1.x86_64.rpm

warning: grafana-4.3.0-1.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 24098cb6: NOKEY
Preparing...                ########################################### [100%]
   1:grafana                ########################################### [100%]
### NOT starting grafana-server by default on bootup, please execute
 sudo /sbin/chkconfig --add grafana-server
### In order to start grafana-server, execute
 sudo service grafana-server start
POSTTRANS: Running script

[root@server0 ~]# service grafana-server start
Starting Grafana Server: … [确定]
[root@server0 ~]# chkconfig grafana-server on
3、安装rabbitmq exporter
[root@server0 ~]# tar zxvf rabbitmq_exporter-0.20.0.linux-amd64.tar.gz -C /usr/local/
[root@server0 ~]# cd /usr/local/rabbitmq_exporter-0.20.0.linux-amd64/
[root@server0 rabbitmq_exporter-0.20.0.linux-amd64]# ls
LICENSE rabbitmq_exporter
[root@server0 rabbitmq_exporter-0.20.0.linux-amd64]# RABBIT_USER=erpmq RABBIT_PASSWORD=erpmq OUTPUT_FORMAT=JSON PUBLISH_PORT=9099 RABBIT_URL=http://localhost:15672 nohup ./rabbitmq_exporter &
[1] 7396
nohup: 忽略输入并把输出追加到”nohup.out”

[root@server0 rabbitmq_exporter-0.20.0.linux-amd64]# ls
LICENSE nohup.out rabbitmq_exporter
[root@server0 rabbitmq_exporter-0.20.0.linux-amd64]# tail nohup.out

{"level":"info","msg":"Using default certificate pool","time":"2017-05-23T20:24:50+08:00"}
{"BRANCH":"heads/v0.20.0","BUILD_DATE":"20170512-20:08:52","OUTPUT_FORMAT":"JSON","PUBLISH_PORT":"9099","RABBIT_CAPABILITIES":"","RABBIT_URL":"http://localhost:15672","RABBIT_USER":"erpmq","REVISION":"a301c6a463bb740123fb2c54b43ac6189a08c019","VERSION":"0.20.0","level":"info","msg":"Starting RabbitMQ exporter","time":"2017-05-23T20:24:50+08:00"}

4、修改prometheus的配置文件
[root@server0 prometheus-1.6.3.linux-amd64]# vim prometheus.yml

scrape_configs:
  # The job name is added as a label `job=` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ['localhost:9090']

  - job_name: 'RabbitMQ'
    static_configs:
      - targets: ['localhost:9099']
        labels:
            instance: RabbitMQ-127.0.0.1   

5、重启prometheus
6、在grafana中添加prometheus的数据来源
Prometheus 监控Rabbitmq_第1张图片
Prometheus 监控Rabbitmq_第2张图片
Prometheus 监控Rabbitmq_第3张图片Prometheus 监控Rabbitmq_第4张图片

参考:
http://www.cnblogs.com/shhnwangjian/p/6878199.html
http://www.cnblogs.com/shhnwangjian/p/6879683.html
http://blog.csdn.net/jb19900111/article/details/55652523
https://www.cnblogs.com/sfnz/p/6566951.html

你可能感兴趣的:(架构设计与优化,服务器与存储)