Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

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?

avatar

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

avatar

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

View solution in original post

3 REPLIES 3

avatar

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

avatar

How do I get the memory usage avg.?

avatar

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}]',