Search in sources :

Example 1 with Metric

use of org.openkilda.messaging.model.Metric in project open-kilda by telstra.

the class StatisticsBasicTest method getNumberOfDatapoints.

private List<Metric> getNumberOfDatapoints() throws Throwable {
    System.out.println("\n==> OpenTSDB Metrics request");
    long current = System.currentTimeMillis();
    Client client = ClientBuilder.newClient(new ClientConfig());
    Response response = client.target(opentsdbEndpoint).path("/api/query").queryParam("start", "24h-ago").queryParam("m", "sum:pen.switch.tx-bytes").queryParam("timezone", "Australia/Melbourne").request().get();
    System.out.println(String.format("===> Response = %s", response));
    System.out.println(String.format("===> OpenTSDB Metrics Time: %,.3f", getTimeDuration(current)));
    List<Metric> metrics = new ObjectMapper().readValue(response.readEntity(String.class), new TypeReference<List<Metric>>() {
    });
    System.out.println(String.format("====> Metrics = %s", metrics));
    return metrics;
}
Also used : Response(javax.ws.rs.core.Response) Metric(org.openkilda.messaging.model.Metric) List(java.util.List) Client(javax.ws.rs.client.Client) ClientConfig(org.glassfish.jersey.client.ClientConfig) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 List (java.util.List)1 Client (javax.ws.rs.client.Client)1 Response (javax.ws.rs.core.Response)1 ClientConfig (org.glassfish.jersey.client.ClientConfig)1 Metric (org.openkilda.messaging.model.Metric)1