Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flask-monitor

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flask-monitor

Flask Monitor module

  • 0.2.6
  • PyPI
  • Socket score

Maintainers
1

Flask-monitor

Generate time of execution and send data on multi destination

  • log
  • influxdb (and so grafana)
  • rabbitmq
  • zeromq
  • statsd

Installation

::

pip install flask-monitor
    

Or

::

git clone https://github.com/fraoustin/flask-monitor.git
cd flask-monitor
python setup.py install

Usage

::

from flask import Flask, request
from flask_monitor import Monitor , ObserverLog
import logging

app = Flask(__name__)
monitor = Monitor('monitor', __name__)
app.register_blueprint(monitor)
monitor.add_observer(ObserverLog())

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.logger.setLevel(logging.INFO)
    for h in app.logger.handlers:
        h.setLevel(logging.INFO)         
    app.run(port=8080)

You can add a filter of event

::

from flask import Flask, request
from flask_monitor import Monitor , ObserverLog

def filterExt(event):
    return event.response.status_code == 400

app = Flask(__name__)
monitor = Monitor('monitor', __name__)
app.register_blueprint(monitor)
monitor.add_observer(ObserverLog(filter=filterExt))

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run(port=8080)

You can create your own observer

::

from flask import Flask, request
from flask_monitor import Monitor , ObserverLog
 
class myeventlog(ObserverMetrics):

    def __init__(self):
        ObserverMetrics.__init__(self, filter=self.filter)

    def action(self, event):
        logging.getLogger().error(event.json)

    def filter(self, event):
        return event.response.status_code != 400

app = Flask(__name__)
monitor = Monitor('monitor', __name__)
app.register_blueprint(monitor)
monitor.add_observer(myeventlog())

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run(port=8080)

Influxdb

::

pip install influxdb

Usage

::

from flask_monitor.influxdb import ObserverInfluxdb
monitor.add_observer(ObserverInfluxdb(host='127.0.0.1',
                                    port=8086,
                                    user='root',
                                    password='root',
                                    db='mydb'))

RabbitMq

::

pip install pika

Usage

::

from flask_monitor.rabbitmq import ObserverRabbit
import pika

monitor.add_observer(ObserverRabbit(host='127.0.0.1',
                            credentials = pika.PlainCredentials('guest', 'guest')))

ZeroMq

::

pip install zmq

Usage

::

from flask_monitor.zeromq import ObserverZmq
import zmq

monitor.add_observer(ObserverZmq(context=zmq.Context(),
                                    addr='tcp://127.0.0.1:8080'))

Statsd

::

pip install statsd

Usage

::

from flask_monitor.statsd import ObserverStatsd
monitor.add_observer(ObserverStatsd(host='127.0.0.1', port=8125, format="{RequestUrl}"))

V. 0.2.6

  • hotfix Issue#5 manage import influxdb

V. 0.2.5

  • hotfix requirement

V. 0.2.4

  • Add ssl, verify_ssl as options for ObserverInfluxdb

V. 0.2.3

  • correction setup.py by sujaymansingh

V. 0.2.2

  • correction statd by sujaymansingh

V. 0.2.1

  • add logger debug for start end finish request

V. 0.2.0

  • change manage logger of ObserverMetrics

V. 0.1.3

  • hotfix for name pkg

V. 0.1.2

  • manage logger default

V. 0.1.1

  • manage setup.py generic

V. 0.1.0

  • init

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc