Skip to content

Commit

Permalink
feat: implement prometheus metrics for base node (#3563)
Browse files Browse the repository at this point in the history
Description
---
- Instrument tari_comms for prometheus metrics
- add `metrics` feature to base node and tari_comms 
- add prometheus metrics scrape server
- add prometheus push client
- add configuration for metrics `common.metrics`
- add `get-network-stats` command
- fix bug in value for last request latency

Motivation and Context
---
Increase base node visibility

![image](https://user-images.githubusercontent.com/1057902/141313369-46060af6-5f27-4ca5-846c-998248996fbd.png)

**Dependencies**
- `warp` for http metric pull server
- `reqwest` for metric push client
- `prometheus` for instrumentation

How Has This Been Tested?
---
Manually

- run prometheus ```docker run --rm -it -p 9090:9090  -v `pwd`/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus```
- run base node(s) with `--metrics-bind-addr 127.0.0.1:5544`
- visit `localhost:9090`

```yaml
# prometheus.yml
scrape_configs:
  - job_name: 'node1'
    scrape_interval: 5s
    metrics_path: "/metrics"
    static_configs:
      - targets: ['host.docker.internal:5544']
        labels:
          node: 'node1'
```
  • Loading branch information
sdbondi committed Nov 15, 2021
1 parent 8d22164 commit 433bc46
Show file tree
Hide file tree
Showing 37 changed files with 1,339 additions and 94 deletions.
199 changes: 197 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -14,6 +14,7 @@ members = [
"comms/dht",
"comms/rpc_macros",
"common_sqlite",
"infrastructure/metrics",
"infrastructure/shutdown",
"infrastructure/storage",
"infrastructure/test_utils",
Expand Down
17 changes: 12 additions & 5 deletions applications/tari_base_node/Cargo.toml
Expand Up @@ -12,7 +12,7 @@ tari_app_grpc = { path = "../tari_app_grpc" }
tari_app_utilities = { path = "../tari_app_utilities" }
tari_common = { path = "../../common" }
tari_comms = { path = "../../comms", features = ["rpc"] }
tari_common_types = {path = "../../base_layer/common_types"}
tari_common_types = { path = "../../base_layer/common_types" }
tari_comms_dht = { path = "../../comms/dht" }
tari_core = { path = "../../base_layer/core", default-features = false, features = ["transactions"] }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", branch = "main" }
Expand All @@ -39,15 +39,22 @@ thiserror = "^1.0.26"
tokio = { version = "1.11", features = ["signal"] }
tonic = "0.5.2"
tracing = "0.1.26"

# network tracing, rt-tokio for async batch export
opentelemetry = { version = "0.16", default-features = false, features = ["trace", "rt-tokio"] }
opentelemetry-jaeger = { version = "0.15", features = ["rt-tokio", "collector_client", "reqwest_collector_client"] }
tracing-opentelemetry = "0.15.0"
tracing-subscriber = "0.2.20"

# network tracing, rt-tokio for async batch export
opentelemetry = { version = "0.16", default-features = false, features = ["trace","rt-tokio"] }
opentelemetry-jaeger = { version="0.15", features=["rt-tokio"]}
# Metrics
tari_metrics = { path = "../../infrastructure/metrics", optional = true }
warp = { version = "0.3.1", optional = true }
reqwest = { version = "0.11.4", default-features = false, optional = true }

[features]
avx2 = ["tari_core/avx2", "tari_crypto/avx2", "tari_p2p/avx2", "tari_comms/avx2", "tari_comms_dht/avx2"]
default = ["metrics"]
avx2 = ["tari_core/avx2", "tari_crypto/avx2", "tari_p2p/avx2", "tari_comms/avx2", "tari_comms_dht/avx2"]
metrics = ["warp", "reqwest", "tari_metrics", "tari_comms/metrics"]
safe = []


0 comments on commit 433bc46

Please sign in to comment.