Flask Graylog client
Project description
flask-graylog-bundle
Graylog extension for Flask
Quickstart
First, install flask-graylog using pip:
$ pip install flask-graylog
Auth extension
To enable Graylog auth, add a GraylogAuth instance to your code:
from flask import current_app as app
from flask_graylog.auth import GraylogAuth
app.config.update({
"GRAYLOG_URL": "http://127.0.0.1:12900"
})
auth = GraylogAuth(app)
You can take a look at examples/auth.py for more complete example. Flask’s application factories and blueprints.
It provides a login decorator login_required. To use it just wrap a view function:
@app.route('/secret-page')
@auth.login_required
def secret_page():
return jsonify({
"message": "hello",
"username": auth.username
})
Additionnal info can be accessed using g.user (see: Graylog REST API result of GET /users/{username})
NOTE: Graylog tokens are supported, take a look at the Graylog REST API documentation.
API client
To use query Graylog API, add a GraylogAPIServer instance to your code:
from flask import Flask
from flask_graylog.server import GraylogAPIServer
app = Flask(__name__)
app.config.update({
"GRAYLOG_URL": "http://127.0.0.1:12900",
"GRAYLOG_USERNAME": "admin",
"GRAYLOG_PASSWORD": "admin"
})
api = GraylogAPIServer(app)
You can take a look at examples/api.py for a complete example.
License
Apache License 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for flask-graylog-bundle-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b742d66f763d8e279cfa78c427f026fee511c9fe92ac45b12d2d79cb999d2006 |
|
MD5 | 75a4b5a557d09f2008d11f76f7a50d5f |
|
BLAKE2b-256 | 8bb82e565b33e3d8c239b99b91659404cbb8eac657cf109ee53fad6dbc0a9bb8 |