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

Not able to retrieve metrics that I just posted on HDP 2.6 sandbox

Rising Star


Trying to play around with ambari metrics on HDP 2.6 sandbox, but still cannot figure out many details...

I'm following this tutorial :

I tried to send a fake_metric by issuing following command :

curl -H "Content-Type: application/json" -X POST -d '{"metrics": 
[{"metricname": "AMBARI_METRICS.SmokeTest.FakeMetric", "appid": 
"amssmoketestfake", "hostname": "ambari20-5.c.pramod-thangali.internal",
 "timestamp": 1432075898000, "starttime": 1432075898000, "metrics": 
{"1432075898000": 0.963781711428, "1432075899000": 1432075898000}}]}'

First, wondering which host/port I should try to target :

I guess host is as I ssh on the sandbox itself (single VM), but which port should I use : the one specified in "timeline.metrics.service.webapp.address" property ?

Anyway, It returns a successfull HTTP 200 code, so I suppose everything went fine.

The question now is "how to check that the metric has been properly received/processed/stored ?"

First, I tried to retrieve it with following command :

curl -vvv -X GET

This returns once again a HTTP 200 status code, and following data : {"metrics":[]}

=> Why doesn't it return what I sent in the first command ?

Then I decided to look at phoenix DB to check its content, but faced another issue : When I tried following command :

./ localhost:61181:/hbase

It simply failed with NPE :


Caused by: java.lang.NullPointerException
  at org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.getMetaReplicaNodes(
  at org.apache.hadoop.hbase.zookeeper.MetaTableLocator.blockUntilAvailable(
  at org.apache.hadoop.hbase.client.ZooKeeperRegistry.getMetaRegionLocation(
  at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.locateMeta(


I tried to figure out once again which port & znode to use :

In ambari configuration, I noticed that :

  • "" property had "{{zookeeper_clientPort}}" value. Not sure about it but I searched for this value in ams-site.xml configuration file and it turned out that "" property had "2181" value.
  • "zookeeper.znode.parent" property had "/ams-hbase-unsecure" value

So, I tried again with following command :

./ localhost:2181:/ams-hbase-unsecure

And still got the same exception...

What's wrong with my configuration ?

Thanks for any help


Super Mentor

@Sebastien Chausson

In your curl command looks like you are using incorrect host name from which yu want to retrieve the Metrics, that you will need to replace with your sandbox "# hostname -f" command output.

# hostname -f 

Notice: amssmoketestfake&hostname=ambari20-5.c.pramod-thangali.internal

You should change the mentioned hostname in both POST & GET requests to your sandbox hostname as following:

"hostname": ""

Also while retrieving metrics from Embedded Mode AMS you should try to use: Login to sandbox using ssh on port 2222


# ssh root@localhost -p 2222

Then try

[root@sandbox ~]# hostname -f

[root@sandbox ~]# 
[root@sandbox ~]# /usr/hdp/


Rising Star

Hi Jay,

Thanks for your help. Second part of your answer was very helpful as it permitted me to check that nothing had been stored in phoenix table. I tried to POST a new metric with correct hostname as you suggested :

curl -H "Content-Type: application/json" -X POST -d '{"metrics": 
[{"metricname": "AMBARI_METRICS.SmokeTest.FakeMetric", "appid": 
"amssmoketestfake", "hostname": "", "timestamp": 
1432075898000, "starttime": 1432075898000, "metrics": {"1432075898000": 
0.963781711428, "1432075899000": 1432075898000}}]}' <a href=""></a>

But again when I tried to retrieve this metrics, following returned empty data :

curl -X GET precision=seconds& startTime=1432075838000&endTime=1432075959000

Is there a way to check on AMS side (log files...?) if it properly received the metric I sent ?

Super Mentor

@Sebastien Chausson

Wow!!! good to know that the initial issue is resolved.

I will need to try the GET part on my own. But looks like the following part if causing the issue here:


Rising Star

oups, copy/paste issue, I updated the GET command above with the exact one I submitted without any success...

Super Mentor

@Sebastien Chausson

Please refer to the following link:

Then try using the following API calls inside your Sandbox Terminal to POST the dummy metrics.

# curl -H "Content-Type: application/json" -X POST -d '{"metrics": [{"metricname": "AMBARI_METRICS.SmokeTest.FakeMetric", "appid": "amssmoketestfake", "hostname": "", "timestamp": 1432075898000, "starttime": 1432075898000, "metrics": {"1432075898000": 0.963781711428, "1432075899000": 1432075898000}}]}' ""


Use the following GET call to fetch the dummy metrics data:

# curl -H "Content-Type: application/json" -X GET ""


Sample Output :

[root@sandbox ~]# curl -H "Content-Type: application/json" -X GET ""



Rising Star

@Jay SenSharma

Hi Jay,

I ran your sample requests successfully, but I'm wondering if this is possible to get all the values of the dummy metric with the REST API. In your example, you post 2 values for your dummy metric but the GET request only returns the latest value. Documentation states that ambari collector only returns latest value if startTime & endTime are not specified in the request, but even by adding thoses 2 parameters, I couldn't get the 2 original values...Any idea ?

Thanks again for your help

Rising Star

@Jay SenSharma

I just gave a try to your suggestion, but still cannot get the same result as you :

1 - POST dummy metric :

curl -H "Content-Type: application/json" -X POST -d '{"metrics": [{"metricname": "AMBARI_METRICS.SmokeTest.FakeMetric", "appid": "amssmoketestfake", "hostname": "", "timestamp": 1432075898000, "starttime": 1432075898000, "metrics": {"1432075898000": 0.963781711428, "1432075899000": 1432075898000}}]}' ""

Output :


2 - GET dummy metrics :

curl -H "Content-Type: application/json" -X GET ""

Output :


Cannot understand why posted metrics don't show up here...

Just a couple of days ago I was using my own blog post to debug a metrics issue on a HDF install and I needed to do two things to get it to work:

- The connect string I needed to use was

./bin/ localhost:61181:/ams-hbase-unsecure

- I needed to use an older version of the phoenix client which I had to find in Apache archives, I can't remember exactly which version, but I want to say I used 4.4 or 4.2... whenever I used the latest ones like 4.10, 4.9. 4.8, I was getting that exception. Even with the older one there was an exception that printed, but it still connected successfully.

Rising Star

Thanks Bryan, You are right about the connection string. Anyway, following @Jay SenSharma suggestion, I used phoenix provided with HDP (in /usr/hdp/ folder) and successfully connected to embedded HBase, no need to download an older version of phoenix.