mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-04-11 13:43:08 +00:00
1.8 KiB
1.8 KiB
Metrics Counter Example
This example runs a tiny counter service together with a Prometheus scraper.
The scenarios increment counters through the node API and then query Prometheus to check the aggregate result.
How TF runs this
Each example follows the same pattern:
- TF starts the counter nodes and a Prometheus scraper
- a workload drives counter increments through the node API
- an expectation, or the manual scenario, checks the Prometheus query result
API
Each node exposes:
POST /counter/incto increment the local counterGET /counter/valueto read the current counter valueGET /metricsfor Prometheus scraping
Scenarios
compose_prometheus_expectationruns the app and Prometheus in Docker Compose, then checks the Prometheus query resultk8s_prometheus_expectationruns the same check on Kubernetesk8s_manual_prometheusstarts the nodes through the k8s manual cluster API, restarts one node, and checks the Prometheus aggregate again
Run with Docker Compose
LOGOS_BLOCKCHAIN_METRICS_QUERY_URL=http://127.0.0.1:19091 \
cargo run -p metrics-counter-examples --bin compose_prometheus_expectation
Run with Kubernetes
docker build -t metrics-counter-node:local -f examples/metrics_counter/Dockerfile .
LOGOS_BLOCKCHAIN_METRICS_QUERY_URL=http://127.0.0.1:30991 \
cargo run -p metrics-counter-examples --bin k8s_prometheus_expectation
Overrides:
METRICS_COUNTER_K8S_IMAGE(falls back toMETRICS_COUNTER_IMAGE, thenmetrics-counter-node:local)METRICS_COUNTER_K8S_PROMETHEUS_NODE_PORT(defaults to30991)
Run with Kubernetes manual cluster
docker build -t metrics-counter-node:local -f examples/metrics_counter/Dockerfile .
LOGOS_BLOCKCHAIN_METRICS_QUERY_URL=http://127.0.0.1:30991 \
cargo run -p metrics-counter-examples --bin k8s_manual_prometheus