Skip to content

drogue-iot/drogue-influxdb-pusher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pushing Cloud Events to InfluxDB

CI GitHub release (latest SemVer) Matrix

Extracts information from JSON based cloud events and pushes them to InfluxDB.

Input

Cloud event:

  • Data Content Type: Mime type of the payload, must be application/json
  • Payload: JSON payload from which to extract values.

Output

There is no output. The result will be written to the configured InfluxDB instance.

Payload

The application expects a JSON payload structure, from which it extracts fields and tags using JSON path expressions.

Configuration

You can use the following environment variables to configure its behavior:

Name Required Default Description
BIND_ADDR 127.0.0.1:8080 The address the HTTP server binds to
RUST_LOG none The configuration of the logger, also see https://docs.rs/env_logger/latest/env_logger/
INFLUXDB_URI x none The URI of the InfluxDB instance to connect to
INFLUXDB_DATABASE x none The name of the InfluxDB database to write to
INFLUXDB_USERNAME none The username used to login in to database instance
INFLUXDB_PASSWORD none The password used to login in to database instance
INFLUXDB_TABLE x none The table to write to
DISABLE_TRY_PARSE false Disable trying to parse expected value from String format

Additionally, you need to configure a set of fields and (optionally) some tags, which make up the write query. Both are configured using environment variables. Fields are prefixed with FIELD_ and tags are prefixed with TAG_.

JSON paths for both fields and tags must result in a single element. Queries which end up with no fields will not be executed.

Fields and tags will be converted to lowercase before writing.

Paths for fields are rooted to the data section of the cloud event. Paths for tags are rooted at the JSON representation of the cloud event.

Examples

The following example defines a field (named temperature), which will take the value from the field temp of the data section of the cloud events:

- name: FIELD_TEMPERATURE
  value: $.temp

For each field, you can also configure the expected type, the default is to try and auto-convert the value:

- name: TYPE_FIELD_TEMPERATURE
  value: float

The types correspond to the InfluxDB types. The following types are available:

none (the default)
Try auto-conversion. For numbers, this will try a float first, then fall back to signed, and then to unsigned integers.
float, number
Floating point value
string, text
Text value
bool, boolean
Boolean value
int, integer
Signed integer value
uint, unsigned
Unsigned integer value

If a value cannot be converted, and error is raised.

The following example defines a tag (named device_id), which will take the value from the cloud events attribute subject:

- name: TAG_DEVICE_ID
  value: $.subject

Building

You can build the container image using:

cargo build --release
docker build . -t drogue-influxdb-pusher