Flussonic Watcher documentation

Contents

Simple Event collector

The application accepts the POST-request, writes the JSON-data in a file /tmp/event.txt and sends JSON back to Watcher.

from flask import Flask, request, jsonify
import json

app=Flask(__name__)

@app.route('/events',methods = ['POST'])
def events():
    d = request.get_json(force=True)

    with open("/tmp/events.txt", "a") as write_events:
        write_events.write(str(d)+'\n')

    return jsonify(d)

app.run(host = '0.0.0.0',debug=true)

gunicorn is required for launching the application, install it using following command: pip3 install gunicorn

Run command, for example:

gunicorn --bind 0.0.0.0:5000 wsgi:app -D -w 3 --log-syslog --reload -g www-data -u www-data --log-file /var/log/event_coll.log --error-logfile /var/log/event_coll_error.log