-
Notifications
You must be signed in to change notification settings - Fork 54
Flexible RPC exporter for Prometheus #423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b446fac
1c10088
27cc9c7
48005d9
ada2d3f
5ef9a34
112b3c9
c577b29
cbc9f56
780d9a9
eba0fe4
8ff4134
73997e0
6e47bad
4fb03b1
034d6a0
7475b45
ec801df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,102 @@ | ||
| # Monitoring | ||
|
|
||
| ## Monitoring container resource usage | ||
| ## Prometheus | ||
|
|
||
| When run in docker, a few additional containers are started up: | ||
| To monitor RPC return values over time, a Prometheus data exporter can be connected | ||
| to any Bitcoin Tank and configured to scrape any available RPC results. | ||
|
|
||
| * CAdvisor (container Monitoring) | ||
| * Prometheus (log scraper) | ||
| * Grafana (graphing/dashboard tool) | ||
| The `bitcoin-exporter` image is defined in `resources/images/exporter` and | ||
| maintained in the BitcoinDevProject dockerhub organization. To add the exporter | ||
| in the Tank pod with Bitcoin Core add the `"exporter"` key to the node in the graphml file: | ||
|
|
||
| ## CAdvisor | ||
| ```xml | ||
| <node id="0"> | ||
| <data key="version">27.0</data> | ||
| <data key="exporter">true</data> | ||
| </node> | ||
| ``` | ||
|
|
||
| CAdvisor needs no additional setup, and can be accessed from the docker host at | ||
| localhost:8080 | ||
| The default metrics are defined in the `bitcoin-exporter` image: | ||
| - Block count | ||
| - Number of inbound peers | ||
| - Number of outbound peers | ||
| - Mempool size (# of TXs) | ||
|
|
||
| ## Prometheus | ||
| Metrics can be configured by setting a `"metrics"` key to the node in the graphml file. | ||
| The metrics value is a space-separated list of labels, RPC commands with arguments, and | ||
| JSON keys to resolve the desired data: | ||
|
|
||
| ``` | ||
| label=method(arguments)[JSON result key][...] | ||
| ``` | ||
|
|
||
| For example, the default metrics listed above are defined as: | ||
|
|
||
| ```xml | ||
| <node id="0"> | ||
| <data key="version">27.0</data> | ||
| <data key="exporter">true</data> | ||
| <data key="metrics">blocks=getblockcount() inbounds=getnetworkinfo()["connections_in"] outbounds=getnetworkinfo()["connections_in"] mempool_size=getmempoolinfo()["size"]</data> | ||
| </node> | ||
| ``` | ||
|
|
||
| Prometheus should also not need any additional setup, and can be accessed from | ||
| the docker host at localhost:9090 | ||
| The data can be retrieved from the Prometheus exporter on port `9332`, example: | ||
|
|
||
| ``` | ||
| # HELP blocks getblockcount() | ||
| # TYPE blocks gauge | ||
| blocks 704.0 | ||
| # HELP inbounds getnetworkinfo()["connections_in"] | ||
| # TYPE inbounds gauge | ||
| inbounds 0.0 | ||
| # HELP outbounds getnetworkinfo()["connections_in"] | ||
| # TYPE outbounds gauge | ||
| outbounds 0.0 | ||
| # HELP mempool_size getmempoolinfo()["size"] | ||
| # TYPE mempool_size gauge | ||
| mempool_size 0.0 | ||
| ``` | ||
|
|
||
| ## Grafana | ||
|
|
||
| Grafana is provisioned with a single default dashboard, but alternative | ||
| dashboards can be added or created. | ||
| Data from Prometheus exporters can be collected and fed into Grafana for a | ||
| web-based interface. | ||
|
|
||
| ### Install logging infrastructure | ||
|
|
||
| First make sure you have `helm` installed, then run the `install_logging` script: | ||
|
|
||
| ```bash | ||
| resources/scripts/install_logging.sh | ||
| ``` | ||
|
|
||
| To forward port `3000` and view the Grafana dashboard run the `connect_logging` script: | ||
|
|
||
| ```bash | ||
| resources/scripts/connect_logging.sh | ||
| ``` | ||
|
|
||
| The Grafana dashboard (and API) will be accessible without requiring authentication | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know it's probably because I'm too dumb, but where are the actual logs? When I open grafana on localhost:3000 I don't see any connected logs coming in? This is with patch to default graph: diffdiff --git a/resources/graphs/default.graphml b/resources/graphs/default.graphml
index 153bd52..8c276a0 100644
--- a/resources/graphs/default.graphml
+++ b/resources/graphs/default.graphml
@@ -6,12 +6,14 @@
<key attr.name="exporter" attr.type="boolean" for="node" id="exporter"/>
<key attr.name="collect_logs" attr.type="boolean" for="node" id="collect_logs"/>
<key attr.name="image" attr.type="string" for="node" id="image"/>
+ <key attr.name="metrics" attr.type="string" for="node" id="metrics"/>
<graph edgedefault="directed">
<node id="0">
<data key="version">27.0</data>
<data key="bitcoin_config">-uacomment=w0</data>
<data key="exporter">true</data>
<data key="collect_logs">true</data>
+ <data key="metrics">blocks=getblockcount() inbounds=getnetworkinfo()["connections_in"] outbounds=getnetworkinfo()["connections_in"] mempool_size=getmempoolinfo()["size"]</data>
</node>
<node id="1">
<data key="version">27.0</data>
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I see running logging containers? This is all I see: The script appeared to run successfully:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. kubectl does show preometheus running: ₿ kubectl --namespace warnet-logging get pods -l "release=prometheus"
NAME READY STATUS RESTARTS AGE
prometheus-kube-prometheus-operator-6c5998f7dc-hjvwx 1/1 Running 0 9m27s
prometheus-kube-state-metrics-688d66b5b8-8srsw 1/1 Running 0 9m27s
prometheus-prometheus-node-exporter-8tt7q 1/1 Running 0 9m27sBut I don't see any node exporters?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. server logs don't appear to contain any errors:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do see a single running exporter (I think):
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The exporters are inside the tank pods, next to the bitcoin containers. The stuff in warnet-logging is the grafana api server and the prometheus scraper that reads from the individual tank exporters. I know there is a "node exporter" pod in warnet-logging as well, I dunno what that is actually for and on my system, it never works anyway: As far as seeing something in Grafana right away you're right I didn't document that, I will push another commit today that hopefully makes a default dashboard easy to load
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @willcl-ark logs are in Loki not Prometheus. There are no additional containers for Loki to get it's data as it collects it via k8s directly similar to how you can do |
||
| at http://localhost:3000 | ||
|
|
||
| ## Dashboards | ||
|
|
||
| To view the default metrics in the included default dashboard, upload the dashboard | ||
| JSON file to the Grafana server: | ||
|
|
||
| ``` | ||
| curl localhost:3000/api/dashboards/db \ | ||
| -H "Content-Type: application/json" \ | ||
| --data "{\"dashboard\": $(cat resources/configs/grafana/default_dashboard.json)}" | ||
| ``` | ||
|
|
||
| Note the URL in the reply from the server (example): | ||
|
|
||
| ``` | ||
| {"folderUid":"","id":2,"slug":"default-warnet-dashboard","status":"success","uid":"fdu0pda1z6a68b","url":"/d/fdu0pda1z6a68b/default-warnet-dashboard","version":1}( | ||
| ``` | ||
|
|
||
| Grafana can be accessed on the docker host from localhost:3000 using username | ||
| `admin` and password `admin` by default. | ||
| Open the dashboard in your browser (example): | ||
|
|
||
| The default dashboard is called "Docker Container & Host Metrics" and can be | ||
| accessed via the "dashboards" tab, or from the bottom right of the home screen. | ||
| `http://localhost:3000/d/fdu0pda1z6a68b/default-warnet-dashboard` | ||
|
|
||
| Additional dashboards and datasources may be added in the future. | ||




There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a
metricskey to both default graph and generated graphs fromwarcli graph createso that users can easily add this key without gettingmissing key(at the graph level) errors.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool done