Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

I cant seem to get the api/v6/timeseries data with curl. Can anyone post a snippet to get me going

avatar
Explorer

I cant seem to get the api/v6/timeseries data with curl.  Can anyone post a snippet to get me going

I have been able to get other data from the api, but everytime I try and use timeseries, I just get Http 400 bad request 

 

1 ACCEPTED SOLUTION

avatar
Super Collaborator

Hi ranks,

In Cloudera Manager 5 and higher, every chart you see in the web UI will provide you a direct /timeseries URL showing exactly how that chart itself retrieved metrics with the /timeseries endpoint! You can grab this same URL and use it with curl.

 

Find any chart and click on the blue arrow that will appear at the top-right. Choose "Export JSON". This will open a new window with the location bar already populated. This URL is a fully-formatted /timeseries API endpoint! Feel free to use any of them as a springboard for your curl testing. I tried to post one here but the forum doesn't like the URL and won't let me post. However it'd look like this:

 

Home_-_Cloudera_Manager.png

 

url.png

 

I can use this now directly with my curl command ($curl -v -u $USER:$PASS '$URL') and I get json output as requested.

 

$ curl -v -u $USER:$PASS 'http://my.cluster.com:7180/api/v6/timeseries?query=select+cpu_percent_across_hosts+where+category+%3...

 

Hope this helps! Add -v and/or -i to your curl testing to get more information about the 400 error you're getting, as needed.

--
Mark S.

View solution in original post

2 REPLIES 2

avatar
Super Collaborator

Hi ranks,

In Cloudera Manager 5 and higher, every chart you see in the web UI will provide you a direct /timeseries URL showing exactly how that chart itself retrieved metrics with the /timeseries endpoint! You can grab this same URL and use it with curl.

 

Find any chart and click on the blue arrow that will appear at the top-right. Choose "Export JSON". This will open a new window with the location bar already populated. This URL is a fully-formatted /timeseries API endpoint! Feel free to use any of them as a springboard for your curl testing. I tried to post one here but the forum doesn't like the URL and won't let me post. However it'd look like this:

 

Home_-_Cloudera_Manager.png

 

url.png

 

I can use this now directly with my curl command ($curl -v -u $USER:$PASS '$URL') and I get json output as requested.

 

$ curl -v -u $USER:$PASS 'http://my.cluster.com:7180/api/v6/timeseries?query=select+cpu_percent_across_hosts+where+category+%3...

 

Hope this helps! Add -v and/or -i to your curl testing to get more information about the 400 error you're getting, as needed.

--
Mark S.

avatar
Explorer

Thanks,  I was missing replacing  spaces with + signs in the select statement