Ambari Metrics API
The Ambari REST API supports metric queries at CLUSTER, HOST, COMPONENT and HOST COMPONENT levels.
Following is an illustration of an API call that fetches metrics from the Metrics backend service using Ambari API at the aforementioned levels.
CLUSTER
E.g.: Dashboard metrics : Fetch load average across all nodes of a cluster
http://<ambari-server>:8080/api/v1/clusters/<cluster-name>/?fields=metrics/load[1430844925,1430848525,15]&_=1430848532904 |
---|
The above API call retrieves the load average, aggregated across all hosts in the cluster.
The request part of the API call selects the cluster instance while the predicate includes the metric with the time range query.
Time range query:
Field | Value | Comment |
---|---|---|
Start time | 1430844925 | Start time for the time range. (Epoch) |
End time | 1430848525 | End time of the time range. (Epoch) |
Step | 15 | Default step, this is used only for zero padding or null padding if the padding interval cannot be determined from the retrieved data. |
HOST
E.g.: Host metrics: Get the cpu utilization on a particular host in the cluster
http://<ambari-server>:8080/api/v1/clusters/<cluster-name>/hosts/<host-name>?fields=metrics/cpu/cpu_user[1430844610,1430848210,15],metrics/cpu/cpu_wio[1430844610,1430848210,15],metrics/cpu/cpu_nice[1430844610,1430848210,15],metrics/cpu/cpu_aidle[1430844610,1430848210,15],metrics/cpu/cpu_system[1430844610,1430848210,15],metrics/cpu/cpu_idle[1430844610,1430848210,15]&_=1430848217591 |
---|
The above API call retrieves all cpu related metrics required to chart out cpu utilization on a host page.
The request part of the above API call selects the host which is queried while the predicate part includes the metric names with time range query.
COMPONENT
E.g.: Service metrics: Get the IO utilization across all datanodes
HOST COMPONENT
(E.g.: Daemon metrics: Get the heap memory usage for a datanode)