Skip to content

Commit 19eb56f

Browse files
pinheadmzwillcl-ark
authored andcommitted
docs: explain prometheus metrics and remove more old docker crap
1 parent 24462bd commit 19eb56f

File tree

2 files changed

+74
-62
lines changed

2 files changed

+74
-62
lines changed

docs/monitoring.md

Lines changed: 69 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,83 @@
11
# Monitoring
22

3-
## Monitoring container resource usage
3+
## Prometheus
44

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.
67

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:
1011

11-
## CAdvisor
12+
```xml
13+
<node id="0">
14+
<data key="version">27.0</data>
15+
<data key="exporter">true</data>
16+
</node>
17+
```
1218

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)
1524

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:
1744

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+
```
2059

2160
## Grafana
2261

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
2581

26-
Grafana can be accessed on the docker host from localhost:3000 using username
27-
`admin` and password `admin` by default.
2882

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.
3183

32-
Additional dashboards and datasources may be added in the future.

docs/running.md

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Running Warnet
22

3-
Warnet runs a server which can be used to manage multiple networks. On docker
4-
this runs locally, but on Kubernetes this runs as a `statefulSet` in the
5-
cluster.
3+
Warnet runs a server which can be used to manage multiple networks.
4+
In Kubernetes this runs as a `statefulSet` in the cluster.
65

76
If the `$XDG_STATE_HOME` environment variable is set, the server will log to
87
a file `$XDG_STATE_HOME/warnet/warnet.log`, otherwise it will use `$HOME/.warnet/warnet.log`.
@@ -11,31 +10,9 @@ a file `$XDG_STATE_HOME/warnet/warnet.log`, otherwise it will use `$HOME/.warnet
1110

1211
// TODO
1312

14-
### Install logging infrastructure
13+
## Running large networks
1514

16-
First make sure you have `helm` installed, then simply run the following script:
17-
18-
```bash
19-
./scripts/install_logging.sh
20-
```
21-
22-
To forward port to view Grafana dashboard:
23-
24-
```bash
25-
./scripts/connect_logging.sh
26-
```
27-
28-
## Kubernetes (e.g. minikube)
29-
30-
To start the server run:
31-
32-
```bash
33-
warnet
34-
```
35-
36-
### Running large networks
37-
38-
When running a large number of containers on a single host machine (i.e. with the Docker interface), the system may run out of various resources.
15+
When running a large number of containers on a single host machine, the system may run out of various resources.
3916
We recommend setting the following values in /etc/sysctl.conf:
4017

4118
```sh
@@ -65,7 +42,7 @@ Apply the settings by either restarting the host, or without restarting using:
6542
sudo sysctl -p
6643
```
6744

68-
In addition to these settings, you may need to increase the maximum number of permitted open files for the user running the docker daemon (usually root) in /etc/security/limits.conf.
45+
In addition to these settings, you may need to increase the maximum number of permitted open files in /etc/security/limits.conf.
6946
This change is often not necessary though so we recommend trying your network without it first.
7047

7148
The following command will apply it to a single shell session, and not persist it.
@@ -75,19 +52,3 @@ Use as root before launching docker.
7552
# Increase the number of open files allowed per process to 4096
7653
ulimit -n 4096
7754
```
78-
79-
If you are running docker as a service via systemd you can apply it by adding the following to the service file and restarting the service:
80-
81-
```sh
82-
# Add the following under the [Service] section of the unit file
83-
LimitNOFILE=4096
84-
```
85-
86-
Reload the systemd configuration and restart the unit afterwards:
87-
88-
```
89-
sudo systemctl daemon-reload
90-
sudo systemctl restart docker
91-
```
92-
93-
On Ubuntu this file is located at `/lib/systemd/system/docker.service` but you can find it using `sudo systemctl status docker`.

0 commit comments

Comments
 (0)