add prometheus/grafana performances sample into test-network directory

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>
This commit is contained in:
fraVlaca 2021-11-22 11:37:39 +00:00
parent bd559c81c8
commit 07470e45cb
9 changed files with 2619 additions and 6 deletions

View file

@ -43,7 +43,8 @@ services:
- ORDERER_ADMIN_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
- ORDERER_ADMIN_TLS_CLIENTROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
- ORDERER_ADMIN_LISTENADDRESS=0.0.0.0:7053
- ORDERER_OPERATIONS_LISTENADDRESS=0.0.0.0:17050
- ORDERER_OPERATIONS_LISTENADDRESS=orderer.example.com:9443
- ORDERER_METRICS_PROVIDER=prometheus
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: orderer
volumes:
@ -54,7 +55,7 @@ services:
ports:
- 7050:7050
- 7053:7053
- 17050:17050
- 9443:9443
networks:
- test
@ -83,7 +84,8 @@ services:
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:17051
- CORE_OPERATIONS_LISTENADDRESS=peer0.org1.example.com:9444
- CORE_METRICS_PROVIDER=prometheus
volumes:
- ${DOCKER_SOCK}:/host/var/run/docker.sock
- ../organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp
@ -93,7 +95,7 @@ services:
command: peer node start
ports:
- 7051:7051
- 17051:17051
- 9444:9444
networks:
- test
@ -122,7 +124,8 @@ services:
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:9051
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:9051
- CORE_PEER_LOCALMSPID=Org2MSP
- CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:19051
- CORE_OPERATIONS_LISTENADDRESS=peer0.org2.example.com:9445
- CORE_METRICS_PROVIDER=prometheus
volumes:
- ${DOCKER_SOCK}:/host/var/run/docker.sock
- ../organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp
@ -132,7 +135,7 @@ services:
command: peer node start
ports:
- 9051:9051
- 19051:19051
- 9445:9445
networks:
- test

View file

@ -0,0 +1,47 @@
# 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 is meant to be used on **linux** in order to fully benefit from its capabilities. However, it can be used and adapted on other systems with some additional work and tweaks.
You will need to have installed **docker-compose with version 1.29 or above**.
# How to use
1. Bring up the test-network
2. Bring up the Prometheus/Grafana network --> **docker-compose up -d**
3. Log in: type “< address >:3000” on your web browser -> username=“admin”, password=“admin”
4. Browse dashboard and analyze results
Extras: add new queries, modify dashboard & add relevant changes to main repo --> extract json and it to "grafana/dashboards/hlf-performances.json"
# 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 conteners metrics
# Prometheus "confgaration 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/

View 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

View file

@ -0,0 +1,2 @@
GF_SECURITY_ADMIN_PASSWORD=admin
GF_USERS_ALLOW_SIGN_UP=false

View file

@ -0,0 +1,11 @@
apiVersion: 1
providers:
- name: 'Prometheus'
orgId: 1
folder: ''
type: file
disableDeletion: false
editable: true
options:
path: /etc/grafana/provisioning/dashboards

View file

@ -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

Binary file not shown.

View 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']