Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Export data to InfluxDB's Line Protocol format

Project Description

# lineprotocol

Export data to InfluxDB's Line Protocol format based on specified input data structure (columns names) and desired output (measurement, fields, tags, timestamp).

Any data going through the exporter is sanitized according to Influx's recommendations:
https://docs.influxdata.com/influxdb/v1.0/write_protocols/line_protocol_tutorial/#data-types
https://docs.influxdata.com/influxdb/v1.0/write_protocols/line_protocol_tutorial/#special-characters-and-keywords

InfluxDB's Line Protocol documentation can be found here:
https://docs.influxdata.com/influxdb/v1.0/write_protocols/


## Usage

from lineprotocol import LineProtocolExporter


input = [
['1', 'foo', 'x', '24', '50.2', 'True'],
['2', 'bar', 'y', '25', '17.0', 'True'],
['3', 'baz', 'z', '26', '100', 'False'],
]


exporter = LineProtocolExporter(
labels=['id', 'name', 'some_letter', 'some_number', 'percentage', 'status'],
measurement='example',
tag_columns=['some_letter'],
field_columns=['id', 'name', 'percentage', 'status'],
field_types=['int', 'str', 'float', 'bool'],
timestamp=1465839830100400200,
)

for line in input:
print exporter.export(line)


# Output:
# example,some_letter=x id=1i,name="foo",percentage=50.2,status=True 1465839830100400200
# example,some_letter=y id=2i,name="bar",percentage=17.0,status=True 1465839830100400200
# example,some_letter=z id=3i,name="baz",percentage=100,status=False 1465839830100400200

## Running tests

$ python -m unittest tests.smoke_test

Release History

This version
History Node

0.1.dev0

Download Files

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

File Name & Hash SHA256 Hash Help Version File Type Upload Date
lineprotocol-0.1.dev0.tar.gz
(4.7 kB) Copy SHA256 Hash SHA256
Source Oct 26, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting