Popularity
7.7
Stable
Activity
8.6
Growing
189
6
31

Monthly Downloads: 4,212
Programming language: Elixir
License: Apache License 2.0
Latest version: v1.0.0

instream alternatives and similar packages

Based on the "ORM and Datamapping" category.
Alternatively, view instream alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of instream or a related project?

Add another 'ORM and Datamapping' Package

README

Instream

InfluxDB driver for Elixir

InfluxDB Support

Tested InfluxDB versions:

  • 1.7.11
  • 1.8.6
  • 2.0.7

Package Setup

To use Instream with your projects, edit your mix.exs file and add the required dependencies:

defp deps do
  [
    # ...
    {:instream, "~> 1.0"},
    # ...
  ]
end

Testing

To run the tests you need to have HTTP authentication enabled.

The test suite will automatically try to exclude tests not expected to work for your InfluxDB version.

If you have not configured your InfluxDB testing instance to provide an UDP endpoint to the "test_database", you can exclude these tests manually:

mix test --exclude udp

Usage

Connections

To connect to an InfluxDB server you need a connection module:

defmodule MyConnection do
  use Instream.Connection, otp_app: :my_app
end

The :otp_app name and the name of the module can be freely chosen but have to be linked to a corresponding configuration entry. This defined connection module needs to be hooked up into your supervision tree:

children = [
  # ...
  MyConnection,
  # ...
]

Example of the matching configuration entry:

config :my_app, MyConnection,
  database: "my_default_database",
  host: "localhost",
  port: 8086

More details on connections and configuration options can be found with the Instream.Connection module.

Queries

# passing database to query/2
MyConnection.query(
  "SELECT * FROM some_measurement",
  database: "my_database"
)

# defining database in the query
MyConnection.query(~S(
  SELECT * FROM "my_database"."default"."some_measurement"
))

# passing precision (= epoch) for query results
MyConnection.query(
  "SELECT * FROM some_measurement",
  precision: :minutes
)

# using parameter binding
MyConnection.query(
  "SELECT * FROM some_measurement WHERE field = $field_param",
  params: %{field_param: "some_value"}
)

A more detailed documentation on queries (reading/writing/options) is available in the main Instream module documentation.

Series Definitions

If you do not want to define the raw maps for writing data you can pre-define a series for later usage:

defmodule MySeries do
  use Instream.Series

  series do
    measurement "my_measurement"

    tag :bar
    tag :foo

    field :value
  end
end

More information about series definitions can be found in the module documentation of Instream.Series.

Writing Series Points

You can then use this module to assemble a data point (one at a time) for writing:

data = %MySeries{}
data = %{data | fields: %{data.fields | value: 17}}
data = %{data | tags: %{data.tags | bar: "bar", foo: "foo"}}

And then write one or many at once:

MyConnection.write(point)
MyConnection.write([point_1, point_2, point_3])

License

Apache License, Version 2.0


*Note that all licence references and agreements mentioned in the instream README section above are relevant to that project's source code only.