Miss any of our Open RFC calls?Watch the recordings here! »

signalk-to-influxdb

1.8.0 • Public • Published

Signal K to InfluxDb Plugin

Signal K Node server plugin to write all simple numeric Signal K values to InfluxDB, a time series database.

Once the data is in InfluxDb you can use for example Grafana to draw pretty graphs of your data.

The plugin assumes that the database you specify exists. You can create one with

curl -X POST http://localhost:8086/query?q=CREATE+DATABASE+boatdata

The plugin writes only self data. It converts Signal K paths to InfluxDb measurement keys in CamelCase format, eg. navigationPosition.

Adding support for non-self data would be pretty easy by adding context as InfluxDB tags.

Position handling and tracks

If enabled by black/whitelist configuration navigation.position updates are written to the db no more frequently than once per second. More frequent updates are simply ignored.

The coordinates are written as [lon, lat] strings for minimal postprocessing in GeoJSON conversion. Optionally, coordinates can be written separately to database. This enable location data to be used in various ways e.g. in Grafana (mapping, functions, ...).

The plugin creates /signalk/vX/api/self/track endpoint that accepts three parameters and returns GeoJSON MultiLineString.

Parameters:

  • timespan: in the format xxxY (e.g. 1h), where xxx is a Number and Y one of:

    • s (seconds)
    • m (minutes)
    • h (hours)
    • d (days)
    • w (weeks)
  • resolution: (in the same format) specifies the time interval between each point returned. For example http://localhost:3000/signalk/v1/api/self/track?timespan=1d&resolution=1h will return the data for the last 1 day (24 hours) with one position per hour. The data is simply sampled with InfluxDB's first() function.

  • timespanOffset: (number) Without timespanOffset defined the end time of the returned data is the current time. Supplying a timespanOffset value changes the end time to be current time - timespanOffset. The timespanOffset value is considered to have the same "Y" as timespan.

Examples: where current time is 14:00

http://localhost:3000/signalk/v1/api/self/track?timespan=12h&resolution=1m returns data in the time window 2:00 - 14:00

http://localhost:3000/signalk/v1/api/self/track?timespan=12h&resolution=1m&timespanOffset=1 returns data in the time window 1:00 - 13:00.

Provider

If you want to import log files to InfluxDb this plugin provides also a provider interface that you can include in your input pipeline. First configure your log playback, then stop the server and insert the following entry in your settings.json:

        {
          "type": "signalk-to-influxdb/provider",
          "options": {
            "host": "localhost",
            "port": 8086,
            "database": "signalk",
            "selfId": <your self id here>,
            "batchSize": 1000
          }
        }

Try it out

You can start a local InfluxDb & Grafana with docker-compose up and then configure the plugin to write to localhost:8086 and then configure Grafana to use InfluxDb data.

Install

npm i signalk-to-influxdb

DownloadsWeekly Downloads

45

Version

1.8.0

License

ISC

Unpacked Size

44.5 kB

Total Files

8

Last publish

Collaborators

  • avatar