Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,266 changes: 1,266 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "btcnode-metrics"
edition = "2024"
version = "1.0.0"
description = "The Bitcoin node metrics exporter for Prometheus built on the Rust Bitcoin Community's corepc-client crate."
license-file = "LICENSE"
homepage = "https://github.com/AltaModaTech/btcnode-metrics"
repository = "https://github.com/AltaModaTech/btcnode-metrics"
readme = "README.md"
keywords = ["bitcoin", "prometheus", "metrics"]

[dependencies]
axum = "0.8"
tokio = { version = "1", features = ["full"] }
prometheus = "0.14"
serde = { version = "1", features = ["derive"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
clap = { version = "4", features = ["derive"] }
toml = "0.8"
anyhow = "1"
corepc-client = { version = "0.10", features = ["client-sync"] }
thiserror = "2"
46 changes: 45 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,46 @@
# btcnode-metrics
The Bitcoin node metrics exporter for Prometheus built on the Rust Bitcoin Community's corepc-client crate.

The best Bitcoin node metrics exporter for Prometheus based on [corepc-client](https://crates.io/crates/corepc-client).

## Install & Configure

### Install

`cargo install btcnode-metrics`

### Configure

After installing btcnode-metrics,

- Copy `config.toml.example` to `config.local.toml`.
- Edit `config.local.toml`
- the _node_ section is for the Bitcoin node to monitor
- the _server_ section is for exposing the endpoint for Prometheus

## Usage

To run:

`cargo run -- -c ./config.local.toml`

For additional output, set the [logging level(https://docs.rs/env_logger/latest/env_logger/)]:

`RUST_LOG=info cargo run -- -c ./config.local.toml`

## Additional Details

### About corepc-client

The [corepc-client](https://crates.io/crates/corepc-client) crate replaces the previous the Bitcoin node RPC crates that were archived on 11/25/2025:

- [bitcoincore-rpc](https://crates.io/crates/bitcoincore-rpc) [GitHub](https://github.com/rust-bitcoin/rust-bitcoincore-rpc)
- [bitcoincore-rpc-json](https://crates.io/crates/) [GitHub](https://github.com/rust-bitcoin/rust-bitcoincore-rpc/tree/master/json)

The Rust Bitcoin Community's public repository for this crate is at [corepc-client](https://github.com/rust-bitcoin/corepc).

### Code structure

This repository's code is separated into:

- _btcnode-metrics_ implements the API for Prometheus to call for gathering metrics.
- _btcnode-metrics_ gathers metrics from the Bitcoin node and transforms them into Prometheus format.
8 changes: 8 additions & 0 deletions config.local.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

[node]
rpc_url = "http://127.0.0.1:8332"
rpc_user = "bitcoin"
rpc_password = "bShipIt!7466c1"

[server]
listen_addr = "0.0.0.0:9898"
7 changes: 7 additions & 0 deletions config.toml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[node]
rpc_url = "http://127.0.0.1:8332"
rpc_user = "bitcoinrpc"
rpc_password = "changeme"

[server]
listen_addr = "0.0.0.0:9332"
5 changes: 5 additions & 0 deletions prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Refactor the code in this project to meet the following criteria:

- Convert the btcnode-metrics crate into a module of btcnode-metrics and rename it to btcnode-metrics-gatherer
- Change btcnode-metrics to use the btcnode-metrics-gatherer module and remove the former btcnode-metrics crate
- Ensure the resulting code compiles and tests continue passing
Loading