mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
add prometheus/grafana performances sample into test-network directory (#576)
Signed-off-by: fraVlaca <ocsenarf@outlook.com> added promethesus-grafana server to test-network Signed-off-by: fraVlaca <ocsenarf@outlook.com> changed image for cadvisor to version that works on Linux Signed-off-by: fraVlaca <ocsenarf@outlook.com> improved documentation on README and tweaked docker-compose file Signed-off-by: fraVlaca <ocsenarf@outlook.com> updated and fixed documentation for the prometheus/grafana sample for the test-network Signed-off-by: fraVlaca <ocsenarf@outlook.com> final modification to grafana dashboard and prom/graf docs Signed-off-by: fraVlaca <ocsenarf@outlook.com>
This commit is contained in:
parent
84c101fb8a
commit
77431f5b39
8 changed files with 2635 additions and 0 deletions
49
test-network/prometheus-grafana/README.md
Normal file
49
test-network/prometheus-grafana/README.md
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# 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 recomended 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.
|
||||

|
||||
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 sever (port 9090) -> pulls metrics from peers, orderer, system(node exporter) and containers(cadvisor)
|
||||
- grafana sever (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: https://prometheus.io/docs/introduction/overview/
|
||||
Grafana docs: https://grafana.com/docs/
|
||||
68
test-network/prometheus-grafana/docker-compose.yaml
Normal file
68
test-network/prometheus-grafana/docker-compose.yaml
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
version: '3'
|
||||
|
||||
volumes:
|
||||
prometheus_data: {}
|
||||
grafana_storage: {}
|
||||
|
||||
services:
|
||||
prometheus:
|
||||
image: prom/prometheus
|
||||
container_name: prometheus
|
||||
volumes:
|
||||
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
|
||||
- prometheus_data:/prometheus
|
||||
command:
|
||||
- '--config.file=/etc/prometheus/prometheus.yml'
|
||||
- '--storage.tsdb.path=/prometheus'
|
||||
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
|
||||
- '--web.console.templates=/usr/share/prometheus/consoles'
|
||||
ports:
|
||||
- "9090:9090"
|
||||
|
||||
grafana:
|
||||
image: grafana/grafana
|
||||
container_name: grafana
|
||||
user: "104"
|
||||
depends_on:
|
||||
- prometheus
|
||||
ports:
|
||||
- 3000:3000
|
||||
volumes:
|
||||
- grafana_storage:/var/lib/grafana
|
||||
- ./grafana/provisioning/:/etc/grafana/provisioning/
|
||||
env_file:
|
||||
- ./grafana/config.monitoring
|
||||
restart: always
|
||||
|
||||
cadvisor:
|
||||
image: google/cadvisor:latest # gcr.io/cadvisor/cadvisor:latest for ios
|
||||
privileged: true
|
||||
container_name: cadvisor
|
||||
volumes:
|
||||
- /var/run:/var/run:rw
|
||||
- /sys:/sys:ro
|
||||
- /var/lib/docker/:/var/lib/docker:ro
|
||||
# - /cgroup:/cgroup:ro
|
||||
ports:
|
||||
- 8080:8080
|
||||
restart: always
|
||||
|
||||
node-exporter:
|
||||
image: prom/node-exporter
|
||||
container_name: node-exporter
|
||||
volumes:
|
||||
- /proc:/host/proc:ro
|
||||
- /sys:/host/sys:ro
|
||||
command:
|
||||
- '--path.procfs=/host/proc'
|
||||
- '--path.sysfs=/host/sys'
|
||||
- --collector.filesystem.ignored-mount-points
|
||||
- "^/(sys|proc|dev|host|etc|rootfs/var/lib/docker/containers|rootfs/var/lib/docker/overlay2|rootfs/run/docker/netns|rootfs/var/lib/docker/aufs)($$|/)"
|
||||
ports:
|
||||
- 9100:9100
|
||||
restart: always
|
||||
|
||||
networks:
|
||||
default:
|
||||
external: true
|
||||
name: fabric_test
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
GF_SECURITY_ADMIN_PASSWORD=admin
|
||||
GF_USERS_ALLOW_SIGN_UP=false
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
apiVersion: 1
|
||||
|
||||
providers:
|
||||
- name: 'Prometheus'
|
||||
orgId: 1
|
||||
folder: ''
|
||||
type: file
|
||||
disableDeletion: false
|
||||
editable: true
|
||||
options:
|
||||
path: /etc/grafana/provisioning/dashboards
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,50 @@
|
|||
# config file version
|
||||
apiVersion: 1
|
||||
|
||||
# list of datasources that should be deleted from the database
|
||||
deleteDatasources:
|
||||
- name: Prometheus
|
||||
orgId: 1
|
||||
|
||||
# list of datasources to insert/update depending
|
||||
# whats available in the database
|
||||
datasources:
|
||||
# <string, required> name of the datasource. Required
|
||||
- name: Prometheus
|
||||
# <string, required> datasource type. Required
|
||||
type: prometheus
|
||||
# <string, required> access mode. direct or proxy. Required
|
||||
access: proxy
|
||||
# <int> org id. will default to orgId 1 if not specified
|
||||
orgId: 1
|
||||
# <string> url
|
||||
url: http://prometheus:9090
|
||||
# <string> database password, if used
|
||||
password:
|
||||
# <string> database user, if used
|
||||
user:
|
||||
# <string> database name, if used
|
||||
database:
|
||||
# <bool> enable/disable basic auth
|
||||
basicAuth: true
|
||||
# <string> basic auth username
|
||||
basicAuthUser: admin
|
||||
# <string> basic auth password
|
||||
basicAuthPassword: foobar
|
||||
# <bool> enable/disable with credentials headers
|
||||
withCredentials:
|
||||
# <bool> mark as default datasource. Max one per org
|
||||
isDefault: true
|
||||
# <map> fields that will be converted to json and stored in json_data
|
||||
jsonData:
|
||||
graphiteVersion: "1.1"
|
||||
tlsAuth: false
|
||||
tlsAuthWithCACert: false
|
||||
# <string> json object of data that will be encrypted.
|
||||
secureJsonData:
|
||||
tlsCACert: "..."
|
||||
tlsClientCert: "..."
|
||||
tlsClientKey: "..."
|
||||
version: 1
|
||||
# <bool> allow users to edit datasources from the UI.
|
||||
editable: true
|
||||
BIN
test-network/prometheus-grafana/grafana_db/grafana.db
Normal file
BIN
test-network/prometheus-grafana/grafana_db/grafana.db
Normal file
Binary file not shown.
25
test-network/prometheus-grafana/prometheus/prometheus.yml
Normal file
25
test-network/prometheus-grafana/prometheus/prometheus.yml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
global:
|
||||
scrape_interval: 1s
|
||||
external_labels:
|
||||
monitor: 'devopsage-monitor'
|
||||
|
||||
scrape_configs:
|
||||
- job_name: "prometheus"
|
||||
static_configs:
|
||||
- targets: ["localhost:9090"]
|
||||
- job_name: "orderer"
|
||||
static_configs:
|
||||
- targets: ["orderer.example.com:9443"]
|
||||
- job_name: "peer0_org1"
|
||||
static_configs:
|
||||
- targets: ["peer0.org1.example.com:9444"]
|
||||
- job_name: "peer0_org2"
|
||||
static_configs:
|
||||
- targets: ["peer0.org2.example.com:9445"]
|
||||
- job_name: cadvisor
|
||||
scrape_interval: 5s
|
||||
static_configs:
|
||||
- targets: ['cadvisor:8080']
|
||||
- job_name: node
|
||||
static_configs:
|
||||
- targets: ['node-exporter:9100']
|
||||
Loading…
Reference in a new issue