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


    前提:

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

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

    目标:

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

     搭建步骤:

    1. 下载所需镜像

    1. docker pull prom/prometheus
    2. docker pull grafana/grafana

    2.修改orderer、peer节点

    1. # orderer 节点
    2. environment:
    3. - ORDERER_METRICS_PROVIDER=prometheus
    4. - ORDERER_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
    5. ports:
    6. - 8443:8443
    7. # peer节点
    8. # org1
    9. environment:
    10. - CORE_METRICS_PROVIDER=prometheus
    11. - CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
    12. ports:
    13. - 8443:8443
    14. # org2
    15. environment:
    16. - CORE_METRICS_PROVIDER=prometheus
    17. - CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
    18. ports:
    19. - 8443:8443

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

    3.编写 prometheus.yml

    1. global:
    2. scrape_interval: 15s # # 将scrape间隔设置为每15秒。默认为每1分钟
    3. evaluation_interval: 15s # 每15秒评估一次规则。默认为1分钟。
    4. scrape_configs:
    5. - job_name: 'hyperledger-fabric'
    6. static_configs:
    7. - targets: ['orderer.example.com:8443','peer0.org1.example.com:8443','peer0.org2.example.com:8443']

    4.编写 docker-compose-prometheus.yaml

    1. services:
    2. prometheus:
    3. image: prom/prometheus:latest
    4. restart: always
    5. container_name: prometheus # 容器名称
    6. ports:
    7. - 9090:9090 # 确保端口未被占用
    8. volumes:
    9. - ./prometheus.yml:/etc/prometheus/prometheus.yml
    10. grafana:
    11. image: grafana/grafana:latest
    12. restart: always
    13. container_name: grafana
    14. ports:
    15. - 3000:3000
    16. depends_on:
    17. - prometheus

    5.启动 prometheus

    命令如下:

    docker-compose -f docker-compose-prometheus.yaml up -d

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

    http://IP地址:9090/targets

    http://IP地址:3000/

    打开 Grafana 界面

    输入账号密码:

    默认账号:admin

    默认密码:admin

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

  • 相关阅读:
    贪心——122. 买卖股票的最佳时机 II
    【Flink系列】开启jdbc批量写入
    Unity3D 检测鼠标位置的Sprite像素颜色
    2311C++抽象工厂
    手写操作系统-环境的建立
    Object.defineProperty()
    快速了解常用的非对称加密算法,再也不用担心面试官的刨根问底
    elastic 概述
    Sound/播放提示音, Haptics/触觉反馈, LocalNotification/本地通知 的使用
    JoySSL-新兴国产品牌数字证书
  • 原文地址:https://blog.csdn.net/wzy4510609/article/details/126157755