Prometheus 监控 HyperLedger Fabric

Prometheus 监控 HyperLedger Fabric

1. 下载所需镜像

docker pull prom/prometheus
docker pull grafana/grafana

2. 修改orderer、peer节点

# orderer 节点
vim docker-compose-orderer.yaml
# 在environment下添加以下参数
    environment:
       - ORDERER_METRICS_PROVIDER=prometheus
       - ORDERER_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
# ports下增加8443端口
    ports:
       - 8443:8443   # 端口不要被占用


# peer节点
# org1
vim docker-compose-org1.yaml
    environment:
      - CORE_METRICS_PROVIDER=prometheus
      - CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
    ports:
      - 8443:8443

# org2
vim docker-compose-org2.yaml
    environment:
      - CORE_METRICS_PROVIDER=prometheus
      - CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
    ports:
      - 8443:8443



# 修改完成之后 up -d
# orderer
docker-compose -f docker-compose-orderer.yaml up -d
[+] Running 1/1
 ⠿ Container orderer.example.com  Started                         1.2s
 
# org1
docker-compose -f docker-compose-org1.yaml up -d
[+] Running 3/3
 ⠿ Container cli                        Running                   0.0s
 ⠿ Container couchdb0.org1.example.com  Running                   0.0s
 ⠿ Container peer0.org1.example.com     Started                   1.8s

# org2
docker-compose -f docker-compose-org2.yaml up -d
[+] Running 3/3
 ⠿ Container couchdb0.org2.example.com  Running                   0.0s
 ⠿ Container peer0.org2.example.com     Started                   1.8s
 ⠿ Container cli                        Running                   0.0s

3. 编写 prometheus.yml

vim prometheus.yml
global:
  scrape_interval:     15s # # 将scrape间隔设置为每15秒。默认为每1分钟
  evaluation_interval: 15s # 每15秒评估一次规则。默认为1分钟。
  # scrape_timeout 设置为全局默认值(10s)。
scrape_configs:
  # 使用名作为标签`job=<job_name>添加到从该配置中抓取的任何时间序列。
  - job_name: 'hyperledger-fabric'
    static_configs:
      - targets: ['orderer.example.com:8443','peer0.org1.example.com:8443','peer0.org2.example.com:8443'] # 如果有多个节点请以逗号分割。

4. 编写 docker-compose-prometheus.yaml

vim docker-compose-prometheus.yaml

version: '2.0'

services:

  prometheus:
    image: prom/prometheus:latest
    restart: always
    container_name: prometheus   # 容器名称
    ports:
      - 9090:9090   # 确保端口未被占用
    extra_hosts:
      - "orderer.example.com:192.168.88.121"
      - "peer0.org1.example.com:192.168.88.122"
      - "peer0.org2.example.com:192.168.88.123"
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml

  grafana:
    image: grafana/grafana:latest
    restart: always
    container_name: grafana
    ports:
      - 3000:3000
    depends_on:
      - prometheus

5. 启动 prometheus

docker-compose -f docker-compose-prometheus.yaml up -d
[+] Running 3/3
 ⠿ Network prometheus_default  Created                                      0.1s
 ⠿ Container prometheus        Started                                      1.9s
 ⠿ Container grafana           Started                                      3.8s

image-20220425104640808

浏览器中访问:

http://192.168.88.121:9090/targets

image-20220425173551803

浏览器中访问: http://192.168.88.121:3000/ 打开 Grafana 界面

image-20220425105001144

输入账号密码:

默认账号:admin

默认密码:admin

之后会让你设置新密码,设置完成之后登录即可

image-20220425105245851

添加prometheus数据源:

image-20220425110019905

image-20220425110238172

添加url之后下方保存

访问Grafana 搜索需要监控组件的 dashboards 文件

Hyperledger Fabric 监控目前只支持 1.4 版本。2.x 版本的应该之后会出。

image-20220425110657386

复制这个 dashboard id 添加fabric dashboard:

或者是下载 Get this dashboard之后导入到Grafana内:Download JSON

image-20220425111044741

image-20220425111358250

填入ID之后点击Load

image-20220425111454737

点击import

效果如下,下面版本显示应该是Fabric版本和json不兼容

image-20220425111759148

image-20220425111947049

看一下是否有数据,选择Fabric Version下拉框

image-20220425112230636

采用的是fabric_version

image-20220425112343137

新建仪表盘

image-20220425112745106

image-20220425113926955

可以看到是有数据的,显示版本为2.4.2

image-20220425114045569

接下来删除新创建的面板

image-20220425114247216

继续选择Fabric Version下拉框,可以看到版本号出现,点击右上角apply

image-20220425142155914

返回仪表盘看到版本正常

image-20220425141934883

其它也一样设置

image-20220425142119615

最终结果如下

image-20220425142324738

完成!

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值