Struct kairosdb::Client [] [src]

pub struct Client { /* fields omitted */ }

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

Methods

impl Client
[src]

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

impl Debug for Client
[src]

Formats the value using the given formatter.