Lightweight concurrent stat-collecting gin gonic web service with a simple API
2.0K
Lightweight concurrent stat-collecting gin gonic web service with a simple API. Stats are queried using REST and are exported as prometheus metrics.
Registering statistics is automatically done when settings values. No initialization is needed, just set the values you wish to track.
Data values are grouped by name and label.
Data is stored periodically (10 minutes interval) to a /data directory. When running in docker a mount to /data will ensure data is store persistently. The storage medium does not impact the performance of queries, it's just for storing the in-memory state
When stats are registered using a name and label, you can either read all stats for a given name, or a specific value for a given label and name.
A demo is available at ews-demo.r59q.com. Check it out and try the api!
Standalone container
docker run --name easywebstats -p 8080:8080 -d r59q/easywebstats
# With data volume
docker run --name easywebstats -p 8080:8080 --volume ews_data:/data -d easywebstats
Part of a docker compose
# docker-compose.yml
services:
webstats:
image: r59q/easywebstats
ports:
- "8080:8080"
restart: always
volumes:
- ews_data:/data
docker compose up -d
Swagger docs available at http://localhost:8080/swagger/index.html
# Curl example
curl -X 'POST' \
'http://localhost:8080/api/v1/register/num/set' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"name": "number_of_visits",
"label": "about_page",
"value": 10
}'
# Outputs (Returns the updated number of visits)
# {
# "value": 10
# }
Increase the number of visits on the about page by 1
# Curl example
curl -X 'POST' \
'http://localhost:8080/api/v1/register/num/increase' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"name": "number_of_visits",
"label": "about_page",
"value": 1
}'
# Outputs (Returns the updated number of visits)
# {
# "value": 11
# }
# Curl example
curl -X 'GET' \
'http://localhost:8080/api/v1/read/num/number_of_visits/about_page' \
-H 'accept: application/json'
# Outputs
# {
# "value": 10
# }
# Curl example
curl -X 'GET' \
'http://localhost:8080/api/v1/read/num/number_of_visits' \
-H 'accept: application/json'
# Outputs
# {
# "about_page": 10,
# "home_page": 321
# }
All numeric stats are exported for prometheus to scrape. Exports are available on the /metrics url.
Read more on github https://github.com/r59q/easywebstats
Content type
Image
Digest
sha256:6fcd2cab8…
Size
12.5 MB
Last updated
11 months ago
docker pull r59q/easywebstats