Querying Hyperledger Fabric Metrics APIs
You can query the Hyperledger Fabric metrics and publish the output to a Prometheus database.
Starting in Hyperledger Fabric 1.4, the RESTful operations service provides a metrics endpoint which allows you to utilize Prometheus to pull operational metrics from peer and orderer nodes. Oracle Blockchain Platform has created a new endpoint to allow you to query these metrics: Get the Native Fabric Metrics for Peer or Orderer
Refer to the Hyperledger Fabric metrics documentation for additional information.
Create the Prometheus Database
A typical Prometheus deployment scrapes metrics by requesting them from an HTTP endpoint exposed by instrumented targets. As Prometheus is responsible for requesting the metrics, it is considered a pull system.
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
metrics_path: '/console/admin/api/v1.1/dashboard/statistics/metrics'
params:
nodeId:['peer0']
scheme: 'https'
tls_config:
insecure_skip_verify: true
static_configs:
- targets: ['hostname.com:10001']
Call the REST API to Query the Hyperledger Fabric Metrics
- method: GET
- path:
/console/admin/api/v1.1/dashboard/statistics/metrics
- query parameters:
nodeID(required): The node ID of the peer or orderer to be queried.
curl -X GET "https://<rest_server_url:port>/console/admin/api/v1.1/dashboard/statistics/metrics?nodeId=peer0"
-H "accept:application/json"