1

I am trying to monitor Fabric network with Prometheus and grafana but i cannot find any example or documentation. So, i am starting the fabcar example(v1.4).

After that, i followed this example https://www.youtube.com/watch?v=4WWW2ZLEg74 which is about the set set up of Prometheus and Grafana. Finally, i added this dashboard https://grafana.com/grafana/dashboards/10716 which is about Hyperledger Fabric Monitoring for 1.4.

However, i have no metrics about my channel. Every graph is empty. I am not sure if my steps are right. Does anybody know any similar example or documentation how to use Grafana for Fabric?

HectorCode
  • 205
  • 2
  • 11
  • Did you modify the docker-compose file to expose metrics? I might have the answer to your issue, but I need to know some more details about your configuration. – Xhens Jun 30 '20 at 23:47
  • @ XhensB thank you for your response. No i did not modify docker compose file to expose metrics. I did not find any example how to do this. Could you guide me with an example please? – HectorCode Jul 01 '20 at 08:48
  • 1
    you can have a look on my article: https://medium.com/@pouyashojaei85/monitoring-hyperledger-fabric-cf2dd6ecd654 – Pouya Shojaei Sep 29 '20 at 12:45

2 Answers2

3

Edit the docker-compose-test-net.yaml and add these lines on environment variables of orderer.example.com:

  - ORDERER_OPERATIONS_LISTENADDRESS=orderer.example.com:your_port
  - ORDERER_METRICS_PROVIDER=prometheus

On each peer add these environment variables:

  - CORE_OPERATIONS_LISTENADDRESS=peer0.org1.example.com:your_port
  - CORE_METRICS_PROVIDER=prometheus

But remember to change the orderer and the peers address:port respectively.

Example of the orderer configuration:

orderer.example.com:
container_name: orderer.example.com
image: hyperledger/fabric-orderer:$IMAGE_TAG
environment:
  - FABRIC_LOGGING_SPEC=DEBUG
  - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
  - ORDERER_GENERAL_LISTENPORT=7050
  - ORDERER_GENERAL_GENESISMETHOD=file
  - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
  - ORDERER_GENERAL_LOCALMSPID=OrdererMSP
  - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
  # enabled TLS
  - ORDERER_GENERAL_TLS_ENABLED=true
  - ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
  - ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
  - ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
  - ORDERER_KAFKA_TOPIC_REPLICATIONFACTOR=1
  - ORDERER_KAFKA_VERBOSE=true
  - ORDERER_GENERAL_CLUSTER_CLIENTCERTIFICATE=/var/hyperledger/orderer/tls/server.crt
  - ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/var/hyperledger/orderer/tls/server.key
  - ORDERER_GENERAL_CLUSTER_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
  - ORDERER_OPERATIONS_LISTENADDRESS=orderer.example.com:9443
  - ORDERER_METRICS_PROVIDER=prometheus
  - TZ=Europe/Berlin
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: orderer
volumes:
    - ../system-genesis-block/genesis.block:/var/hyperledger/orderer/orderer.genesis.block
    - ../organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp
    - ../organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls
    - orderer.example.com:/var/hyperledger/production/orderer
ports:
  - 7050:7050
networks:
  - test
Xhens
  • 804
  • 3
  • 13
  • 33
  • When you say your_port, do you mean the port from the core. yaml file from the operations section? For example, from this `listenAddress: 127.0.0.1:9443` i will add this `- CORE_OPERATIONS_LISTENADDRESS=peer0.org1.example.com:9443` – HectorCode Jul 03 '20 at 14:13
  • and my prometheus.yaml file: `global: scrape_interval: 15s evaluation_interval: 15s scrape_configs: - job_name: ‘prometheus’ scrape_interval: 10s static_configs: - targets: [‘localhost:9090’] - job_name: ‘hyperledger_metrics’ scrape_interval: 10s static_configs: - targets: [‘peer0.org1.example.com:9443’, ‘peer0.org2.example.com:9443’, ‘peer1.org2.example.com:9443’, ‘peer1.org1.example.com:9443’, ‘orderer.example.com:9443’] ` – HectorCode Jul 03 '20 at 14:16
  • Regarding the first comment: Exactly. But don't forget that for orderer container you must use the `ORDERER_OPERATIONS_LISTENADDRESS` and `ORDERER_METRICS_PROVIDER` while for peers use those starting with `CORE_`. Regarding the second comment (prometheus config file): it seems very good. Try it and let me know :) – Xhens Jul 03 '20 at 21:49
  • @ XhensB thank you for your advise. I used your instructions for orderer and peers but when i open prometheus at [link] http://localhost:9090/targets the state of 'prometheus' and 'hyperledger_metrics' is down. And the error tab is "invalid port after host" for each endpoint. – HectorCode Jul 08 '20 at 14:24
  • Hey, I updated my answer and added my orderer configuration. With that configuration, and listed as `orderer.example.com:9443` on prometheus config, it shows up as a target with the state `UP` – Xhens Jul 08 '20 at 22:17
  • @ XhensB For me it wasn't the config file the problem but i removed `` from the targets on the prometheus.yaml file and prometheus and hyperledger metrics are UP – HectorCode Jul 10 '20 at 19:32
  • Oh, cool! I'm glad you have it running now. I'd really appreciate it if you accept my answer above :) – Xhens Jul 11 '20 at 10:05
  • 1
    You also need to add the operations ports to the [ports] section of the YAML file, i.e. `- 9443:9443` – Sigmatics Sep 10 '20 at 09:41
0

also can use below for binding from any IP address:

orderer environment variable:

ORDERER_OPERATIONS_LISTENADDRESS=0.0.0.0:9444

peer /etc/hyperledger/fabric/core.yaml file:

operations:
  # host and port for the operations server
  listenAddress: 0.0.0.0:9443