Skip to main content

Influx Object Package

Project description

Influx Point

Description

This module enables the creation of an influx point object that can be transformed into either a JSON or LineProtocol format.

Features

InfluxDB Line Protocol Format

The InfluxDB Line Protocol is a text-based format designed for the efficient writing of time-series data into InfluxDB. It organizes the data points with timestamps, measurement names, fields (key-value pairs representing the data), and tags (optional key-value pairs used to store metadata that describes the data). The format is highly optimized for time-series data, enabling quick parsing and writing. A typical line in this format looks like this:

measurementName,tagKey=tagValue fieldKey="fieldValue" 1465839830100400200

  • measurementName: Identifies the measurement.
  • tagKey=tagValue: Zero or more tag sets separated by commas. Tags are optional but recommended for indexing.
  • fieldKey="fieldValue": At least one field set, with multiple fields separated by commas. Fields are the actual data points.
  • 1465839830100400200: An optional timestamp for the data point. If not specified, the server's current time is used.

JSON Format

The JSON format offers a more flexible way to represent data.

{
    "measurement": "measurement",
    "tags": {"tag1": "value1"},
    "fields": {"field1": 1, "field2": 2},
    "timestamp": 1609455600,
}

Usage

    from influxobject.influxpoint import InfluxPoint

    influx_point = InfluxPoint()
    influx_point.set_measurement("measurement")
    influx_point.set_tags({"tag1": "value1"})
    influx_point.set_fields({"field1": 1, "field2": 2})
    influx_point.set_timestamp(datetime.datetime(2021, 1, 1))\
    
    print(influx_point.to_json())

        # {
        #     "measurement": "measurement",
        #     "tags": {"tag1": "value1"},
        #     "fields": {"field1": 1, "field2": 2},
        #     "timestamp": 1609455600,
        # }
        
    print(influx_point.to_line_protocol())

        # "measurement,tag1=value1 field1=1,field2=2 1609455600"

Installation

To install the package use the pip package manager

    pip install influxobject

Development

Tox is used as the test runner for this project. To run the entire tox suite use the following command:

    tox

To only run the tests under python 3.9

    tox -e py39

Build

    python setup.py sdist

Publish

    twine upload dist/*

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

influxobject-0.0.3.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

influxobject-0.0.3-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file influxobject-0.0.3.tar.gz.

File metadata

  • Download URL: influxobject-0.0.3.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.13

File hashes

Hashes for influxobject-0.0.3.tar.gz
Algorithm Hash digest
SHA256 d01e7eda7d6d6a8dd3032b508ec4f9c6863ed78328bff180112218f373cd3c08
MD5 e62423783deb74694d6147fb20e19ac1
BLAKE2b-256 3df8d3c967d1181e1092c252612d4e1caa78cb8b72cff4fef62ead3b4802ef53

See more details on using hashes here.

File details

Details for the file influxobject-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: influxobject-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.7 Darwin/24.5.0

File hashes

Hashes for influxobject-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 770906af5815caab3db22e8f125a101e42f9705064c474f2ca4303e6ccf747e5
MD5 b1df721163db5c3f8cbbd3644e0863cb
BLAKE2b-256 18ddcdf72f1e59ae86f85c16062dd0aee1ff8bf329b0e6238e3a6d52efd0eaf0

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