Struct kairosdb::Client

source ·
pub struct Client { /* private fields */ }
Expand description

The core of the kairosdb client, owns a HTTP connection.

Implementations§

Constructs a new KairosDB Client

Example
use kairosdb::Client;
let client = Client::new("localhost", 8080);

Returns the version string of the KairosDB Server

Example
use kairosdb::Client;
let client = Client::new("localhost", 8080);
assert!(client.version().unwrap().starts_with("KairosDB"));

Returns the health status of the KairosDB Server

Example
use kairosdb::Client;
let client = Client::new("localhost", 8080);
let response = client.health();

Method to add datapoints to the time series database

Example
use kairosdb::Client;
use kairosdb::datapoints::Datapoints;

let client = Client::new("localhost", 8080);
let mut datapoints = Datapoints::new("first", 0);
datapoints.add_ms(1475513259000, 11.0);
datapoints.add_ms(1475513259001, 12.0);
datapoints.add_tag("test", "first");
let result = client.add(&datapoints);
assert!(result.is_ok())

Runs a query on the database.

Example
use kairosdb::Client;
use kairosdb::query::{Query, Time, TimeUnit};

let client = Client::new("localhost", 8080);
let query = Query::new(
   Time::Nanoseconds(1),
   Time::Relative{value: 1, unit: TimeUnit::WEEKS});
let result = client.query(&query);
assert!(result.is_ok())

Runs a delete query on the database. View the query structure to understand more about.

Example
use kairosdb::Client;
use kairosdb::query::{Query, Time, TimeUnit};

let client = Client::new("localhost", 8080);
let query = Query::new(
   Time::Nanoseconds(1),
   Time::Relative{value: 1, unit: TimeUnit::WEEKS});
let result = client.delete(&query);
assert!(result.is_ok())

Returns a list with all metric names

Example
use kairosdb::Client;
let client = Client::new("localhost", 8080);

let result = client.list_metrics();
assert!(result.is_ok());
assert!(result.unwrap().contains(&"first".to_string()));

Deleting a metric

Example
use kairosdb::Client;
let client = Client::new("localhost", 8080);

let result = client.delete_metric(&"first");
assert!(result.is_ok());

Returns a list of all tagnames

Example
use kairosdb::Client;
let client = Client::new("localhost", 8080);

let result = client.tagnames();
assert!(result.is_ok());
assert!(result.unwrap().contains(&"test".to_string()));

Returns a list of all tagvalues

Example
use kairosdb::Client;
let client = Client::new("localhost", 8080);

let result = client.tagvalues();
assert!(result.is_ok());
assert!(result.unwrap().contains(&"first".to_string()));

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.