Skip to content
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

feat: setup devenv observability #1105

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ $(EMILY_OPENAPI_SPEC): $(INSTALL_TARGET) $(EMILY_HANDLER_SOURCE_FILES)
# ----------------------------------------------------

devenv-no-sbtc-up:
docker compose -f docker/docker-compose.yml --profile default --profile bitcoin-mempool up
docker compose -f docker/docker-compose.yml --profile default --profile bitcoin-mempool --profile observability up

devenv-no-sbtc-down:
docker compose -f docker/docker-compose.yml --profile default --profile bitcoin-mempool down
docker compose -f docker/docker-compose.yml --profile default --profile bitcoin-mempool --profile observability down
matteojug marked this conversation as resolved.
Show resolved Hide resolved

devenv-up:
docker compose -f docker/docker-compose.yml --profile default --profile bitcoin-mempool --profile sbtc-signer up --detach
Expand Down
55 changes: 55 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ x-common-vars:
- &REWARD_RECIPIENT ${REWARD_RECIPIENT:-STQM73RQC4EX0A07KWG1J5ECZJYBZS4SJ4ERC6WN} # priv: 6ad9cadb42d4edbfbe0c5bfb3b8a4125ddced021c4174f829b714ccbf527f02001
- &EXIT_FROM_MONITOR 1 # set to "1" to automatically shut down via monitor.ts

volumes:
# prometheus-data: {}
grafana-data1: {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: do we want the trailing 1?
qq: why do we want a volume for one but not the other?

Copy link
Collaborator Author

@djordon djordon Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prometheus data is the raw metrics data. My thinking is that we don't usually want to preserve the metrics of some test run that happened yesterday. The grafana data includes things like "where is the prometheus host" and "what do my saved dashboards look like". Presumably, those will remain fixed between set up and tear down.

But sometimes I do want to keep metrics data which is why I had that volume there ready to go. I'm okay with keeping or discarding metrics data here.


# Templates.
# ------------------------------------------------------------------------------
x-postgres: &postgres
Expand Down Expand Up @@ -610,3 +614,54 @@ services:
command: "./wait-for-it.sh mariadb:3306 --timeout=720 --strict -- ./start.sh"
profiles:
- bitcoin-mempool

prometheus:
image: prom/prometheus:v2.45.2
djordon marked this conversation as resolved.
Show resolved Hide resolved
restart: always
volumes:
- ./local-prometheus.yml:/etc/prometheus/prometheus.yml
# - prometheus-data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
ports:
- 9090:9090
depends_on:
- vector
profiles:
- observability

grafana:
image: grafana/grafana:10.2.3-ubuntu
djordon marked this conversation as resolved.
Show resolved Hide resolved
user: '472'
restart: always
environment:
GF_INSTALL_PLUGINS: 'grafana-clock-panel,grafana-simple-json-datasource'
GF_SECURITY_ADMIN_USER: admin
GF_SECURITY_ADMIN_PASSWORD: admin
GF_USERS_ALLOW_SIGN_UP: 'false'
volumes:
- grafana-data1:/var/lib/grafana
- ./grafana/provisioning/:/etc/grafana/provisioning/
ports:
- 3030:3000
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This port is already used for the blocklist client.

depends_on:
- prometheus
profiles:
- observability

vector:
image: timberio/vector:0.34.2-distroless-static
command: --config /etc/vector/vector.toml
restart: always
ports:
- 9598
volumes:
- ./vector.toml:/etc/vector/vector.toml:ro
# This is needed for localhost networking
extra_hosts:
- "host.docker.internal:host-gateway"
profiles:
- observability
11 changes: 11 additions & 0 deletions docker/grafana/dashboards/dashboard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: 1

providers:
- name: 'Prometheus'
orgId: 1
folder: ''
type: file
disableDeletion: false
editable: true
options:
path: /etc/grafana/provisioning/dashboards
50 changes: 50 additions & 0 deletions docker/grafana/datasources/datasource.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# config file version
apiVersion: 1

# list of datasources that should be deleted from the database
deleteDatasources:
- name: Prometheus
orgId: 1

# list of datasources to insert/update depending
# whats available in the database
datasources:
# <string, required> name of the datasource. Required
- name: Prometheus
# <string, required> datasource type. Required
type: prometheus
# <string, required> access mode. direct or proxy. Required
access: proxy
# <int> org id. will default to orgId 1 if not specified
orgId: 1
# <string> url
url: http://prometheus:9090
# <string> database password, if used
password:
# <string> database user, if used
user:
# <string> database name, if used
database:
# <bool> enable/disable basic auth
basicAuth: false
# <string> basic auth username, if used
basicAuthUser:
# <string> basic auth password, if used
basicAuthPassword:
# <bool> enable/disable with credentials headers
withCredentials:
# <bool> mark as default datasource. Max one per org
isDefault: true
# <map> fields that will be converted to json and stored in json_data
jsonData:
graphiteVersion: "1.1"
tlsAuth: false
tlsAuthWithCACert: false
# <string> json object of data that will be encrypted.
secureJsonData:
tlsCACert: "..."
tlsClientCert: "..."
tlsClientKey: "..."
version: 1
# <bool> allow users to edit datasources from the UI.
editable: true
18 changes: 18 additions & 0 deletions docker/local-prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
evaluation_interval: 15s # By default, evaluate targets every 15 seconds.

rule_files:
# - "first.rules"
# - "second.rules"

scrape_configs:
- job_name: prometheus
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']

- job_name: vector
scrape_interval: 5s
static_configs:
- targets: ['vector:9598']
27 changes: 27 additions & 0 deletions docker/vector.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Prometheus Host metrics

[sources.host_metrics]
type = "host_metrics"
collectors = ["cpu", "disk", "load", "filesystem", "host", "memory", "network"]
scrape_interval_secs = 15

[sources.host_metrics.filesystem.mountpoints]
includes = ["/"]

[sources.host_metrics.disk.devices]
includes = ["/dev/root", "nvme*", "tmpfs"]

[sources.app]
type = "prometheus_scrape"
endpoints = [
"http://host.docker.internal:9181",
"http://host.docker.internal:9182",
"http://host.docker.internal:9183",
]

djordon marked this conversation as resolved.
Show resolved Hide resolved
## App Metric Sinks

[sinks.host_metrics_sink]
type = "prometheus_exporter"
inputs = ["host_metrics", "app"]
address = "0.0.0.0:9598"
1 change: 1 addition & 0 deletions envs/signer-1.env
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export SIGNER_SIGNER__SIGNER_ROUND_MAX_DURATION=5
export SIGNER_SIGNER__BITCOIN_PRESIGN_REQUEST_MAX_DURATION=5
export SIGNER_SIGNER__DKG_MAX_DURATION=5
export SIGNER_SIGNER__DKG_BEGIN_PAUSE=1
export SIGNER_SIGNER__PROMETHEUS_EXPORTER_ENDPOINT=0.0.0.0:9181

export SIGNER_SIGNER__BOOTSTRAP_SIGNING_SET=035249137286c077ccee65ecc43e724b9b9e5a588e3d7f51e3b62f9624c2a49e46,031a4d9f4903da97498945a4e01a5023a1d53bc96ad670bfe03adf8a06c52e6380,02007311430123d4cad97f4f7e86e023b28143130a18099ecf094d36fef0f6135c

Expand Down
1 change: 1 addition & 0 deletions envs/signer-2.env
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export SIGNER_SIGNER__SIGNER_ROUND_MAX_DURATION=5
export SIGNER_SIGNER__BITCOIN_PRESIGN_REQUEST_MAX_DURATION=5
export SIGNER_SIGNER__DKG_MAX_DURATION=5
export SIGNER_SIGNER__DKG_BEGIN_PAUSE=1
export SIGNER_SIGNER__PROMETHEUS_EXPORTER_ENDPOINT=0.0.0.0:9182

export SIGNER_SIGNER__BOOTSTRAP_SIGNING_SET=035249137286c077ccee65ecc43e724b9b9e5a588e3d7f51e3b62f9624c2a49e46,031a4d9f4903da97498945a4e01a5023a1d53bc96ad670bfe03adf8a06c52e6380,02007311430123d4cad97f4f7e86e023b28143130a18099ecf094d36fef0f6135c

Expand Down
1 change: 1 addition & 0 deletions envs/signer-3.env
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export SIGNER_SIGNER__SIGNER_ROUND_MAX_DURATION=5
export SIGNER_SIGNER__BITCOIN_PRESIGN_REQUEST_MAX_DURATION=5
export SIGNER_SIGNER__DKG_MAX_DURATION=5
export SIGNER_SIGNER__DKG_BEGIN_PAUSE=1
export SIGNER_SIGNER__PROMETHEUS_EXPORTER_ENDPOINT=0.0.0.0:9183

export SIGNER_SIGNER__BOOTSTRAP_SIGNING_SET=035249137286c077ccee65ecc43e724b9b9e5a588e3d7f51e3b62f9624c2a49e46,031a4d9f4903da97498945a4e01a5023a1d53bc96ad670bfe03adf8a06c52e6380,02007311430123d4cad97f4f7e86e023b28143130a18099ecf094d36fef0f6135c

Expand Down
2 changes: 1 addition & 1 deletion signers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ exec_run() {
. "$ENV_PATH/signer-$i.env" \
&& export RUST_LOG="$LOG_SETTINGS" \
&& export SIGNER_SIGNER__BOOTSTRAP_SIGNING_SET="$BOOTSTRAP_SIGNER_SET" \
&& cargo run --bin signer -- --config "$SIGNER_CONFIG" --migrate-db > "$PWD/target/signer-$i.log" 2>&1 \
&& cargo run --bin signer -- --config "$SIGNER_CONFIG" --migrate-db -o json > "$PWD/target/signer-$i.log" 2>&1 \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a flag to control the -o json? Otherwise checking the logs when running this natively will be quite annoying.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, will do.

&
)
i=$((i + 1))
Expand Down
Loading