A Client for KairosBD REST API
The Client itself is used as the central access point, from which numerous operations are defined implementing each of the specific KairosDB APIs.
use Client;
let client = new;
A main job of a time series database is collecting and querying data.
To add data to KairosDB we have to create a Datapoints struct and add
the data to the object.
# use Client;
use Datapoints;
# let client = new;
let mut datapoints = new;
datapoints.add_ms;
datapoints.add_ms;
datapoints.add_ms;
datapoints.add_tag;
let result = client.add;
assert!;
To query data we have to create a Query Object with the start and end
of the query. The start and the end can be a relative time. Check the
'Time' structure for more information.
# use Client;
# let client = new;
use HashMap;
use ;
# use Datapoints;
# let mut datapoints = new;
# datapoints.add_ms;
# datapoints.add_ms;
# datapoints.add_ms;
# datapoints.add_tag;
# let result = client.add;
# assert!;
let mut query = new;
let metric = new;
query.add;
let result = client.query.unwrap;
assert!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Optionally you can specify aggregators. Aggregators perform an operation on data points. For example, you can sum all data points that exist in 5 minute periods. Aggregators can be combined together. E.g you could sum all data points in 5 minute periods then calculate the average of them for a week period. Aggregators are processed in the order they are specified in the vector for the metric constructor.
# use Client;
# let client = new;
use *;
use Datapoints;
# let result = client.delete_metric;
# assert!;
for i in 0..10
let mut query = new;
let aggregator = new;
let metric = new;
query.add;
let result = client.query.unwrap;
assert!;
assert_eq!;
assert_eq!;
assert_eq!;
# assert_eq!;
# assert_eq!;
# assert_eq!;
# assert_eq!;
# assert_eq!;
# assert_eq!;
# assert_eq!;
# assert_eq!;
Deleting data is like querying data.
# use Client;
# let client = new;
use ;
let mut query = new;
let mut tags = new;
tags.insert;
let metric = new;
query.add;
let result = client.delete;
assert!;
Getting the current set of metric names is a simple function call.
# use Client;
# let client = new;
# use Datapoints;
# let mut datapoints = new;
# datapoints.add_ms;
# datapoints.add_ms;
# datapoints.add_ms;
# datapoints.add_tag;
# let result = client.add;
# assert!;
let result = client.list_metrics;
assert!;
To get information about the current tags and tag values you can use the tagsnames and tagvalues method.
# use Client;
# let client = new;
# use Datapoints;
# let mut datapoints = new;
# datapoints.add_tag;
# let result = client.add;
# assert!;
let tagnames = client.tagnames;
let tagvalues = client.tagvalues;
assert!;
assert!;
Delete a metric by name
# use Client;
# let client = new;
let result = client.delete_metric;
assert!;
Server status
To get the health status of the KairosDB Server
# use Client;
# let client = new;
let response = client.health;
let result = response.unwrap;
assert_eq!;
assert_eq!;
Get the version of the KairosDB Server