Search in sources :

Example 1 with ContainerMetrics

use of io.kubernetes.client.custom.ContainerMetrics in project java by kubernetes-client.

the class MetricsExample method main.

public static void main(String[] args) throws IOException, ApiException {
    ApiClient client = Config.defaultClient();
    Configuration.setDefaultApiClient(client);
    Metrics metrics = new Metrics(client);
    NodeMetricsList list = metrics.getNodeMetrics();
    for (NodeMetrics item : list.getItems()) {
        System.out.println(item.getMetadata().getName());
        System.out.println("------------------------------");
        for (String key : item.getUsage().keySet()) {
            System.out.println("\t" + key);
            System.out.println("\t" + item.getUsage().get(key));
        }
        System.out.println();
    }
    for (PodMetrics item : metrics.getPodMetrics("default").getItems()) {
        System.out.println(item.getMetadata().getName());
        System.out.println("------------------------------");
        if (item.getContainers() == null) {
            continue;
        }
        for (ContainerMetrics container : item.getContainers()) {
            System.out.println(container.getName());
            System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
            for (String key : container.getUsage().keySet()) {
                System.out.println("\t" + key);
                System.out.println("\t" + container.getUsage().get(key));
            }
            System.out.println();
        }
    }
}
Also used : Metrics(io.kubernetes.client.Metrics) PodMetrics(io.kubernetes.client.custom.PodMetrics) NodeMetrics(io.kubernetes.client.custom.NodeMetrics) ContainerMetrics(io.kubernetes.client.custom.ContainerMetrics) NodeMetricsList(io.kubernetes.client.custom.NodeMetricsList) NodeMetrics(io.kubernetes.client.custom.NodeMetrics) PodMetrics(io.kubernetes.client.custom.PodMetrics) ApiClient(io.kubernetes.client.openapi.ApiClient) ContainerMetrics(io.kubernetes.client.custom.ContainerMetrics)

Aggregations

Metrics (io.kubernetes.client.Metrics)1 ContainerMetrics (io.kubernetes.client.custom.ContainerMetrics)1 NodeMetrics (io.kubernetes.client.custom.NodeMetrics)1 NodeMetricsList (io.kubernetes.client.custom.NodeMetricsList)1 PodMetrics (io.kubernetes.client.custom.PodMetrics)1 ApiClient (io.kubernetes.client.openapi.ApiClient)1