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

INFLUXDB_ENABLED

Set to false to disable InfluxDB support

true

INFLUXDB_INTERVAL

How often to submit measurements to InfluxDB in milliseconds.

5000

INFLUXDB_MAX_BATCH_SIZE

Max # of measurements to submit in a batch

5000

INFLUXDB_MAX_BUFFER_SIZE

Limit of measurements in a buffer before new measurements are discarded.

20000

INFLUXDB_TAG_HOSTNAME

Include the hostname as a tag in the measurement

true

Mixin Configuration

The sprockets_influxdb.InfluxDBMixin class will automatically 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

Project details


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.4.0.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sprockets_influxdb-1.4.0-py2.py3-none-any.whl (10.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file sprockets-influxdb-1.4.0.tar.gz.

File metadata

File hashes

Hashes for sprockets-influxdb-1.4.0.tar.gz
Algorithm Hash digest
SHA256 f82740db4005b6ce43eb6494737604c41cef5600ca3f5c0310bd336e723c1616
MD5 3bae4fdb90739330c2c4e9f3c9629ea1
BLAKE2b-256 ce75862669a77ec10f8104080d940d908bd281778bfe20c0694620d36a4c8458

See more details on using hashes here.

File details

Details for the file sprockets_influxdb-1.4.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for sprockets_influxdb-1.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8d91c4d6fd8d498ee2d9e5b13faff8e32d4dda40522aca39fe75588414332cfa
MD5 26583519324537e62acd1058e0573075
BLAKE2b-256 287c273840b4778e13cd51db0cf5ca08e31f027e8d434645d928b72978659afe

See more details on using hashes here.

Supported by

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