AppInsights (formerly Leftronic) is an online dashboard service. This article explains how to output query results as data points for dashboard graphs.
- Basic knowledge of ArmTreasure Data, including the toolbelt.
- An AppInsights (formerly Leftronic) account.
A typical use case is to setup a scheduled query in Treasure Data and output the results to a line graph in AppInsights. 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 AppInsights 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. AppInsights' documentation describes how to obtain your accessKey.
Create a new "Line Graph" in AppInsights
Get the "Stream Name" from graph properties
Step 2: Set up a scheduled query. This will execute periodically and send the result to your AppInsights 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())"
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.
- Only support pushing 1 data point per a job