Writing Job Results into Leftronic.

Leftronic is an online dashboard service. This article explains how to output query results as data points for dashboard graphs.

Table of Contents

Prerequisites

Scheduled Queries

A typical use case is to setup a scheduled query in Treasure Data and output the results to a line graph in Leftronic. The resuling time series provides a great at-a-glance performance metric. This can be done in a few simple steps:

Step 1: In the Leftronic dashboard, create a new line graph. Click on the properties for this graph and take note of its streamName. This is a reference name to the graph, which we’ll use in the next steps. Also find out your accessKey. Leftronic’s documentation describes how to obtain your accessKey.

Create a new "Line Graph" in Leftronic

Get the "Stream Name" from graph properties


Step 2: Set up a scheduled query. This will execute periodically and send the result to your Leftronic graph as a data point.

$ td sched:create mymetric_hourly "0 * * * *" \
  -d testdb \
  --result "leftronic://accessKey/streamName" \
  "SELECT TD_SCHEDULED_TIME(), COUNT(1) FROM www_access WHERE TD_TIME_RANGE(time,TD_TIME_ADD(TD_SCHEDULED_TIME(),'-1h'), TD_SCHEDULED_TIME())"

Note that accessKey and streamName are the parameters mentioned in Step 1.

The query result should contain only one row with two columns. The first column should contain a timestamp value in UNIX epoch format. The second column should contain the value associated with each timestamp. In this example, we are counting the number of entries in the www_access table that occured within the past hour.


Last modified: Aug 03 2015 00:01:48 UTC

If this article is incorrect or outdated, or omits critical information, please let us know. For all other issues, please see our support channels.