npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wz2b/node-red-influxdb-line-protocol

v0.2.0

Published

Parses InfluxDB Line Protocol to JSON and vice versa.

Downloads

101

Readme

node-red-contrib-influxdb-line-protocol

Parses InfluxDB Line Protocol to JSON and vice versa. There is one node that transfers in both directions: if you provide it an input that is an object, it produces line protocol (a string). If you provide it a string, it parses it as line protocol and emits an object.

What's nice about this format is that it's simple, and it works directly with influxdb, telegraf (via MQTT if you like), or the line protocol input to the cloud grafana.com (which is really prometheus, but has a line protocol compatible input method).

The parser and formatter functions in this node aren't particularily strong. They are rather simple, but they work for all of the original author's use cases. If you encounter any limitations or problems feel free to report a bug via github.

configuration

This node requires no configuration and by default will write all fields as either floats, strings, or booleans depending on the input type. One of the behaviors of influxdb is that you can't switch fields between float and int once the first point has been written. Most people are fine with just writing floats, but there are certain situations where you need to force the type to an integer, including:

  • pre-existing fields in a measurement that are in integer format
  • scientific requirements that numbers be exact
  • need to do comparisons against exact int values without worrying about float/double ULPs
  • specific performance concerns that are helped by data being floats

In these cases, the node configuration allows you to set a default type (which defaults to float) and a list of specific fields that need to be mapped to one type or the other. This is completely optional; if you do nothing, everything will be written to line protocol as a float.

This type mapping mechanism only affects the JSON to line protocol conversion direction. It stems from the fact that there are not really ints in basic javascript, only 'number'.

Rounding

If you specify that a field be transformed to an integer, but the input value has a fractional component, it will be rounded. If someone has the need for this behavior to be selectable (for example Math.ceil() or Math.floor()) please submit an issue.

Example

The following input string in msg.payload:

measurementName,tag1=tagValue1,tag2=tagValue2 field1=42,field2=1337,field3="foobar" 1546300800000000000

Will yield this JSON output in msg.payload:

{
  "measurement": "measurementName",
  "tags": {
    "tag1": "tagValue1",
    "tag2": "tagValue2"
  },
  "fields": {
    "field1": 42,
    "field2": 1337,
    "field3": "foobar"
  },
  "timestamp": 1546300800000
}

It works the other way around, too. Whatever you feed in (string or Object) is parsed or formatted, respectively.

Array operation

If your msg.payload is an array, it will operate on each item independently. That may actually lead to some items being parsed and others being formatted, depending on the previous state. Filter or map your content beforehand, if this is not desired.

Options

You can check the addTimestamp option. In that case, if a point does not contain a timestamp (nanosecond epoch at end in string form, or millisecond epoch timestamp field in JSON object), it will be added with the current time.

This will never override an existing truthy timestamp value. Strip or override it yourself, preferably while your data is in JSON form, if you need such behaviour.

License

MIT