Loggr Query Language

So your posting all your valuable event data to Loggr. Your data is safe and accessible through our tools, but you own your data and we know how important it is to have full control and access to it. Whether you want to integrate it into other business applications, perform deeper analysis, archive it or simply move it to a different service, we make it pretty easy to do.

One of the tools we provide for digging through your events is a custom query language. We call it the Loggr Query Language (or LQL). It’s a very simple language similar to SQL that can be used in our API or within the query editor on the website.

sss

Note

We will be providing more documentation on using the query language. We just wanted to introduce it, show the syntax for it and provide a couple examples.


You can also run queries through the Loggr Web API using the Query endpoint.

The query syntax is:

sss

Some examples. First, to get the text from the last 5 events added to your log.

GET events TAKE 5 SORT created DESC OCCURS(TODAY) COLUMNS(text)

This next example uses a WHERE clause to get the last 5 events that have text matching ‘New subscriber’ exactly.

GET events WHERE text='New subscriber' TAKE 5 SORT created DESC
OCCURS(TODAY) COLUMNS(text)

Using the same query above, but replace the exact match on text with a regex match clause LIKE. Also, this time we’re going to return just the KEY for the event which we can use to call into the API for more specifics about the event.

GET events WHERE text LIKE '(D|d)ave' TAKE 5 SORT created DESC
OCCURS(TODAY) COLUMNS(key)

The following queries based on a set of tags. It also return the created date and geo info for each event.

GET events WHERE tags=('user','created') TAKE 5 SORT created DESC
OCCURS(TODAY) COLUMNS(text, created, geo)

You can also include boolean operators in the WHERE clause.

GET events WHERE tags=('error') OR tags=('failed') TAKE 5
SORT created DESC OCCURS(TODAY) COLUMNS(text)

Finally a more complex example showing how you can query for aggregate information and specify time ranges. This query gets the sum of all events of class ‘order’ having the tag ‘online’. It uses the OCCURS clause to get the aggregates over the last 7 days. It will return the results as a list of 7 records for each day in the query. Each record will contain the KEY (in this case, the date) and the SUM.

GET events.order WHERE tags=('online') GROUPBY DAY
OCCURS(TODAY - DAYS(7), TODAY) COLUMNS(KEY,SUM)

If you want to get specific dates, you can include them in the OCCURS clause instead of the keywords shown above.

GET events OCCURS('4/22/2011 12:00am', '4/22/2011 12:00pm')
COLUMNS(text)