prometheus监控常用的中间键

一、监控redis中间键

1)redis_exporter安装包下载路径

https://github.com/oliver006/redis_exporter/releases/download/v1.9.0/redis_exporter-v1.9.0.linux-amd64.tar.gz

2)解压包

tar -xf redis_exporter-v1.9.0.linux-amd64.tar.gz 
mv redis_exporter-v1.9.0.linux-amd64.tar.gz redis_exporter
cd redis_exporter

3) 启动redis_exporter

nohup ./redis_exporter -web.listen-address=0.0.0.0:9121 -redis.addr redis://10.2.2.236:6380 -redis.password 密码 &

创建redis_exporter启动服务 

$ vim /etc/systemd/system/redis_exporter.service
 
[Unit]
Description=redis_exporter
After=network.target
[Service]
Type=simple
User=root
ExecStart=/usr/local/prometheus/redis_exporter/redis_exporter -redis.addr -redis.password
Restart=on-failure
[Install]
WantedBy=multi-user.target

4)、prometheus的配置如下

#redis配置信息
  - job_name: "redis"
    static_configs:
    - targets: [10.2.2.236:9121]

5、再grafan中导入redis dashboardprometheus监控常用的中间键_第1张图片

prometheus监控常用的中间键_第2张图片 6、得到的监控数据dashboard图如下prometheus监控常用的中间键_第3张图片

二、rabbitmq-server 的监控

rabbitmq_exporter监控软件包下载,下载页面:https://github.com/kbudde/rabbitmq_exporter/releases

https://github.com/kbudde/rabbitmq_exporter/releases/download/v1.0.0-RC7/rabbitmq_exporter-1.0.0-RC7.linux-amd64.tar.gz

1、下载并安装部署过程 

# wget https://github.com/kbudde/rabbitmq_exporter/releases/download/v1.0.0-RC7/rabbitmq_exporter-1.0.0-RC7.linux-amd64.tar.gz
--2020-08-11 11:02:33--  https://github.com/kbudde/rabbitmq_exporter/releases/download/v1.0.0-RC7/rabbitmq_exporter-1.0.0-RC7.linux-amd64.tar.gz
Resolving github.com (github.com)... 13.229.188.59
Connecting to github.com (github.com)|13.229.188.59|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/37385103/f747bf80-839d-11ea-8a00-c9636688d7b4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200811%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200811T030233Z&X-Amz-Expires=300&X-Amz-Signature=d1a88eb92e5915ada5a2e7860bc7f909c851d295053b05fbed9795efc16d2727&X-Amz-SignedHeaders=host&actor_id=0&repo_id=37385103&response-content-disposition=attachment%3B%20filename%3Drabbitmq_exporter-1.0.0-RC7.linux-amd64.tar.gz&response-content-type=application%2Foctet-stream [following]
--2020-08-11 11:02:33--  https://github-production-release-asset-2e65be.s3.amazonaws.com/37385103/f747bf80-839d-11ea-8a00-c9636688d7b4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200811%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200811T030233Z&X-Amz-Expires=300&X-Amz-Signature=d1a88eb92e5915ada5a2e7860bc7f909c851d295053b05fbed9795efc16d2727&X-Amz-SignedHeaders=host&actor_id=0&repo_id=37385103&response-content-disposition=attachment%3B%20filename%3Drabbitmq_exporter-1.0.0-RC7.linux-amd64.tar.gz&response-content-type=application%2Foctet-stream
Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.130.75
Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.130.75|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7049717 (6.7M) [application/octet-stream]
Saving to: ‘rabbitmq_exporter-1.0.0-RC7.linux-amd64.tar.gz’

100%[====================================================================================================================================================================================================================================>] 7,049,717   2.88MB/s   in 2.3s   

2020-08-11 11:02:37 (2.88 MB/s) - ‘rabbitmq_exporter-1.0.0-RC7.linux-amd64.tar.gz’ saved [7049717/7049717]

[root@ip-10-2-2-14 updates]# tar -xf rabbitmq_exporter-1.0.0-RC7.linux-amd64.tar.gz 

[root@ip-10-2-2-14 updates]# mv rabbitmq_exporter-1.0.0-RC7.linux-amd64 ../rabbitmq_exporter

[root@ip-10-2-2-14 updates]# cd ../rabbitmq_exporter/
[root@ip-10-2-2-14 rabbitmq_exporter]# ls
LICENSE  rabbitmq_exporter

2、启动服务

RABBIT_USER=zat RABBIT_PASSWORD=zat123 OUTPUT_FORMAT=json PUBLISH_PORT=9090 RABBIT_URL=http://localhost:15672 nohup ./rabbitmq_exporter &

tail -100f nohup.out

3、查看服务是否正常启动

# netstat -antpu |grep 30026
tcp6       0      0 :::30026                :::*                    LISTEN      28594/./rabbitmq_ex

4、更改prometheus的配置文件

#rabbitmq_exporter配置信息
  - job_name: "Rabbitmq_exporter"
    static_configs:
      - targets: [10.2.2.14:30026]
        labels:
          unitname: "Rabbitmq_exporter"

5、重启prometheus

# systemctl restart prometheus

6、查看target情况,显示已经启动

7、 再granfan上配置dashboard

prometheus监控常用的中间键_第4张图片

prometheus监控常用的中间键_第5张图片 最后导入显示的dashboard如下图

prometheus监控常用的中间键_第6张图片

8、rabbitmq列队信息数监控

1)编写rule文件

      - alert: Rabbitmq-queue(mq队列数)
        expr: rabbitmq_queue_messages > 6
        for: 2m
        labels:
          service_name: alertmanage-monitor
          level: warning
        annotations:
          description: "{
    {$labels.instance}}: Rabbitmq-server queue of {
    {$labels.queue}}. (current value is: {
    { $value }}"

 2)重启alertmanager和prometheus

# systemctl restart prometheus
# systemctl restart alertmanager

3)测试阶段我将number值调小点,此时我们可以在localhost:/alerts下看到我们的告警情况

prometheus监控常用的中间键_第7张图片

4)与此同时我的邮箱也收到了对应的邮件

prometheus监控常用的中间键_第8张图片

你可能感兴趣的:(prometheus,云深海阔专栏,prometheus)