user2698580
user2698580

Reputation: 47

Live monitoring of container, nodes and cluster

we are using k8s cluster for one of our application, cluster is owned by other team and we dont have full control over there… We are trying to find out metrics around resource utilization (CPU and memory), detail about running containers/pods/nodes etc. Need to find out how many parallel containers are running. Problem is they have exposed monitoring of cluster via Prometheus but with Prometheus we are not getting live data, it does not have info about running containers.

My query is , what is that API which is by default available in k8s cluster and can give all what we need. We dont want to read data form another client like Prometheus or anything else, we want to read metrics directly from cluster so that data is not stale. Any suggestions?

Upvotes: 0

Views: 331

Answers (2)

Chris
Chris

Reputation: 59

to monitoring the resources inside kubernetes without Prometheus, you might consider two options:

  • Using kube-state-metrics for checking kubernetes object state and config
  • Using cAdvisor for resources consumption

In your case cAdvisor can help in collect those information. In addition, cAdvisor provides a REST API that allows users to query and retrieve performance metrics programmatically. This can be particularly useful for custom monitoring and automation.

For example, To retrieve CPU usage metrics for a specific pod using cAdvisor's REST API, you need to make an HTTP request to the appropriate endpoint. Assuming:

  • Your cAdvisor instance is running on http://:/
  • The pod you're interested in has the name my-pod
  • You want to retrieve CPU usage metrics REST API: curl http://:/api/v1.3/containers/docker//stats | jq '.cpu'

In case you want to consider an alternative solution, checkout the 7 Top Kubernetes Monitoring Tools for a list of monitoring tools in Kubernetes.

Upvotes: 0

aurelius
aurelius

Reputation: 3561

As you mentioned you will need metrics-server (or heapster) to get those information. You can confirm if your metrics server is running kubectl top nodes/pods or just by checking if there is a heapster or metrics-server pod present in kube-system namespace.

Also the provided command would be able to show you the information you are looking for. I wont go into details as here you can find a lot of clues and ways of looking at cluster resource usage. You should probably take a look at cadvisor too which should be already present in the cluster. It exposes a web UI which exports live information about all the containers on the machine.

Other than that there are probably commercial ways of acheiving what you are looking for, for example SignalFx and other similar projects - but this will probably require the cluster administrator involvement.

Upvotes: 1

Related Questions