Sign inSign up

r59q/easywebstats

By r59q

•Updated 11 months ago

Lightweight concurrent stat-collecting gin gonic web service with a simple API

Image
Developer tools
Monitoring & observability
Web analytics
0

2.0K

r59q/easywebstats repository overview

⁠easywebstats

Static Badge TeamCity Full Build Status Docker Image Size

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

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

⁠Reading statistics

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.

⁠Demo

A demo is available at ews-demo.r59q.com⁠. Check it out and try the api!

⁠Deploying

⁠Docker

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⁠

⁠Documentation

⁠Examples

⁠Registering statistics
⁠Set numeric value
# 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 numeric value

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
# }
⁠Reading statistics
⁠Read numeric values by label
# Curl example
curl -X 'GET' \
  'http://localhost:8080/api/v1/read/num/number_of_visits/about_page' \
  -H 'accept: application/json'

# Outputs
# {
#   "value": 10
# }

⁠Read numeric values
# 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
# }

⁠Prometheus Export

All numeric stats are exported for prometheus to scrape. Exports are available on the /metrics url.

⁠Source

Read more on github https://github.com/r59q/easywebstats⁠

Tag summary

Content type

Image

Digest

sha256:6fcd2cab8…

Size

12.5 MB

Last updated

11 months ago

docker pull r59q/easywebstats