Skip to content
InfluxDB v2.x crystal-lang client / Flux query language tools
Crystal
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows
spec
src
.gitignore
LICENSE
README.md
shard.yml

README.md

flux

Client library for pushing data to, and querying information from InfluxDB v2.x.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      flux:
        github: aca-labs/flux
  2. Run shards install

Usage

require "flux"

Configure the client

Define your client configuration with Flux.configure. This yields an Options object with appriopriate setters.

Flux.configure do |settings|
  settings.host = ENV["INFLUX_HOST"]? || abort "INFLUX_HOST env var not set"
  settings.api_key = ENV["INFLUX_API_KEY"]? || abort "INFLUX_API_KEY env var not set"
  settings.org = ENV["INFLUX_ORG"]? || "vandelay-industries"
  settings.bucket = ENV["INFLUX_BUCKET"]? || "latex-sales"
end

Writing data

Use Flux.write to enqueue a point. Writes are automatically buffered and flushed after either a time delay or optimal write size.

Running queries

Once information is available in the bucket, queries are executed with Flux.query. This accepts a Flux expression.

Parallel clients

If your application requires connectivity with more that one InfluxDB instance or bucket, clients can be directly created with Flux::Client.new.

Contributing

  1. Fork it (https://github.com/aca-labs/flux/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

You can’t perform that action at this time.