Hyperledger Fabric v2.X Monitoring Using Prometheus

Aditya Joshi
Coinmonks

--

1. Overview

In this article, we will be going to see how we can set up monitoring for our hyperledger fabric network. In one of my previous articles, we saw how we can integrate Hyperledger explorer with the Hyperledger Fabric network. We will be going to use Prometheus and Grafana for monitoring. Prometheus is an open-source time-series database developed by SoundCloud and serves as the storage layer for the Prometheus monitoring system. Grafana is the open-source analytics & monitoring solution for every database. It provides charts, graphs, and alerts for the web when connected to supported data sources.

Also, Check out my course on Hyperledger Fabric Deployment on MultiHost

2. Prometheus Configuration

To run the prometheus instance we need to run it with your configuration file. The configuration files allow us for setting up jobs and targets for scraping.

The global section describes and overrides some defaults. The rule_files section lists all rule files (recording or alert rules) that Prometheus needs to load and process. The scrape_configs section, describes the job(s) that Prometheus needs to process. In our case, we have a job named prometheus, orderer , peer0_org1, peer0_org2 with some config items, including the target_groups sub-section.

3. Grafana Configuration

Configuration as code is the practice of storing the configuration of your system as a set of version-controlled, human-readable configuration files, rather than in a database. Grafana supports configuration as code through provisioning. The resources that currently support provisioning are:

The provisioning directory assumes the following structure:

Our data source file looks like this

And our dashboard file looks like this

4. Peer’s Configuration

In the peer’s configuration, we need to add two environment variables CORE_OPERATIONS_LISTENADDRESS and CORE_METRICS_PROVIDER

5. Orderer Configuration

In the orderer configuration, we need to add two environment variables ORDERER_OPERATIONS_LISTENADDRESS and ORDERER_METRICS_PROVIDER

6. Setup

  1. Clone the repository
git clone https://github.com/adityajoshi12/fabric-samples-advance-topics.git
cd fabric-samples-advance-topics

2. Navigate to the monitoring and logging directory

cd test-network/moniter\ and\ logging/monitering

3. Start the Prometheus and Grafana service.

docker-compose up

4. Now, we can start the fabric network

cd ../..
./network.sh up createChannel -ca -c mychannel -i 2.2

5. Once the network starts up visit the http://localhost:3000 on the browser and you can see the grafana dashboard.

The username and password for grafana is admin/admin

7. Summary

In this article, we learned how we can enable metrics on our hyperledger fabric network and set up Prometheus and grafana for monitoring. Source code can be found here

If you find this article helpful do hit the clap button and follow me for more such informative articles.

You can find me on Linkedin or stalk me on GitHub? If that’s too social for you, just drop a mail to adityaprakashjoshi1@gmail.com if you wish to talk tech with me.

--

--

Aditya Joshi
Coinmonks

I am a Software Engineer @Walmart and instructor @Udemy, working on Blockchain, and Kubernetes. Get in touch: linktr.ee/adityajoshi12