A backend for https://stats.golem.network serving handful of REST endpoints. Uses redis as a data store.
Server has three features switchable at compile time. Two of them are enabled by default.
stats_update | list_nodes | pingme | |
---|---|---|---|
is default | ✓ | ✓ | ✗ |
endpoints | / , /update |
/dump , /v1/nodes |
/ping-me |
Depending on selected features server supports following endpoints:
endpoint | http method | description |
---|---|---|
/ |
GET | redirects to /show (configurable) |
/ and /update |
POST | accept {json} messages from Golem nodes. Number of types are supported. Most notable are: node info, usage stats and p2p network info. Writes data into redis |
/dump |
GET | dumps whole redis store into csv format (compatible with old monitor frontend) |
/v1/nodes |
GET | responds with {json} containing info about active nodes. Golem node is considered active when it has triggered /update within last 120 s (configurable). Used by new monitor frontend |
/ping-me |
POST | accept {json} request to scan up to 5 ports at origin IP (read from x-forwarded-for header; it is by design to be deployed behind some load balancer e.g. nginx ) |
Server can be configured through environment variables. Here are their default values
GOLEM_MONITOR_ADDRESS=0.0.0.0:8081
GOLEM_MONITOR_REDIS=127.0.0.1:6379
GOLEM_MONITOR_REDIRECT=/show
GOLEM_MONITOR_REDIRECT=120
# additionally, this rust built-in env var is preset to
RUST_LOG=actix_web=info,actix_redis=info,golem_monitor_rust=info
which means by default the backend server:
- listens on
0.0.0.0:8081
- writes to a local redis instance at
127.0.0.1:6379
To run in development mode use e.g.
RUST_LOG="actix_web=info,actix_redis=info,golem_monitor_rust=debug" \
GOLEM_MONITOR_ADDRESS="0.0.0.0:2732" \
cargo run
We are generating change-log's via git journal. This requires each commit to have category. For category list see .gitjournal.toml.
Please install it locally when you're planning to contribute:
cargo install git-journal
git journal setup
To bump version we are using cargo release minor
or ... patch
.
Use cargo install cargo-release
to get this tool.
To build and release .deb
package use cargo deb
Use cargo install cargo-deb
to get it.
- make sure local redis server is running
- run golem monitor replicator (e.g.
cargo run
) - then post some request to it
curl \
--header "Content-Type: application/json" \
--request POST \
--data '{
"proto_ver": 2,
"data": {
"known_tasks": 0,
"supported_tasks": 2721,
"computed_tasks": 0,
"tasks_with_errors": 0,
"tasks_with_timeout": 0,
"tasks_requested": 314,
"sessid": "5bbeefa5-423e-425c-92dd-bde94e2c9777",
"cliid": "some-fake-cliid",
"timestamp": 1,
"type": "Stats"
}
}' \
http://localhost:8081
- start local redis
- run
cargo build --features=pingme
- run
curl \
--header "Content-Type: application/json" \
--request POST \
--data '{"timestamp":1, "ports":[40102, 40103, 3282]}' \
http://localhost:8081/ping-me