time ordered list of datapoints

28 views
Skip to first unread message

Berco Beute

unread,
Mar 29, 2010, 6:10:17 PM3/29/10
to boto-users
querying a metric for a specific period retuns a list of datapoints,
but that list is unordered. For instance the following query on an ELB
instance:

metric.query(start, end, 'Sum', 'Count/Second')

This is problematic since ordering it by time requires you to order
the datapoints by their 'Timestamp' key (which is a string that is
hard to convert to a datetime instance, it is neither recognized by
datetime or time). Why is the list unordered? Could it be ordered?

Mitchell Garnaat

unread,
Mar 29, 2010, 7:04:12 PM3/29/10
to boto-...@googlegroups.com
The list of datapoints are in the order returned by the CloudWatch service.  I don't see any documentation from AWS that makes any statements or guarantees about the order of results.  That would probably be a good question to pose on the EC2 forum.

It should be easy to sort the list.  The timestamps are ISO8601 strings so they can be compared lexicographically.  I think something like this (untested) should work.  Assume that rs is the list of datapoints returned:

rs.sort(cmp=lambda x, y: cmp(x['Timestamp'], y['Timestamp']))

Mitch


--
You received this message because you are subscribed to the Google Groups "boto-users" group.
To post to this group, send email to boto-...@googlegroups.com.
To unsubscribe from this group, send email to boto-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/boto-users?hl=en.


Reply all
Reply to author
Forward
0 new messages