Skip to main content

Buffering InfluxDB client and mixin for Tornado applications

Project description

Buffering InfluxDB client and mixin for Tornado applications

Version Downloads Status Coverage License

Installation

sprockets-influxdb is available on the Python package index and is installable via pip:

pip install sprockets-influxdb

Documentation

Documentation is available at sprockets-influxdb.readthedocs.io.

Configuration

Configuration can be managed by specifying arguments when invoking sprockets_influxdb.install or by using environment variables.

For programmatic configuration, see the sprockets_influxdb.install documentation.

The following table details the environment variable configuration options.

Variable

Definition

Default

INFLUXDB_SCHEME

The URL request scheme for making HTTP requests

https

INFLUXDB_HOST

The InfluxDB server hostname

localhost

INFLUXDB_PORT

The InfluxDB server port

8086

INFLUXDB_USER

The InfluxDB server username

INFLUXDB_PASSWORD

The InfluxDB server password

Mixin Configuration

The sprockets_influxdb.InfluxDBMixin class will automatically tag measurements with the application/service name if the SERVICE environment variable is set. It will also tag the measurement if the ENVIRONMENT environment variable is set with the environment that the application is running in. Finally, if you are using the Sprockets Correlation Mixin, measurements will automatically be tagged with the correlation ID for a request.

Example

In the following example, a measurement is added to the example InfluxDB database with the measurement name of measurement-name. When the ~tornado.ioloop.IOLoop is started, the stop method is invoked, calling ~sprockets_influxdb.shutdown. ~sprockets_influxdb.shutdown ensures that all of the buffered metrics are written before the IOLoop is stopped.

import logging

import sprockets_influxdb as influxdb
from tornado import ioloop

logging.basicConfig(level=logging.INFO)

io_loop = ioloop.IOLoop.current()
influxdb.install(io_loop=io_loop)

measurement = influxdb.Measurement('example', 'measurement-name')
measurement.set_tag('foo', 'bar')
measurement.set_field('baz', 1.05)

influxdb.add_measurement(measurement)

def stop():
    influxdb.shutdown()
    io_loop.stop()

io_loop.add_callback(stop)
io_loop.start()

Requirements

Version History

Available at https://sprockets-influxdb.readthedocs.org/en/latest/history.html

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sprockets-influxdb-1.2.0.tar.gz (15.6 kB view hashes)

Uploaded Source

Built Distribution

sprockets_influxdb-1.2.0-py2.py3-none-any.whl (9.8 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page