2 releases

Uses old Rust 2015

0.1.1 May 14, 2016
0.1.0 Mar 29, 2016

#20 in #metrics-collection

MIT license

16KB
380 lines

bklyn

Build Status Software License

collect artisanal kubernetes cluster metrics from rust

Bklyn is a rust interface querying heapster.

api docs

Find them here

usage

Bklyn relies on the kubernetes heapster API to query cluster metrics. In order to do so, you will need your cluster username and password as well as a url for heapster. You can resolve this url using kubectl

After authenticating with a kubeternetes cluster, run the following

$ kubectl cluster-info

Inspect the output for the Heapster url.

With those items on hand, you should be on your way with bklyn

extern crate bklyn;
extern crate hyper;

use bklyn::{Credentials, Heapster};
use hyper::Client;
use std::env;

fn main() {
    if let (Ok(baseurl), Ok(user), Ok(password)) = (
        env::var("HEAPSTER_BASEURL"),
        env::var("HEAPSTER_USER"),
        env::var("HEAPSTER_PASSWORD")
    ) {
        let client = Client::new();
        let heapster = Heapster::new(
            baseurl,
            &client,
            Credentials::Basic(
                user,
                password
            )
        );
        if let Ok(names) = heapster.cluster().metrics().names() {
            for metric in names {
                println!(
                    "{:#?} metrics {:#?}",
                    metric,
                    heapster.cluster().metrics().values(metric.clone(), &Default::default())
                );
            }
        }

    }
}

Doug Tangren (softprops) 2016

Dependencies

~6.5MB
~147K SLoC