使用Grafana+Prometheus
quickmsg   
# 安装prometheus
 - 新建prometheus.yml配置文件
 
global:
  scrape_interval: 3s # 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:
          # - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "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=<job_name>` 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: "smqtt02"
    metrics_path: /smqtt/meter
    static_configs:
      - targets: ["192.168.124.62:60000"] # 你后台服务的地址
 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
- 使用docker启动
 
sudo docker run -it  -d  -p 9090:9090 -v /tmp/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \
       -v /tmp/prometheus-data:/prometheus-data \
       prom/prometheus
 1
2
3
2
3
- 访问prometheus监控页面 http://localhost:9090
 
# 安装grafana
 docker run  -it -d \
-p 3000:3000 \
--name=grafana \
-v /opt/grafana-storage:/var/lib/grafana \
grafana/grafana
 1
2
3
4
5
2
3
4
5
# 配置grafana
 配置
prometheus数据源导入dashboard
在gitee/github项目中monitor/prometheus目录下包含三个json文件,倒入到grafana中即可, 目前influxdb的配置暂未提供, 敬请期待
# SMQTT启动监控
启动http接口,开启
prometheus
smqtt:
  http: # http相关配置 端口固定60000
    enable: true # 开关
    accessLog: true # http访问日志
    ssl: # ssl配置
      enable: false
    admin: # 后台管理配置
      enable: true  # 开关
      username: smqtt # 访问用户名
      password: smqtt # 访问密码
  meter:
    meterType: PROMETHEUS # INFLUXDB , PROMETHEUS
    
 1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13