How to use RQL to query rollbar to group by time period?

671 Views Asked by At

How do I construct an RQL statement that will count errors by, say, day. This gets the number of errors over a seven day period, but how do I count per day?

SELECT count(*)
FROM item_occurrence
WHERE timestamp > unix_timestamp() - 60 * 60 * 24 * 7
LIMIT 1000
2

There are 2 best solutions below

3
Nick Hodges On

Does this get you what you are after?

SELECT item.hash, count(item.id)
FROM item_occurrence
WHERE timestamp > unix_timestamp() - 60 * 60 * 24 * 6
GROUP BY item.id 
ORDER BY item.id desc
1
dbw0011 On

I think the operator you are looking for is the timestamp div X operator. You can use it to bucket the query results if you use it in a group by statement. Try this:

SELECT count(*), timestamp div (60 * 60 * 24)
FROM item_occurrence
WHERE timestamp > unix_timestamp() - 60 * 60 * 24 * 7
GROUP BY 2
ORDER BY 2 asc

The second column will be formatted as an integer, not sure if there's a way to fix it, but that should allow you to see the results grouped into a chosen timeslice.