bonitoo-io / influxdb-client-rust

InfluxDB (v2+) Client Library for Rust
MIT License
7 stars 1 forks source link
flux influxdata influxdb rust timeseries

influxdb-client-rust

CircleCI codecov License Latest Version Documentation GitHub issues GitHub pull requests Slack Status

This repository contains the reference Rust client for the InfluxDB 2.0.

Disclaimer: This library is a work in progress and should not be considered production ready yet.

Features

Installation

Add this to your Cargo.toml:

[dependencies]
influxdb_client_rust = "1.0.0-alpha"

Usage

Creating a client

Use influxdb_client_rust::Client::new to create a client connected to a running InfluxDB 2 instance authenticate by token.

use influxdb_client_rust::Client;

let client = Client::new("http://localhost:9999", "my-token");

Client Options

Option Description Type Default
bucket Default destination bucket for writes String none
org Default organization bucket for writes String none
precision Default precision for the unix timestamps within the body line-protocol WritePrecision ns
Configure default Bucket, Organization and Precision
use influxdb_client_rust::Client;
use influxdb_client_rust::generated::models::WritePrecision;

let client = Client::new("http://localhost:9999", "my-token")
    .with_bucket("my-bucket")
    .with_org("my-org")
    .with_precision(WritePrecision::S);

InfluxDB 1.8 API compatibility

Use influxdb_client_rust::Client::new_v1 to create a client connected to InfluxDB 1.8.

use influxdb_client_rust::Client;

let client = Client::new_v1("http://localhost:8086", 
    "my-user", 
    "my-password", 
    "telegraf", 
    "autogen"
);

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/bonitoo-io/influxdb-client-rust.

License

The client is available as open source under the terms of the MIT License.