|
1 | 1 | # Monitoring |
2 | 2 |
|
3 | | -## Monitoring container resource usage |
| 3 | +## Prometheus |
4 | 4 |
|
5 | | -When run in docker, a few additional containers are started up: |
| 5 | +To monitor RPC return values over time, a Prometheus data exporter can be connected |
| 6 | +to any Bitcoin Tank and configured to scrape any available RPC results. |
6 | 7 |
|
7 | | -* CAdvisor (container Monitoring) |
8 | | -* Prometheus (log scraper) |
9 | | -* Grafana (graphing/dashboard tool) |
| 8 | +The `bitcoin-exporter` image is defined in `resources/images/exporter` and |
| 9 | +maintained in the BitcoinDevProject dockerhub organization. To add the exporter |
| 10 | +in the Tank pod with Bitcoin Core add the `"exporter"` key to the node in the graphml file: |
10 | 11 |
|
11 | | -## CAdvisor |
| 12 | +```xml |
| 13 | + <node id="0"> |
| 14 | + <data key="version">27.0</data> |
| 15 | + <data key="exporter">true</data> |
| 16 | + </node> |
| 17 | +``` |
12 | 18 |
|
13 | | -CAdvisor needs no additional setup, and can be accessed from the docker host at |
14 | | -localhost:8080 |
| 19 | +The default metrics are defined in the `bitcoin-exporter` image: |
| 20 | +- Block count |
| 21 | +- Number of inbound peers |
| 22 | +- Number of outbound peers |
| 23 | +- Mempool size (# of TXs) |
15 | 24 |
|
16 | | -## Prometheus |
| 25 | +Metrics can be configured by setting a `"metrics"` key to the node in the graphml file. |
| 26 | +The metrics value is a space-separated list of labels, RPC commands with arguments, and |
| 27 | +JSON keys to resolve the desired data: |
| 28 | + |
| 29 | +``` |
| 30 | +label=method(arguments)[JSON result key][...] |
| 31 | +``` |
| 32 | + |
| 33 | +For example, the default metrics listed above are defined as: |
| 34 | + |
| 35 | +```xml |
| 36 | + <node id="0"> |
| 37 | + <data key="version">27.0</data> |
| 38 | + <data key="exporter">true</data> |
| 39 | + <data key="metrics">blocks=getblockcount() inbounds=getnetworkinfo()["connections_in"] outbounds=getnetworkinfo()["connections_in"] mempool_size=getmempoolinfo()["size"]</data> |
| 40 | + </node> |
| 41 | +``` |
| 42 | + |
| 43 | +The data can be retrieved from the Prometheus exporter on port `9332`, example: |
17 | 44 |
|
18 | | -Prometheus should also not need any additional setup, and can be accessed from |
19 | | -the docker host at localhost:9090 |
| 45 | +``` |
| 46 | +# HELP blocks getblockcount() |
| 47 | +# TYPE blocks gauge |
| 48 | +blocks 704.0 |
| 49 | +# HELP inbounds getnetworkinfo()["connections_in"] |
| 50 | +# TYPE inbounds gauge |
| 51 | +inbounds 0.0 |
| 52 | +# HELP outbounds getnetworkinfo()["connections_in"] |
| 53 | +# TYPE outbounds gauge |
| 54 | +outbounds 0.0 |
| 55 | +# HELP mempool_size getmempoolinfo()["size"] |
| 56 | +# TYPE mempool_size gauge |
| 57 | +mempool_size 0.0 |
| 58 | +``` |
20 | 59 |
|
21 | 60 | ## Grafana |
22 | 61 |
|
23 | | -Grafana is provisioned with a single default dashboard, but alternative |
24 | | -dashboards can be added or created. |
| 62 | +Data from Prometheus exporters can be collected and fed into Grafana for a |
| 63 | +web-based interface. |
| 64 | + |
| 65 | +### Install logging infrastructure |
| 66 | + |
| 67 | +First make sure you have `helm` installed, then run the `install_logging` script: |
| 68 | + |
| 69 | +```bash |
| 70 | +resources/scripts/install_logging.sh |
| 71 | +``` |
| 72 | + |
| 73 | +To forward port `3000` and view the Grafana dashboard run the `connect_logging` script: |
| 74 | + |
| 75 | +```bash |
| 76 | +resources/scripts/connect_logging.sh |
| 77 | +``` |
| 78 | + |
| 79 | +The Grafana dashboard (and API) will be accessible without requiring authentication |
| 80 | +at http://localhost:3000 |
25 | 81 |
|
26 | | -Grafana can be accessed on the docker host from localhost:3000 using username |
27 | | -`admin` and password `admin` by default. |
28 | 82 |
|
29 | | -The default dashboard is called "Docker Container & Host Metrics" and can be |
30 | | -accessed via the "dashboards" tab, or from the bottom right of the home screen. |
31 | 83 |
|
32 | | -Additional dashboards and datasources may be added in the future. |
|
0 commit comments