Prometheus+Grafana学习(九)监控RocketMq

文章目录

  • 一、安装Prometheus和Grafana
  • 二、安装RocketMq
  • 三、安装Rocketmq exporter
    • 3.1 下载源码
    • 3.2 将源码编译成jar包
    • 3.3 注册为系统服务
    • 3.4 测试
  • 四、配置Prometheus
  • 五、配置Grafana


一、安装Prometheus和Grafana

prometheus参考:https://blog.csdn.net/u011943534/article/details/122519799
grafana参考:https://blog.csdn.net/u011943534/article/details/122520190

二、安装RocketMq

参考:https://blog.csdn.net/u011943534/article/details/122628777

三、安装Rocketmq exporter

最简单的方式是使用docker安装,这里选择在没docker环境下编译源码安装。

3.1 下载源码

github地址:https://github.com/apache/rocketmq-exporter

3.2 将源码编译成jar包

将上一步下载的源码rocketmq-exporter-master.zip进行编译,需要MAVEN环境。
编译:

mvn clean install

运行完后在target目录找到打好的jar包
Prometheus+Grafana学习(九)监控RocketMq_第1张图片

3.3 注册为系统服务

将打好的jar:rocketmq-exporter-0.0.2-SNAPSHOT.jar上传至rocketmq所在的服务器。

vi /etc/systemd/system/rocketmq_exporter.service

添加内容:

[Service]
WorkingDirectory=/opt/soft/rocketmq_exporter/
PrivateTmp=true
Restart=always
Type=simple
ExecStart=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.292.b10-1.el7_9.x86_64/bin/java -jar /opt/soft/rocketmq_exporter/rocketmq-exporter-0.0.2-SNAPSHOT.jar >dev/null 2>&1 &
ExecStop=/usr/bin/kill -15 $MAINPID

[Install]
WantedBy=multi-user.target
systemctl start exporter_service
systemctl enable exporter_service

3.4 测试

访问http://IP:5557/metrics
Prometheus+Grafana学习(九)监控RocketMq_第2张图片

四、配置Prometheus

修改prometheus.yml配置文件,添加一个rocketmq的job。

vi /usr/local/prometheus/prometheus.yml

将刚启动的rocketmq_exporter配置进去

# my global config
global:
  scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets: ["172.16.10.171:9093"]

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  - "*rule.yml"
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
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: "spring"
    scrape_interval: 15s
    scrape_timeout: 10s
    metrics_path: "/demo/actuator/prometheus"
    static_configs:
    - targets: ["192.168.100.88:7901"]
  - job_name: "mysql8.x"
    static_configs:
    - targets: ["172.16.10.169:9104", "192.168.100.88:9104"]
  - job_name: "nginx"
    static_configs:
    - targets: ["172.16.10.171:9913"]
  - job_name: "node"
    static_configs:
    - targets: ["172.16.10.171:9100","172.16.10.160:9100","172.16.10.161:9100", "172.16.10.162:9100", "172.16.10.163:9100", "172.16.10.164:9100", "172.16.10.165:9100", "172.16.10.167:9100", "172.16.10.168:9100", "172.16.10.169:9100", "172.16.10.170:9100"]
  - job_name: "alertmanager"
    static_configs:
    - targets: ["172.16.10.171:9093"]
  - job_name: "rocketmq"
    static_configs:
    - targets: ["172.16.10.168:5557", "172.16.10.169:5557"]

重启prometheus

systemctl restart prometheus

访问http://172.16.10.171:9090/targets
Prometheus+Grafana学习(九)监控RocketMq_第3张图片

五、配置Grafana

使用14612的模板:https://grafana.com/grafana/dashboards/14612
下载JSON(已下载)
导入JSON
效果:
Prometheus+Grafana学习(九)监控RocketMq_第4张图片

你可能感兴趣的:(rocketmq,rocketmq,exporter,rocketmq监控,监控rocketmq)