Skip to content

Commit 420794a

Browse files
committed
add: prometheus metrics endpoint for node and signer
add command to run the environment with signer on README.md
1 parent 5394a10 commit 420794a

12 files changed

+22
-1
lines changed

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,18 @@ git clone https://github.com/stacks-network/stacks-blockchain-docker && cd stack
1616
cp sample.env .env
1717
```
1818

19-
### Sync from genesis
19+
### Sync from genesis (no signer)
2020

2121
```bash
2222
./manage.sh -n mainnet -a start
2323
```
2424

25+
### Sync from genesis (with signer)
26+
27+
```bash
28+
./manage.sh -n mainnet -a start -f signer
29+
```
30+
2531
### Seed chainstate from Hiro Archiver
2632

2733
Using data from the [Hiro Archiver](https://docs.hiro.so/hiro-archive) service, this script will download the latest files, extract them and restore the postgres data. \

compose-files/common.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ services:
2424
ports:
2525
- ${STACKS_CORE_RPC_PORT:-20443}:${STACKS_CORE_RPC_PORT:-20443}
2626
- ${STACKS_CORE_P2P_PORT:-20444}:${STACKS_CORE_P2P_PORT:-20444}
27+
- ${NODE_METRICS_PORT:-9153}:${NODE_METRICS_PORT:-9153}
2728
env_file:
2829
- ${SCRIPTPATH}/.env
2930
networks:

compose-files/extra-services/signer.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ services:
77
volumes:
88
- ${SCRIPTPATH}/conf/${NETWORK}:/src/stacks-signer
99
- ${SCRIPTPATH}/persistent-data/${NETWORK}/stacks-signer:/root/stacks-signer/data
10+
ports:
11+
- ${SIGNER_METRICS_PORT:-9154}:${SIGNER_METRICS_PORT:-9154}
1012
env_file:
1113
- ${SCRIPTPATH}/.env
1214
networks:

conf/mainnet/Config.toml.sample

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ working_dir = "/root/stacks-blockchain/data"
33
rpc_bind = "0.0.0.0:20443"
44
p2p_bind = "0.0.0.0:20444"
55
bootstrap_node = "02196f005965cebe6ddc3901b7b1cc1aa7a88f305bb8c5893456b8f9a605923893@seed.mainnet.hiro.so:20444"
6+
prometheus_bind = "0.0.0.0:9153"
67
stacker = true
78

89
[burnchain]

conf/mainnet/Signer.toml.sample

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
node_host = "stacks-blockchain:20443"
22
endpoint = "0.0.0.0:30000"
3+
metrics_endpoint = "0.0.0.0:9154"
34
network = "mainnet"
45
db_path = "/root/stacks-signer/data/signer.sqlite"
56
auth_password = ""

conf/mocknet/Config.toml.sample

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ rpc_bind = "0.0.0.0:20443"
33
p2p_bind = "0.0.0.0:20444"
44
wait_time_for_microblocks = 10000
55
use_test_genesis_chainstate = true
6+
prometheus_bind = "0.0.0.0:9153"
67
stacker = true
78

89
[burnchain]

conf/mocknet/Signer.toml.sample

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
node_host = "stacks-blockchain:20443"
22
endpoint = "0.0.0.0:30000"
3+
metrics_endpoint = "0.0.0.0:9154"
34
network = "testnet"
45
db_path = "/root/stacks-signer/data/signer.sqlite"
56
auth_password = ""

conf/testnet/Config.toml.sample

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ bootstrap_node = "029266faff4c8e0ca4f934f34996a96af481df94a89b0c9bd515f3536a9568
66
always_use_affirmation_maps = true
77
require_affirmed_anchor_blocks = true
88
pox_sync_sample_secs = 30
9+
prometheus_bind = "0.0.0.0:9153"
910
stacker = true
1011

1112
[burnchain]

conf/testnet/Signer.toml.sample

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
node_host = "stacks-blockchain:20443"
22
endpoint = "0.0.0.0:30000"
3+
metrics_endpoint = "0.0.0.0:9154"
34
network = "testnet"
45
db_path = "/root/stacks-signer/data/signer.sqlite"
56
auth_password = ""

docs/config.md

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Most variables in `.env` shouldn't be modified, but there are a few you may wish
3636
| `SIGNER_PRIVATE_KEY` | The private key of the signer, on mainnet. | |
3737
| `TESTNET_SIGNER_PRIVATE_KEY` | The private key of the signer, on testnet. | |
3838
| `STACKS_SIGNER_PORT` | The port where the signer will expose an RPC endpoint for receiving events from your Stacks node | `30000` |
39+
| `SIGNER_METRICS_PORT` | The port where the signer will expose an endpoint for reading metrics | `9154` |
3940

4041
### API Settings
4142

@@ -78,6 +79,7 @@ Most variables in `.env` shouldn't be modified, but there are a few you may wish
7879
| `STACKS_LOG_DEBUG` | Verbose output logs | `0` |
7980
| `STACKS_LOG_JSON` | Output logs in json format | `0` |
8081
| `STACKS_SHUTDOWN_TIMEOUT` | Time to wait for Stacks Blockchain to shutdown properly.<br>_recommended to leave this at the default_ | `1200` |
82+
| `NODE_METRICS_PORT` | The port where the node will expose an endpoint for reading metrics | `9153` |
8183

8284
### Burnchain Settings
8385

manage.sh

+2
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ update_configs(){
482482
$(sed -i.tmp "
483483
/^node_host/s/.*/node_host = \"${STACKS_CORE_RPC_HOST}:${STACKS_CORE_RPC_PORT}\"/;
484484
/^endpoint/s/.*/endpoint = \"0.0.0.0:${STACKS_SIGNER_PORT}\"/;
485+
/^metrics_endpoint/s/.*/metrics_endpoint = \"0.0.0.0:${SIGNER_METRICS_PORT}\"/;
485486
/^auth_password/s/.*/auth_password = \"${AUTH_TOKEN}\"/;
486487
/^stacks_private_key/s/.*/stacks_private_key = \"${SIGNER_PRIVATE_KEY}\"/;
487488
" "${SIGNER_TOML}" 2>&1) || {
@@ -504,6 +505,7 @@ update_configs(){
504505
/^peer_port/s/.*/peer_port = ${BTC_P2P_PORT}/;
505506
/^auth_token/s/.*/auth_token = \"${AUTH_TOKEN}\"/;
506507
/^endpoint = \"stacks-signer/s/.*/endpoint = \"stacks-signer:${STACKS_SIGNER_PORT}\"/;
508+
/^prometheus_bind/s/.*/prometheus_bind = \"0.0.0.0:${NODE_METRICS_PORT}\"/;
507509
" "${CONFIG_TOML}" 2>&1) || {
508510
log_exit "Unable to update values in Config.toml file: ${COLCYAN}${CONFIG_TOML}${COLRESET}"
509511
}

sample.env

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ AUTH_TOKEN=1234
1010
SIGNER_PRIVATE_KEY=
1111
TESTNET_SIGNER_PRIVATE_KEY=
1212
STACKS_SIGNER_PORT=30000
13+
SIGNER_METRICS_PORT=9154
1314

1415
###############################
1516
## Stacks Blockchain API
@@ -46,6 +47,7 @@ STACKS_EXPORT_EVENTS_FILE=/tmp/event-replay/stacks-node-events.tsv
4647
RUST_BACKTRACE=full
4748
STACKS_LOG_DEBUG=0
4849
STACKS_LOG_JSON=0
50+
NODE_METRICS_PORT=9153
4951
# STACKS_EVENT_OBSERVER=stacks-blockchain-api:3700
5052
##
5153
## How long to wait for stacks-blockchain event loop to stop (default is 20 minutes)

0 commit comments

Comments
 (0)