搭建Prometheus+Grafana框架监控Hyperledger Fabric的运行

前提:

        已有可正常运行的Hyperledger Fabric环境,包括已经完成网络环境搭建,链码部署,web应用开发部署,具体的案例或实例可联系博主获取,(企鹅)。846412999 环境搭建必须包含docker等基础环境的安装。

        本环境的fabric版本可以是1.4-2.4,博主使用的是经过pbft改造的共识算法的fabric1.4.4版本,并支持tape、caliper进行项目压测,explorer监控等工作;

目标:

        实现Prometheus+Grafana框架的搭建,用于监控fabric网络环境,具体的效果图如下:

搭建Prometheus+Grafana框架监控Hyperledger Fabric的运行_第1张图片

 搭建步骤:

1. 下载所需镜像

docker pull prom/prometheus
docker pull grafana/grafana


2.修改orderer、peer节点

# orderer 节点
    environment:
       - ORDERER_METRICS_PROVIDER=prometheus
       - ORDERER_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
    ports:
       - 8443:8443


# peer节点
# org1
    environment:
      - CORE_METRICS_PROVIDER=prometheus
      - CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
    ports:
      - 8443:8443

# org2
    environment:
      - CORE_METRICS_PROVIDER=prometheus
      - CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
    ports:
      - 8443:8443

 修改完成之后重启fabric区块链网络

3.编写 prometheus.yml

global:
  scrape_interval:     15s # # 将scrape间隔设置为每15秒。默认为每1分钟
  evaluation_interval: 15s # 每15秒评估一次规则。默认为1分钟。
scrape_configs:
  - 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

services:

  prometheus:
    image: prom/prometheus:latest
    restart: always
    container_name: prometheus   # 容器名称
    ports:
      - 9090:9090   # 确保端口未被占用
    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

启动后即可在浏览器中访问:

http://IP地址:9090/targets

http://IP地址:3000/

打开 Grafana 界面

输入账号密码:

默认账号:admin

默认密码:admin

之后会让你设置新密码,设置完成之后登录即可,登陆后添加prometheus数据源完成整个环境搭建部署;

你可能感兴趣的:(区块链,fabric,java,Prometheus,Grafana,hyperledger)