json-to-influxdb-line

WebJar for json-to-influxdb-line

License

License

MIT
Categories

Categories

JSON Data
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

json-to-influxdb-line
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

json-to-influxdb-line
WebJar for json-to-influxdb-line
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/evanshortiss/node-json-to-influx-line

Download json-to-influxdb-line

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/json-to-influxdb-line/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>json-to-influxdb-line</artifactId>
    <version>0.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/json-to-influxdb-line/
implementation 'org.webjars.npm:json-to-influxdb-line:0.2.0'
// https://jarcasting.com/artifacts/org.webjars.npm/json-to-influxdb-line/
implementation ("org.webjars.npm:json-to-influxdb-line:0.2.0")
'org.webjars.npm:json-to-influxdb-line:jar:0.2.0'
<dependency org="org.webjars.npm" name="json-to-influxdb-line" rev="0.2.0">
  <artifact name="json-to-influxdb-line" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='json-to-influxdb-line', version='0.2.0')
)
libraryDependencies += "org.webjars.npm" % "json-to-influxdb-line" % "0.2.0"
[org.webjars.npm/json-to-influxdb-line "0.2.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

JSON to InfluxDB Line Protocol

Module that will convert a JSON Object to the line protocol format for InfluxDB. Will perform any necessary escaping on strings as specified by the protocol. You can read about the InfluxDB line protocol here.

This module does not perform any I/O to InfluxDB. It is just a converter.

This is the initial version and has not been thoroughly tested in real world scenarios, nor performance tested. A suite of unit tests are passing however.

Install

npm i json-influxdb-line

Usage

Any Object you want to convert to a line must be of the format:

{
  measurement: 'name-of-measure',
  // Fields cannot contain sub-objects unless they are stringified
  fields: {
    c: '2',
    d: 3
  },
  // Options. Tags cannot contain sub-objects unless they are stringified
  tags: {
    a: '1',
    b: 2
  },
  // Optional. Any precision can be used (see InfluxDB API)
  ts: Date.now()
}

Streaming

var JsonInfluxDbStream = require('json-influxdb-line').JsonInfluxDbStream;

var jsonToLine = new JsonInfluxDBLineStream();

// Get JSON (stringified objects), convert to line format, write to influxdb
getJsonStream()
  .pipe(jsonToLine)
  .pipe(influxApiStream);

Functional

var convert = require('json-influxdb-line').convert;

// This will create a String with the contents:
// measurement-name,foo=bar value=15 1461108623664
var line = convert({
  // A measurement name
  measurement: 'measurement-name',

  // Optional tags. Nested objects are not supported
  tags: {
    foo: 'bar'
  },

  // Fields. Nested objects are not supported
  fields: {
    value: 15
  },

  // Timestamp - can be omitted
  ts: Date.now()
});

Contributions

All are welcome, just open a Pull Request and add tests where necessary.

Versions

Version
0.2.0