How to get maximum timestamp per metric

67 views
Skip to first unread message

Andy Flury

unread,
Sep 21, 2015, 2:28:40 PM9/21/15
to OpenTSDB
Hi

Is there a way to retrieve the maximum (last) timestamp for a particular metric and tag(s)?.

I looked at /api/uid/tsmeta which contains the item "lastReceived" but apparently this value holds the time when the last insert happened but not the actual timestamp of the insert.

Background: we would like to store financial tickdata with OpenTSDB. For that we will be retrieving all ticks for a particular day after the markets close. So every day when we run the script, we first need to check the end-date of the current time series in the DB and then download missing tickdata and store it in the DB.

Thanks
Andy Flury

Izak Marais

unread,
Oct 5, 2015, 4:21:11 AM10/5/15
to OpenTSDB
Hi

Sorry, I don't have an answer for you. Can't you just query for the last day's data (up to current time) and see what the last timestamp is? 

Regards
Izak

Kieren Hynd

unread,
Oct 6, 2015, 6:11:12 PM10/6/15
to OpenTSDB
Is http://opentsdb.net/docs/build/html/api_http/query/last.html the kind of thing you're looking for?  It should return the last value and timestamp for the last value.
(the doc mentions two methods of figuring it out - both have associated costs, checkout the "metadata" page for more details on the impact of enabling metadata tracking).

-kieren

Andy Flury

unread,
Oct 8, 2015, 7:37:10 AM10/8/15
to OpenTSDB
Hi Izak

Well, the lasttime stamp might be today but it might also be a year back, we do not know. So querying over a certain time period is suboptimal.

Thanks
Andy

Andy Flury

unread,
Oct 8, 2015, 7:50:03 AM10/8/15
to OpenTSDB
Hi Kiren

Thanks! Yes, that is exactly what I was looking for. (I had noticed the /query/last endpoint before but assumed it would just return the last query issues)

Andy

spico...@gmail.com

unread,
Oct 8, 2015, 11:22:59 AM10/8/15
to OpenTSDB
Hi!
 Can you please tell me how can I get the last and the first record via Java API?
 Thanks.
 Florin 

ankit arora

unread,
Mar 1, 2016, 10:07:33 PM3/1/16
to OpenTSDB
Hi Andy,
I have exactly the same requirement you had. Can you please guide if you have found some resolutions to it.
Reply all
Reply to author
Forward
0 new messages