Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How do I get information of CPU & memory used by a certain node in the cluster by an API call for certain amount of time?

Solved Go to solution
Highlighted

How do I get information of CPU & memory used by a certain node in the cluster by an API call for certain amount of time?

New Contributor

Say, for last 5 minutes what is the cpu usage for 5 minutes averaged across all nodes in the cluster?

I can see that in Ambari, but I want information in the given time range and I should be able to get that information with an API call.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How do I get information of CPU & memory used by a certain node in the cluster by an API call for certain amount of time?

Hi @naveen r

If you have ambari metrics installed you can do this with REST API. For example;

curl -u admin:admin -H 'X-Requested-By:ambari' -X GET "https//localhost:8080/api/v1/clusters/<your cluster name>/?fields=metrics/load/CPUs._avg[1534230000,1534231500,15]"

Note that ;

CPUs._avg[X,Y,15]

X = start time, Y = end time, 15 = step value used for zero padding or null padding

More examples and official documentation on:

https://cwiki.apache.org/confluence/display/AMBARI/Ambari+Metrics+API+specification

3 REPLIES 3

Re: How do I get information of CPU & memory used by a certain node in the cluster by an API call for certain amount of time?

Hi @naveen r

If you have ambari metrics installed you can do this with REST API. For example;

curl -u admin:admin -H 'X-Requested-By:ambari' -X GET "https//localhost:8080/api/v1/clusters/<your cluster name>/?fields=metrics/load/CPUs._avg[1534230000,1534231500,15]"

Note that ;

CPUs._avg[X,Y,15]

X = start time, Y = end time, 15 = step value used for zero padding or null padding

More examples and official documentation on:

https://cwiki.apache.org/confluence/display/AMBARI/Ambari+Metrics+API+specification

Re: How do I get information of CPU & memory used by a certain node in the cluster by an API call for certain amount of time?

New Contributor

How do I get the memory usage avg.?

Re: How do I get information of CPU & memory used by a certain node in the cluster by an API call for certain amount of time?

There are a variety of options for memory. I just tried the same for my cluster and using for example fields=metrics/memory/Use._avg[1534235091,1534235391,15] worked well.

Further options quoted from the source code;

/clusters/{clusterName}/?fields=metrics/memory/Buffer._avg[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/Cache._avg[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/Share._avg[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/Swap._avg[{fromSeconds},{toSeconds},{stepSeconds}],
metrics/memory/Total._avg[{fromSeconds},{toSeconds},{stepSeconds}], metrics/memory/Use._avg[{fromSeconds},{toSeconds},{stepSeconds}]',
Don't have an account?
Coming from Hortonworks? Activate your account here