Last active
January 20, 2017 19:15
-
-
Save drawks/533b8b519a1bf44f9b1fd139a7abda31 to your computer and use it in GitHub Desktop.
minimal prometheus instrumentation of a bottle application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bottle import route, run, template, Bottle | |
from prometheus_client import multiprocess | |
from prometheus_client import generate_latest, REGISTRY, Gauge, Counter | |
application = Bottle() | |
IN_PROGRESS = Gauge("inprogress_requests", "help") | |
REQUESTS = Counter('http_requests_total', 'Description of counter', ['method', 'endpoint']) | |
@IN_PROGRESS.track_inprogress() | |
@application.route('/hello/<name>') | |
def index(name): | |
REQUESTS.labels(method='GET', endpoint="hello").inc() | |
return template('<b>Hello {{name}}</b>!', name=name) | |
@IN_PROGRESS.track_inprogress() | |
@application.route('/metrics') | |
def metrics(): | |
return generate_latest(REGISTRY) | |
application.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment