Support Questions
Find answers, ask questions, and share your expertise

ambari rest api for ambari metrics

ambari rest api for ambari metrics

I am using rest api for getting ambari metrics what AMS displays at ambari Dashboard .

curl -v "http://<metrics_host>:6188/ws/v1/timeline/metrics?metricNames=master.Server.numDeadRegionServers&hostname=&appId=HOST&instanceId=&startTime=1451630974&endTime=1519110315"

but above rest api does not fetch any result.

Please refer below link for all metrics :

https://github.com/apache/ambari/tree/release-2.6.1/ambari-server/src/main/resources/common-services...

1 REPLY 1

Re: ambari rest api for ambari metrics

Super Mentor

@Anurag Mishra

In your Query looks like there is some special character. it works for me:

Example:

# curl -v "http://amb25102.example.com:6188/ws/v1/timeline/metrics?metricNames=master.Server.numDeadRegionServers&hostname=%&appId=hbase&instanceId=&startTime=1451630974&endTime=1519110315"

.

Example Output:

# curl -v "http://amb25102.example.com:6188/ws/v1/timeline/metrics?metricNames=master.Server.numDeadRegionServers&hostname=%&appId=hbase&instanceId=&startTime=1451630974&endTime=1519110315"


*   Trying 172.22.33.44...
* TCP_NODELAY set
* Connected to amb25102.example.com (172.22.33.44) port 6188 (#0)
> GET /ws/v1/timeline/metrics?metricNames=master.Server.numDeadRegionServers&hostname=%&appId=hbase&instanceId=&startTime=1451630974&endTime=1519110315 HTTP/1.1
> Host: amb25102.example.com:6188
> User-Agent: curl/7.54.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Cache-Control: no-cache
< Expires: Fri, 23 Feb 2018 07:19:32 GMT
< Date: Fri, 23 Feb 2018 07:19:32 GMT
< Pragma: no-cache
< Content-Type: application/json
< X-Frame-Options: DENY
< Transfer-Encoding: chunked
< Server: Jetty(6.1.26.hwx)
< 
* Connection #0 to host amb25102.example.com left intact
{"metrics":[{"timestamp":1505865600000,"metadata":{},"metricname":"master.Server.numDeadRegionServers","appid":"hbase","hostname":"amb25104.example.com","starttime":1505865600000,"metrics":{"1505865600000":0.020482476103777878,"1506038400000":0.0,"1506124800000":0.0,"1506211200000":0.0,"1506297600000":0.0,"1506384000000":0.0,"1506470400000":0.0,"1506556800000":0.0,"1506643200000":0.0,"1506729600000":0.0,"1506816000000":0.0,"1506902400000":0.0,"1506988800000":0.0,"1507593600000":0.0,"1507680000000":0.0,"1507766400000":0.0,"1507852800000":0.008484381025838797,"1508803200000":0.0,"1509840000000":0.0,"1509926400000":0.0,"1510012800000":0.0,"1510099200000":0.0,"1510185600000":0.0,"1510272000000":0.0,"1510358400000":0.0,"1510444800000":0.0,"1510531200000":0.0,"1510617600000":0.0,"1510704000000":0.0,"1510790400000":0.0,"1510876800000":0.0,"1510963200000":0.0,"1511049600000":0.0,"1511136000000":0.0,"1511222400000":0.0,"1511308800000":0.0,"1511395200000":0.0,"1511481600000":0.0,"1511568000000":0.0,"1511654400000":0.0,"1511740800000":0.0,"1511827200000":0.0,"1511913600000":0.0,"1512000000000":0.0,"1512086400000":0.0,"1512172800000":0.0,"1512259200000":0.0,"1512345600000":0.0,"1512432000000":0.0,"1512518400000":0.0,"1516060800000":0.0,"1516147200000":0.0,"1516233600000":0.0,"1516838400000":0.0,"1516924800000":0.0,"1517011200000":0.0,"1517097600000":0.0,"1517184000000":0.0,"1517270400000":0.0,"1517356800000":0.0,"1517443200000":0.0,"1517529600000":0.0,"1517616000000":0.0,"1517702400000":0.0,"1517788800000":0.0,"1517875200000":0.0,"1517961600000":0.0,"1518048000000":0.0,"1518134400000":0.0,"1518220800000":0.0,"1518307200000":0.0,"1518393600000":0.0,"1518480000000":0.0,"1518566400000":0.0,"1518652800000":0.0,"1518739200000":0.0,"1518825600000":0.0,"1518912000000":0.0}},{"timestamp":1510876800000,"metadata":{},"metricname":"master.Server.numDeadRegionServers","appid":"hbase","hostname":"amb25103.example.com","starttime":1510876800000,"metrics":{"1510876800000":0.0,"1510963200000":0.0,"1511049600000":0.0,"1511136000000":0.0,"1511222400000":0.0,"1511308800000":0.0,"1511395200000":0.0,"1511481600000":0.0,"1511568000000":0.0,"1511654400000":0.0,"1511740800000":0.0,"1511827200000":0.0,"1511913600000":0.0,"1512000000000":0.0,"1512086400000":1.2683916793505834E-4,"1512172800000":0.0,"1512259200000":0.0,"1512345600000":0.0,"1512432000000":0.0,"1512518400000":0.0,"1512604800000":0.0,"1512691200000":0.0,"1512777600000":0.0,"1512864000000":0.0,"1512950400000":0.0,"1513036800000":0.0,"1513123200000":0.0,"1513209600000":0.0,"1513296000000":0.0,"1513382400000":0.0,"1513468800000":0.0,"1513555200000":0.0,"1513641600000":0.0,"1513728000000":0.0,"1513814400000":0.0,"1513900800000":0.0,"1513987200000":0.0,"1514073600000":0.0,"1514160000000":0.0,"1514246400000":0.0,"1514332800000":0.0,"1514419200000":0.0,"1514505600000":0.0,"1514592000000":0.0,"1514678400000":0.0,"1514764800000":0.0,"1514851200000":0.0,"1514937600000":0.0,"1515024000000":0.0,"1515110400000":0.0,"1515196800000":0.0,"1515283200000":0.0,"1515369600000":0.0,"1515456000000":0.0,"1515542400000":0.0,"1515628800000":0.0,"1515715200000":0.0,"1515801600000":0.0,"1515888000000":0.0,"1515974400000":0.0,"1516060800000":0.0,"1516147200000":0.0,"1516233600000":0.0,"1516838400000":0.0,"1516924800000":0.0,"1517011200000":0.0,"1517097600000":0.0,"1517184000000":0.0,"1517270400000":0.42954650624710783,"1517356800000":1.0,"1517443200000":1.0,"1517529600000":1.0,"1517616000000":1.0,"1517702400000":1.0,"1517788800000":1.0,"1517875200000":1.0,"1517961600000":1.0,"1518048000000":1.0,"1518134400000":1.0,"1518220800000":1.0,"1518307200000":1.0,"1518393600000":1.0,"1518480000000":1.0,"1518566400000":1.0,"1518652800000":1.0,"1518739200000":1.0,"1518825600000":1.0,"1518912000000":1.0,"1518998400000":1.0,"1519084800000":1.0}}]}

.

Also the "appId" should be hbase instead of HOST.