fabric-samples/test-network/prometheus-grafana
Mark S. Lewis a72b2b5132
Remove obsolete version element from compose files (#1361)
The version element is obsolete and unused since Compose v1 was
deprecated in favour of Compose v2 in 2022, and reached end-of-life in
2023. The version element generates warning messages running Docker
Compose commands when bringing up and down the test-network, which
adds unnecessary noise and can be confusing for users.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2025-11-04 10:52:28 -05:00
..
grafana further grafana dashboard improvements (#614) 2022-02-02 15:30:09 +00:00
grafana_db add prometheus/grafana performances sample into test-network directory (#576) 2022-01-20 09:37:37 +00:00
prometheus add prometheus/grafana performances sample into test-network directory (#576) 2022-01-20 09:37:37 +00:00
docker-compose.yaml Remove obsolete version element from compose files (#1361) 2025-11-04 10:52:28 -05:00
README.md docs: Quotation marks are used incorrectly. (#1282) 2024-12-24 09:52:40 +00:00

Description

This sample provides an environment to display and capture metrics from the test-network in real time. It consists of a docker-compose file that starts a Prometheus and Grafana server setup configured to collect and display metrics for the test network.

Requirements

This sample has been tested and is recommended to be used on linux in order to fully benefit from its capabilities, however it can be deployed and works on MacOS-intel machine as well (some modification to the cadvisor docker image and related queries are required to show docker containers metrics). You will need to have installed docker-compose with version 1.29 or above (note that this is higher than the v1.14 requirement requested for the test-network).

How to use

  1. Go to the test-network directory and run bring up the test-network ./network.sh up createChannel
  2. Bring up the Prometheus/Grafana network in the test-network/prometheus-grafana directory and run docker-compose up -d
  3. Log in: type "localhost:3000" on your web browser -> username="admin", password="admin" -> set a new password
  4. Browse dashboard and analyse results
    • The default dashboard "HLF Performances Review" can be found and displayed by hovering over the dashboard menu and clicking on the browse button. picture alt Once opened the dashboard, to display the collected metrics and data, adjust the timeframe on the top right to focus on the latest timespan when the network was up.
  5. Deploy a chaincode (i.e. "./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go"), start using the test-network and use the Grafana dashboard to analyse and assess your network performances. Extras: add new queries, modify dashboard & add relevant changes to main repo --> extract json and add it to "Grafana/dashboards/hlf-performances.json". Metrics can also be displayed directly from Prometheus by going to "localhost:9090".

Docker Compose

Brings up

  • a Prometheus server (port 9090) -> pulls metrics from peers, orderer, system(node exporter) and containers(cadvisor)
  • Grafana server (port 3000) -> collects and display data from Prometheus
  • node exporter (port 9100) -> exposes systems metrics
  • cadvisor (port 8080) -> exposes docker containers metrics

Prometheus "configuration file"

Prometheus.yml

Fabric metrics targets:

  • peer0.org1.example.com:9444
  • peer0.org2.example.com:9445
  • orderer.example.com:9443

System and docker metrics targets:

  • cadvisor:8080
  • node-exporter:9100

Check the state of the connections with targets on http://localhost:9090/targets.

Sources

Prometheus docs Grafana docs