Code Monkey home page Code Monkey logo

turfgame-exporter's Introduction

turfgame-exporter

Flask application that exposes user metrics from Turf to Prometheus. The application is built as an 12-factor app and uses Redis as backing service and Celery for background tasks.

Deployment using Dokku

On host running Dokku
$ dokku apps:create turfgame-exporter && \
  dokku redis:create turfgame-exporter && \
  dokku redis:link turfgame-exporter turfgame-exporter && \
  dokku config:set turfgame-exporter TURF_USERS=<turf username> && \
  dokku ps:scale turfgame-exporter beat=1 web=1 worker=1
In a directory containing a clone of this repository
git remote add turfgame-exporter dokku@<host_running_dokku>:turfgame-exporter
Deploy with git push
$ git push turfgame-exporter master

Deployment using Heroku

https://devcenter.heroku.com/articles/getting-started-with-python

Configuration

Configuration is done with environment variables using dokku config:set:

dokku config:set turfgame-exporter TURF_USERS=<turf username>

Required

Environment variable Description
REDIS_URL Connection string to Redis
TURF_USERS Comma separated list of Turf usernames

Optional

Environment variable Default value Description
TURF_API_USERS_URL https://api.turfgame.com/v4/users Turf API enpoint
CHECK_INTERVAL_SEC 300 Interval in which statistics is polled from Turf API.
LOGLEVEL INFO Set loglevel

Example output

The data exposed when visiting the /metrics-endpoint:

# HELP turfgame_user_zones_owned Number of zones owned
# TYPE turfgame_user_zones_owned gauge
turfgame_user_zones_owned{user="someuser"} 1
# HELP turfgame_user_points_per_hour Number of points received per hour
# TYPE turfgame_user_points_per_hour gauge
turfgame_user_points_per_hour{user="someuser"} 4
# HELP turfgame_user_points Number of points received in this round
# TYPE turfgame_user_points gauge
turfgame_user_points{user="someuser"} 14956
# HELP turfgame_user_blocktime The users blocktime
# TYPE turfgame_user_blocktime counter
turfgame_user_blocktime{user="someuser"} 16
# HELP turfgame_user_taken Number of zones taken
# TYPE turfgame_user_taken counter
turfgame_user_taken{user="someuser"} 1387
# HELP turfgame_user_total_points The users total points
# TYPE turfgame_user_total_points counter
turfgame_user_total_points{user="someuser"} 218623
# HELP turfgame_user_rank The users rank
# TYPE turfgame_user_rank counter
turfgame_user_rank{user="someuser"} 26
# HELP turfgame_user_place The users place
# TYPE turfgame_user_place gauge
turfgame_user_place{user="someuser"} 1774
# HELP turfgame_user_unique_zones_taken Number of unique zones the user has taken
# TYPE turfgame_user_unique_zones_taken counter
turfgame_user_unique_zones_taken{user="someuser"} 263
# HELP turfgame_user_medals_taken Number of medals the user has taken
# TYPE turfgame_user_medals_taken counter
turfgame_user_medals_taken{user="someuser"} 16

turfgame-exporter's People

Contributors

dependabot[bot] avatar dhose avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.