[website]: add prometheus monitor (#27074)

* docs/monitoring: add prometheus metric

Signed-off-by: jsvisa <delweng@gmail.com>

* docs: grafana2 image

Signed-off-by: jsvisa <delweng@gmail.com>

* docs/monitoring: don't set recording rules

Signed-off-by: jsvisa <delweng@gmail.com>

---------

Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
Delweng 2023-04-26 14:41:32 +08:00 committed by GitHub
parent 6eab645de9
commit 5a9af8c064
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 78 additions and 2 deletions

View File

@ -69,6 +69,51 @@ exit
InfluxDB is running and configured to store metrics from Geth.
## Setting up Prometheus {#setting-up-prometheus}
Prometheus can be downloaded from the [Prometheus](https://prometheus.io/download/). There is also a Docker image at [prom/prometheus](https://hub.docker.com/r/prom/prometheus), you can run in containerized environments. eg:
```sh
docker run \
-p 9090:9090 \
-v /path/to/prometheus:/etc/prometheus \
prom/prometheus:latest
```
Here a example directoy of `/path/to/promethus`:
```sh
prometheus/
├── prometheus.yml
└── record.geth.rules.yml
```
And an example of `prometheus.yml` is:
```yaml
global:
scrape_interval: 15s
evaluation_interval: 15s
# Load and evaluate rules in this file every 'evaluation_interval' seconds.
rule_files:
- 'record.geth.rules.yml'
# A scrape configuration containing exactly one endpoint to scrape.
scrape_configs:
- job_name: 'go-ethereum'
scrape_interval: 10s
metrics_path: /debug/metrics/prometheus
static_configs:
- targets:
- '127.0.0.1:6060'
labels:
chain: ethereum
```
Meanwhile, [Recording rules](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/) are a powerful feature that allow you to precompute frequently needed or computationally expensive expressions and save their results as new sets of time series. Read more about setting up recording rules at the [official prometheus docs](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/).
## Preparing Geth {#preparing-geth}
After setting up database, metrics need to be enabled in Geth. Various options are available, as documented in the `METRICS AND STATS OPTIONS`
@ -128,10 +173,14 @@ Click on "Save and test" and wait for the confirmation to pop up.
Grafana is now set up to read data from InfluxDB. Now a dashboard can be created to interpret and display it. Dashboards properties are encoded in JSON files which can be created by anybody and easily imported. On the left bar, click on the "Dashboards" icon, then "Import".
For a Geth monitoring dashboard, copy the URL of [this dashboard](https://grafana.com/grafana/dashboards/13877/) and paste it in the "Import page" in Grafana. After saving the dashboard, it should look like this:
For a Geth InfluxDB monitoring dashboard, copy the URL of [this dashboard](https://grafana.com/grafana/dashboards/13877/) and paste it in the "Import page" in Grafana. After saving the dashboard, it should look like this:
![Grafana 1](/images/docs/grafana.png)
For a Geth Prometheus monitoring dashboard, copy the URL of [this dashboard](https://grafana.com/grafana/dashboards/18463/) and paste it in the "Import page" in Grafana. After saving the dashboard, it should look like this:
![Grafana 2](/images/docs/grafana2.png)
## Customization {#customization}
The dashboards can be customized further. Each panel can be edited, moved, removed or added. To learn more about how dashboards work, refer to

View File

@ -60,7 +60,6 @@ chain/account/commits.fifteen-minute: 0.029134344092314267
chain/account/commits.five-minute: 0.029134344092314267
...
```
Any developer is free to add, remove or modify the available metrics as they see fit. The precise list of available metrics is always available by opening the metrics server in the browser.
@ -79,6 +78,34 @@ Geth also supports dumping metrics directly into an influx database. In order to
--metrics.influxdb.organization value InfluxDB organization name (v2 only) (default: "geth")
```
We also provide Prometheus-formatted metrics data, which can be obtained through the `http://127.0.0.1:6060/debug/metrics/prometheus` URL, eg:
```sh
# TYPE chain_account_commits_count counter
chain_account_commits_count 6506
# TYPE chain_account_commits summary
chain_account_commits {quantile="0.5"} 8.194577e+06
chain_account_commits {quantile="0.75"} 1.016841725e+07
chain_account_commits {quantile="0.95"} 1.4334824899999999e+07
chain_account_commits {quantile="0.99"} 1.923948246000001e+07
chain_account_commits {quantile="0.999"} 5.038267952400009e+07
chain_account_commits {quantile="0.9999"} 5.108694e+07
# TYPE chain_account_hashes_count counter
chain_account_hashes_count 6506
# TYPE chain_account_hashes summary
chain_account_hashes {quantile="0.5"} 1.565746e+06
chain_account_hashes {quantile="0.75"} 1.87953975e+06
chain_account_hashes {quantile="0.95"} 4.6262716e+06
chain_account_hashes {quantile="0.99"} 8.655076970000029e+06
chain_account_hashes {quantile="0.999"} 4.823811956800011e+07
chain_account_hashes {quantile="0.9999"} 4.9055682e+07
...
```
## Creating and updating metrics {#creating-and-updating-metrics}
Metrics can be added easily in the Geth source code:

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB