Skip to content

Commit

Permalink
add: prometheus metrics endpoint for node and signer
Browse files Browse the repository at this point in the history
add command to run the environment with signer on README.md
  • Loading branch information
bowtiedbot committed Oct 26, 2024
1 parent 5394a10 commit 420794a
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@ git clone https://github.com/stacks-network/stacks-blockchain-docker && cd stack
cp sample.env .env
```

### Sync from genesis
### Sync from genesis (no signer)

```bash
./manage.sh -n mainnet -a start
```

### Sync from genesis (with signer)

```bash
./manage.sh -n mainnet -a start -f signer
```

### Seed chainstate from Hiro Archiver

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. \
Expand Down
1 change: 1 addition & 0 deletions compose-files/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ services:
ports:
- ${STACKS_CORE_RPC_PORT:-20443}:${STACKS_CORE_RPC_PORT:-20443}
- ${STACKS_CORE_P2P_PORT:-20444}:${STACKS_CORE_P2P_PORT:-20444}
- ${NODE_METRICS_PORT:-9153}:${NODE_METRICS_PORT:-9153}
env_file:
- ${SCRIPTPATH}/.env
networks:
Expand Down
2 changes: 2 additions & 0 deletions compose-files/extra-services/signer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ services:
volumes:
- ${SCRIPTPATH}/conf/${NETWORK}:/src/stacks-signer
- ${SCRIPTPATH}/persistent-data/${NETWORK}/stacks-signer:/root/stacks-signer/data
ports:
- ${SIGNER_METRICS_PORT:-9154}:${SIGNER_METRICS_PORT:-9154}
env_file:
- ${SCRIPTPATH}/.env
networks:
Expand Down
1 change: 1 addition & 0 deletions conf/mainnet/Config.toml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ working_dir = "/root/stacks-blockchain/data"
rpc_bind = "0.0.0.0:20443"
p2p_bind = "0.0.0.0:20444"
bootstrap_node = "02196f005965cebe6ddc3901b7b1cc1aa7a88f305bb8c5893456b8f9a605923893@seed.mainnet.hiro.so:20444"
prometheus_bind = "0.0.0.0:9153"
stacker = true

[burnchain]
Expand Down
1 change: 1 addition & 0 deletions conf/mainnet/Signer.toml.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_host = "stacks-blockchain:20443"
endpoint = "0.0.0.0:30000"
metrics_endpoint = "0.0.0.0:9154"
network = "mainnet"
db_path = "/root/stacks-signer/data/signer.sqlite"
auth_password = ""
Expand Down
1 change: 1 addition & 0 deletions conf/mocknet/Config.toml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ rpc_bind = "0.0.0.0:20443"
p2p_bind = "0.0.0.0:20444"
wait_time_for_microblocks = 10000
use_test_genesis_chainstate = true
prometheus_bind = "0.0.0.0:9153"
stacker = true

[burnchain]
Expand Down
1 change: 1 addition & 0 deletions conf/mocknet/Signer.toml.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_host = "stacks-blockchain:20443"
endpoint = "0.0.0.0:30000"
metrics_endpoint = "0.0.0.0:9154"
network = "testnet"
db_path = "/root/stacks-signer/data/signer.sqlite"
auth_password = ""
Expand Down
1 change: 1 addition & 0 deletions conf/testnet/Config.toml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ bootstrap_node = "029266faff4c8e0ca4f934f34996a96af481df94a89b0c9bd515f3536a9568
always_use_affirmation_maps = true
require_affirmed_anchor_blocks = true
pox_sync_sample_secs = 30
prometheus_bind = "0.0.0.0:9153"
stacker = true

[burnchain]
Expand Down
1 change: 1 addition & 0 deletions conf/testnet/Signer.toml.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_host = "stacks-blockchain:20443"
endpoint = "0.0.0.0:30000"
metrics_endpoint = "0.0.0.0:9154"
network = "testnet"
db_path = "/root/stacks-signer/data/signer.sqlite"
auth_password = ""
Expand Down
2 changes: 2 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Most variables in `.env` shouldn't be modified, but there are a few you may wish
| `SIGNER_PRIVATE_KEY` | The private key of the signer, on mainnet. | |
| `TESTNET_SIGNER_PRIVATE_KEY` | The private key of the signer, on testnet. | |
| `STACKS_SIGNER_PORT` | The port where the signer will expose an RPC endpoint for receiving events from your Stacks node | `30000` |
| `SIGNER_METRICS_PORT` | The port where the signer will expose an endpoint for reading metrics | `9154` |

### API Settings

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

### Burnchain Settings

Expand Down
2 changes: 2 additions & 0 deletions manage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ update_configs(){
$(sed -i.tmp "
/^node_host/s/.*/node_host = \"${STACKS_CORE_RPC_HOST}:${STACKS_CORE_RPC_PORT}\"/;
/^endpoint/s/.*/endpoint = \"0.0.0.0:${STACKS_SIGNER_PORT}\"/;
/^metrics_endpoint/s/.*/metrics_endpoint = \"0.0.0.0:${SIGNER_METRICS_PORT}\"/;
/^auth_password/s/.*/auth_password = \"${AUTH_TOKEN}\"/;
/^stacks_private_key/s/.*/stacks_private_key = \"${SIGNER_PRIVATE_KEY}\"/;
" "${SIGNER_TOML}" 2>&1) || {
Expand All @@ -504,6 +505,7 @@ update_configs(){
/^peer_port/s/.*/peer_port = ${BTC_P2P_PORT}/;
/^auth_token/s/.*/auth_token = \"${AUTH_TOKEN}\"/;
/^endpoint = \"stacks-signer/s/.*/endpoint = \"stacks-signer:${STACKS_SIGNER_PORT}\"/;
/^prometheus_bind/s/.*/prometheus_bind = \"0.0.0.0:${NODE_METRICS_PORT}\"/;
" "${CONFIG_TOML}" 2>&1) || {
log_exit "Unable to update values in Config.toml file: ${COLCYAN}${CONFIG_TOML}${COLRESET}"
}
Expand Down
2 changes: 2 additions & 0 deletions sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ AUTH_TOKEN=1234
SIGNER_PRIVATE_KEY=
TESTNET_SIGNER_PRIVATE_KEY=
STACKS_SIGNER_PORT=30000
SIGNER_METRICS_PORT=9154

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

0 comments on commit 420794a

Please sign in to comment.