Support Questions

Find answers, ask questions, and share your expertise
Announcements
Check out our newest addition to the community, the Cloudera Data Analytics (CDA) group hub.

Ambari Metrics Curl Fails

Explorer

I am trying to post custom metrics to Ambari Metrics Collector. I am using the following command.

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

The output I get from the command is

{"errors":[]}

I can run the following GET command and successfully connect to the ambari metrics service server with a 200 response.

curl -v "http://ams_hostname:6188/ws/v1/timeline/metrics?metricNames=bytes_in._rate._avg&hostname=&appId=HOST&instanceId=&startTime=1451630974&endTime=1519110315"

Any ideas on how to fix the POST command to post custom metrics to Ambari Metrics Collector?

3 REPLIES 3

Super Mentor

@Greg Porter
When you posted the JSON metrics data to AMS ... did you see any Error in the AMS collector log? Can you share the collector log?

Also in your curl call can you add "curl -iLv" flags as well to get more verbose logging.

Super Mentor

@Greg Porter

I see that you never responded to your previous HCC thread on the same kind of requirement.

https://community.hortonworks.com/questions/234795/creating-custom-ambari-metrics.html

Explorer
curl -iLv -H "Content-Type: application/json" -X POST -d '{"metrics": [{"metricname": "AMBARI_METRICS.SmokeTest.FakeMetric", "appid": "amssmoketestfake", "hostname": "hostname", "timestamp": 1432075898000, "starttime": 1432075898000, "metrics": {"1432075898000": 0.963781711428, "1432075899000": 1432075898000}}]}' "http://hostname:6188/ws/v1/timeline/metrics"
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying ip...
* TCP_NODELAY set
* Connected to hostname (ip) port 6188 (#0)
> POST /ws/v1/timeline/metrics HTTP/1.1
> Host: hostname:6188
> User-Agent: curl/7.53.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 288
>
* upload completely sent off: 288 out of 288 bytes
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Cache-Control: no-cache
Cache-Control: no-cache
< Expires: Tue, 05 Feb 2019 03:38:01 GMT
Expires: Tue, 05 Feb 2019 03:38:01 GMT
< Date: Tue, 05 Feb 2019 03:38:01 GMT
Date: Tue, 05 Feb 2019 03:38:01 GMT
< Pragma: no-cache
Pragma: no-cache
< Content-Type: application/json
Content-Type: application/json
< X-Frame-Options: DENY
X-Frame-Options: DENY
< Transfer-Encoding: chunked
Transfer-Encoding: chunked
< Server: Jetty(6.1.26.hwx)
Server: Jetty(6.1.26.hwx)


<
* Connection #0 to host hostname left intact
{"errors":[]}

The ambari-metrics-collector.log doesn't contain any information related to the curl.

2019-02-05 03:37:05,985 INFO TimelineClusterAggregatorSecond: Skipping aggregation for metric patterns : sdisk\_%,boottime
2019-02-05 03:37:07,502 INFO TimelineClusterAggregatorSecond: Saving 5734 metric aggregates.
2019-02-05 03:37:08,018 INFO TimelineClusterAggregatorSecond: End aggregation cycle @ Tue Feb 05 03:37:08 UTC 2019
2019-02-05 03:39:05,984 INFO TimelineClusterAggregatorSecond: Started Timeline aggregator thread @ Tue Feb 05 03:39:05 UTC 2019
2019-02-05 03:39:05,985 INFO TimelineClusterAggregatorSecond: Last Checkpoint read : Tue Feb 05 03:36:00 UTC 2019
2019-02-05 03:39:05,985 INFO TimelineClusterAggregatorSecond: Rounded off checkpoint : Tue Feb 05 03:36:00 UTC 2019
Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.