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

signalk-to-influxdb2

v1.9.0

Published

Signal K to InfluxDb 2

Downloads

207

Readme

signalk-to-influxdb2

This is a Signal K Server plugin that writes Signal K data into one or several InfluxDB v2 databases.

This is a total rewrite of signalk-to-influxdb that works with InfluxDB v1.x databases.

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

Main features:

  • writes navigation.position shaped to work with InfluxDB's geo features
  • supports multiple InfluxDb connections

See backlog for planned features and Releases for published features.

For discussions and support visit the Signal K Website.

Details

  • data for Signal K "self" vessel is tagged with tag self with value t

Plugin and InfluxDB Setup

To configure the plugin, you need to have have already installed InfluxDB 2 and created a new bucket and an access token. You can use the operator API token or, if you're security-conscious, create a new token with more restrictive permissions.

Install the plugin using the Signal K Appstore. Remember to restart Signal K to apply the changes.

Go to plugin configuration: Server -> Plugin Config, then scroll down to "Signal K to InfluxDb 2" and expand the section.

The plugin can connect to multiple InfluxDB instances. We will only configure one:

  • Add a new Influx instance by clicking the plus sign
  • Url: http://127.0.0.1:8086
  • Set the token to the one you created earlier
  • Organization: (same as in the InfluxDB config)
  • Bucket: (same as in the InfluxDB config)

If you're mostly interested in your own boat data, select "Store only self data". Leaving that unchecked may result in a lot of data being stored, especially if you are in a busy area.

Set the other configuration options as to your liking. Brief guidance:

  • Ignored paths and sources are important for limiting the amount of data. However, don't set them until you have verified data is being stored in the DB.
  • "Use timestamps from SK data": Usually you want to use the original timestamps, but rewriting the timestamps may result in more efficient DB operations.
  • "Resolution": typically the maximum data frequency on boat networks is 10 Hz. If you set a value of 100 ms or less, you will capture all data, at the cost of a lot of used disk space. A value of 1000 ms is reasonable for real-time observations, and 5000 ms or even 10 000 ms for history logging purposes.
  • "Flush interval" dictates how often data is written to the disk. Use the same value as in "Resolution" as the initial setting.
  • Remaining settings can be safely skipped.

Remember to click "Submit" to save your configuration!

Configuring the Grafana Data Source

While technically not in the scope of this plugin, this section describes how to set up an InfluxDB data source in Grafana. (Another option would be to use the experimental signalk-grafana data data source.) These settings have been tested with InfluxDB 2.7.10, earlier versions may or may not work.

These instuctions configure an InfluxDb datasource using InfluxQL as the query language against InfluxDb version 2. InfluxQL is a good choice as the query language because the Grafana datasource includes a UI for building queries by picking database fields instead of manually writing the raw query.

To begin with you will need to create an API token in InfluxDB.

Login to Grafana. On Signal K installations, Grafana often runs on port 3001: http://mysignalkhostname:3001/

Create the data source:

  • Click on "Add your first data source"
    • Data source type: Influxdb
    • Name: influxdb
    • Query language: InfluxQL
    • HTTP URL: http://localhost:8086

Use the following InfluxDB Details:

  • Database: your bucket name
  • User: your influxdb user
  • Password: your API Token
  • HTTP Method: either GET or POST

Then click "Save & test". You should get a positive acknowledgment. Now, you can create dashboard panels that use InfluxDB as the data source.

History API

The plugin implements the Signal K History API, allowing retrieval of historical data with HTTP GET requests.

Retrieve logged data

To retrieve logged data from the database, send a request to the values endpoint, specifying at least the time interval and SignalK path(s).

http://localhost:3000/signalk/v1/history/values?from=2023-04-23T18:53:20Z&to=2023-04-23T18:55:00Z&paths=environment.wind.speedApparent

The data returned is in SI units, e.g. vessel and wind speeds in meters/s, angles in radian.

For further refinement of the queries, you can use the following request parameters.

Request Parameters

The following request parameters are supported in queries:

  • from / to (mandatory)

    Start and end timestamp, GMT based, e.g. 2023-11-12T21:34:00Z

  • paths (mandatory)

    SignalK paths to retrieve, comma-separated. By default the mean value is returned, but a path can be appended with :min or :max to select the minimum or maximum value.

  • resolution (optional)

    The time interval in seconds between each point returned. For example http://localhost:3000/signalk/v1/history/values?paths=navigation.position&from=2023-11-06T17:30:47Z&to=2023-11-12T21:34:00Z&resolution=60 will return the data with one position per minute. The data is simply sampled with InfluxDB's first() function.

  • format (optional)

    Position data ('navigation.position') can be exported as JSON (default) or in GPX format. Set format=gpx to receive a GPX track.

Examples

Get minimum apparent wind angles:

http://localhost:3000/signalk/v1/history/values?from=2023-04-23T18:51:26Z&to=2023-04-23T19:58:43Z&paths=environment.wind.angleApparent:min

Get wind angle and boat speed:

http://localhost:3000/signalk/v1/history/values?from=2023-04-23T18:53:20Z&to=2023-04-23T18:55:00Z&paths=environment.wind.angleApparent,navigation.speedThroughWater&resolution=60

Get the track with positions at intervals of 5 minutes in GPX format:

http://localhost:3000/signalk/v1/history/values?from=2023-11-04T10:00:00Z&to=2023-11-12T18:00:00Z&paths=navigation.position&resolution=300

List available data paths

To retrieve a list of available paths, send a request to the paths endpoint with from and to timestamps:

http://localhost:3000/signalk/v1/history/paths?from=2023-11-04T00:00:00Z&to=2029-11-25T23:59:59Z

List available contexts

To retrieve a list of available contexts, send a request to the contexts endpoint with from and to timestamps:

http://localhost:3000/signalk/v1/history/contexts?from=2023-11-04T00:00:00Z&to=2029-11-25T23:59:59Z