An InfluxDB driver that is designed from the ground up to bend, not break under load. In order to accomplish this there were three major design goals:
- Effectively utilize the InfluxDB UDP protocol by making batched writes a part of the library.
- Support the complete Influx line protocol with proper escaping and type support
- Handle load accountably and shed load in a defined FIFO manner when stats cannot be shipped
fast enough:
- prioritize casts over calls
- drop datapoints from the queue, oldest first, when the queue is full and all UDP socket workers are busy.
Full documentation can be found on hexdocs
Now available in Hex, the package can be installed
by adding ex_flux
to your list of dependencies in mix.exs
:
def deps do
[
{:ex_flux, "~> 0.1.0"}
]
end
As explained in the Influx UDP protocol, InfluxDB specifies that a UDP port maps to exactly one configured database. Example configuration for InfluxDB .conf files can be found at the bottom of the Influx udp protocol page
Create an ExFlux.Database
in your project:
defmodule YourApp.YourInfluxDatabase do
use ExFlux.Database, otp_app: :your_app, database: "database_name"
end
Add it to your application.ex
:
children = [
...,
YourApp.YourInfluxDatabase
]
To add points in a series, use ExFlux.Point
s or regular elixir maps interchangeably. A helper for defining series schema is a Near Term TODO.
iex(1)> point = %{measurement: "series_name", fields: %{value: 1}, tags: %{}, timestamp: System.os_time(:nanosecond)}
iex(2)> YourApp.SpecificDatabase.push(point)
The point will be queued asynchronously and either flushed or sent as part of a batch.
- series specification
- timestamp granularity support
- test for load shedding
Copyright 2018 Pylon, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.