Skip to main content

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"

All functinoalities of the InfluxPoint object are listed below:

    import influxobject
    x = influxobject.InfluxPoint()
    x.
        x.add_field(..., ...)
        x.from_json(...)
        x.remove_field(...)
        x.set_measurement(...)
        x.to_line_protocol()
        x.add_tag(..., ...)
        x.remove_tag(...)
        x.set_tags(...)
        x.validate()
        x.parse_line_protocol(...)
        x.set_fields(...)
        x.set_timestamp(...)
        x.to_json()

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/*

Metadata

Release files for influxobject 0.0.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for influxobject 0.0.13
File Size Uploaded Provenance Actions
influxobject-0.0.13.tar.gz 6.6 kB Without provenance Details for influxobject-0.0.13.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for influxobject 0.0.13
File Interpreter ABI Platform Actions
influxobject-0.0.13-py3-none-any.whl Python 3 none any Details for influxobject-0.0.13-py3-none-any.whl

Total release size: 14.2 kB

Release files / influxobject-0.0.13.tar.gz

Download URL influxobject-0.0.13.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
61fe69e18b1b09c6870c27a8f337b066f85214c2cf1685e1a4e33c628dd4a677
BLAKE2b-256 checksum
How to use checksums
2062c5a5e09b6a48ee81a209c7ac4932d0d7688be0b8399d84f248718bb89dd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.12.13 Linux/5.15.154+

Release files / influxobject-0.0.13-py3-none-any.whl

Download URL influxobject-0.0.13-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0e3640bd5bcb1fd34f1a0f030fb219751f7ce97a8cc298b003c9799ef9a35c02
BLAKE2b-256 checksum
How to use checksums
f07d5bf556e785092c6d865e3507b50618601c5706e2e4e84481480f83f25857
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.12.13 Linux/5.15.154+

Security for influxobject 0.0.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page