Struct kairosdb::Client
[−]
[src]
pub struct Client { /* fields omitted */ }
The core of the kairosdb client, owns a HTTP connection.
Methods
impl Client
[src]
fn new(host: &str, port: u32) -> Client
Constructs a new KairosDB Client
Example
use kairosdb::Client; let client = Client::new("localhost", 8080);
fn version(&self) -> Result<String, KairoError>
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"));
fn health(&self) -> Result<Vec<String>, KairoError>
Returns the health status of the KairosDB Server
Example
use kairosdb::Client; let client = Client::new("localhost", 8080); let response = client.health();
fn add(&self, datapoints: &Datapoints) -> Result<(), KairoError>
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())
fn query(&self, query: &Query) -> Result<ResultMap, KairoError>
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())
fn delete(&self, query: &Query) -> Result<(), KairoError>
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())
fn list_metrics(&self) -> Result<Vec<String>, KairoError>
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()));
fn delete_metric(&self, metric: &str) -> Result<(), KairoError>
Deleting a metric
Example
use kairosdb::Client; let client = Client::new("localhost", 8080); let result = client.delete_metric(&"first"); assert!(result.is_ok());
fn tagnames(&self) -> Result<Vec<String>, KairoError>
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()));
fn tagvalues(&self) -> Result<Vec<String>, KairoError>
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()));