diff --git a/utils/prometheus/README.md b/utils/prometheus/README.md index 3add837de9e7e..67199143fcdd6 100644 --- a/utils/prometheus/README.md +++ b/utils/prometheus/README.md @@ -1,4 +1,4 @@ -# Substrate Prometheus Node Exporter +# Substrate Prometheus Exporter ![grants](./photo_2019-12-13_16-32-53.jpg) ## Introduction @@ -6,21 +6,11 @@ Prometheus is one of the most widely used monitoring tool for managing highly av ## Table of Contents -Hack Prometheus in Substrate - - Prometheus primer - - CLI Config - - Metrics Add - Metrics - - List of available metrics Start Prometheus - - Install prometheus - Edit Prometheus config file - - Start Prometheus -Start Grafana - - Install Grafana ## Metrics @@ -28,43 +18,11 @@ substrate can report and serve the Prometheus metrics, which in their turn can b This functionality is disabled by default. -To enable the Prometheus metrics, set in your cli command (--prometheus-addr,--prometheus-port ). -Metrics will be served under /metrics on 33333 port by default. - -### List of available metrics - - -Consensus metrics, namespace: `substrate` - -| **Name** | **Type** | **Tags** | **Description** | -| -------------------------------------- | --------- | -------- | --------------------------------------------------------------- | -| consensus_finality_block_height_number | IntGauge | | finality Height of the chain | -| consensus_best_block_height_number | IntGauge | | best Height of the chain | -| consensus_target_syn_number | IntGauge | | syning Height target number | -| consensus_num_txs | Gauge | | Number of transactions | -| consensus_node_memory | IntGauge | | Node's primary memory | -| consensus_node_cpu | IntGauge | | Node's cpu load | -| consensus_state_cache_size | IntGauge | | used state cache size | -| p2p_peers_number | IntGauge | | Number of peers node's connected to | -| p2p_peer_receive_bytes_per_sec | IntGauge | | number of bytes received from a given peer | -| p2p_peer_send_bytes_per_sec | IntGauge | | number of bytes sent to a given peer | -| Resource_receive_bytes_per_sec(Future) | IntGauge | | Operating System of bytes received | -| Resource_send_bytes_per_sec(Future) | IntGauge | | Operating System of bytes sent | -| Resource_cpu_use(Future) | IntGauge | | Operating System cpu load | -| Resource_disk_use(Future) | IntGauge | | Operating System disk use | -| validator_sign_prevote(Future) | IntGauge | validator addr | validator sign vote list | -| validator_sign_precommit(Future) | IntGauge | validator addr | validator sign commit list | +To enable the Prometheus metrics, set in your cli command (--prometheus_external, --prometheus-port ). +Metrics will be served under /metrics on 9955 port by default. ## Start Prometheus -### Install prometheus - -https://prometheus.io/download/ -```bash -wget -tar -zxvf -``` - ### Edit Prometheus config file You can visit [prometheus.yml](https://github.com/prometheus/prometheus/blob/master/documentation/examples/prometheus.yml) to download default `prometheus.yml`. @@ -74,7 +32,7 @@ Then edit `prometheus.yml` and add `jobs` : ```yaml - job_name: kusama static_configs: - - targets: ['localhost:33333'] + - targets: ['localhost:9955'] labels: instance: local-validator ``` @@ -83,35 +41,6 @@ Then edit `prometheus.yml` and add `jobs` : ### Start Prometheus -```bash -cd -./prometheus -``` - > The above example, you can save `prometheus.yml` at `~/volumes/prometheus` on your host machine You can visit `http://localhost:9090` to see prometheus data. - - - -## Start Grafana -### Install Grafana -https://grafana.com/docs/installation/debian/ - -```bash -apt-get install -y software-properties-common -sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main" -wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add - -sudo apt-get update -sudo apt-get install grafana -sudo service grafana-server start -./prometheus -``` - -You can visit `http://localhost:3000/` to open grafana and create your own dashboard. - -> Tips: The default username and password are both admin. We strongly recommend immediately changing your username & password after login - -### Seting Grafana - -Default ID:PW is admin. diff --git a/utils/prometheus/src/lib.rs b/utils/prometheus/src/lib.rs index 802a2b53b7fa5..7cb18b220028c 100644 --- a/utils/prometheus/src/lib.rs +++ b/utils/prometheus/src/lib.rs @@ -97,7 +97,7 @@ pub async fn init_prometheus(mut prometheus_addr: SocketAddr) -> Result<(), Err Err(err) => match err.kind() { io::ErrorKind::AddrInUse | io::ErrorKind::PermissionDenied if prometheus_addr.port() != 0 => { log::warn!( - "Prometheus server to already {} port.", prometheus_addr.port() + "Prometheus metric port {} already in use.", prometheus_addr.port() ); prometheus_addr.set_port(0); continue; @@ -112,12 +112,12 @@ pub async fn init_prometheus(mut prometheus_addr: SocketAddr) -> Result<(), Err } }); - let _server = Server::builder(Incoming(listener.incoming())) + let server = Server::builder(Incoming(listener.incoming())) .executor(Executor) .serve(service) .boxed(); - let result = _server.await.map_err(Into::into); + let result = server.await.map_err(Into::into); result }