The Ambari REST API supports metric queries at CLUSTER, HOST, COMPONENT and HOST COMPONENT levels.
Broadly, the types of metrics queries supported are: time range or point in time.
Following is an illustration of an API call that fetches metrics from the Metrics backend service using Ambari API.
E.g.: Dashboard metrics : Fetch load average across all nodes of a cluster
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, followed by current time in milliseconds.
Time range query:
|Start time||Start time for the time range. (Epoch)|
|End time||End time of the time range. (Epoch)|
|Step||Default step, this is used only for zero padding or null padding if the padding interval cannot be determined from the retrieved data.|
E.g.: Host metrics: Get the cpu utilization on a particular host in the cluster
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.
E.g.: Service metrics: Get the capacity utilization metrics aggregated across all datanodes but only the latest value (point in time)
The above API call retrieves two metrics values which represent the point in time metric value for the requested metrics obtained for the Metrics Service backend. (non JMX)
For a call to get JMX metrics directly from a Hadoop daemon, use the metrics name that corresponds to the JMX MBean metric, example: metrics/dfs/FSNamesystem/CapacityUsedGB (Refer to Stack Defined Metrics for more info)
The request part of the above API call selects the service from the cluster while predicate part includes the metrics names.
E.g.: Daemon metrics: Get the heap memory usage for active Namenode
The above API call retrieves JVM heap metrics for the Active Namenode in the cluster.
The request part of the api selects the Namenode host component while predicate part includes metrics with time range query.