Skip to content

matt-snider/flask-healthcheck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flask-healthcheck

Flask-Healthcheck is a Flask extension that provides a simple way of adding healthchecks to a service.

Example:

from flask import Flask
app = Flask(__name__)
healthcheck = Healthcheck(app)

@app.route('/')
def hello_world():
    return 'Hello world!'


@healthcheck
def connections():
    if len(connections) < 5:
        return False, 'Less than 5 active connections'
    else:
        return True

Making a request against this endoint will return a 200 status code and the following output when the healthcheck passes:

{
  "connections": {
    "healthy": true,
  }
}

And, the following if the healthcheck fails:

{
  "connections": {
    "healthy": false,
    "message": "Less than 5 active connections"
  }
}

Built-in Healthchecks

Healthchecks for some popular Flask extensions are already built in and just need to be activated:

from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy(app)
healthcheck.add_extension('sqlalchemy', db)

Here it's important to call add_extension() with the proper extension name and the extension object.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages