The trackpanel API

Intro

Use the API to send and display realtime data on one or more spaces. This way you can easily build a custom dashboard showing data from various sources.

You can use this for i.e:

  • Create application backend dashboard, showing important server and application metrics
  • Create a realtime company health display showing the number of new customers and orders for that day.
  • Monitor specific server and application metrics from a central place

Since an space in trackpanel.net is shareable you can also use the custom dashboard in teams and organizations.

Sending metrics

Sending metrics to a space is easy using the space ID and the space API key. You can find the both the ID and API key for on the space settings page.

The space settings are located under the cog icon when logged in and on the space frontpage:

Next you can make a POST call to api.trackpanel.net to the url:

http://api.trackpanel.net/space/<space id>/metric

Include the API key as an custom HTTP header:

apikey: <space api key>

Send the data as application/x-www-form-urlencoded:

test=42&alert=1

Displaying metrics

After sending the data using the API you should be able to add a metric, displaying the data on your trackpanel.

You can add the metrics to a list using the down-arrow button:

Note: refresh your trackpanel if the add metric option isn't visible.

There are al sorts of different ways to display data within trackpanel, you can also add one piece of data multiple times using different displays.

Code examples

Using wget

To send metrics from a batch script or from the command line:

wget -O - http://api.trackpanel.net/space/<space id>/metric --header="apikey:<api key>" --post-data="test=42"

Using python

Embed this code to send metrics directly from your application:

import httplib, urllib

space_id = 1 # Space id
apikey = "space api key"
data = { "test" : 42 }

# Connects to the server:
connection = httplib.HTTPConnection("api.trackpanel.net")

# Post the metrics, sends the api key as HTTP header:
connection.request("POST", "/space/%s/metric" % space_id, urllib.urlencode(data), { 'apikey' : apikey })
                

Using PHP

Embed this code to send metrics directly from your application:

<?
$space_id = 1; /* Space id */
$apikey = "space api key"; /* API key */
$data = array("test" => 42);

$conn = curl_init();
curl_setopt($conn,CURLOPT_URL, sprintf("http://api.trackpanel.net/space/%d/metric", $space_id));
curl_setopt($conn,CURLOPT_HTTPHEADER, array(sprintf("apikey: %s", $apikey)));
curl_setopt($conn,CURLOPT_POST, 1);
curl_setopt($conn,CURLOPT_POSTFIELDS, http_build_query($data));
curl_exec($conn);
curl_close($conn);
?>
                

Notes & limitations

Send frequency

Please do not connect to the API service more than once every 1 minute, sending metrics more often may result in your client being blocked.

Contact us from this page if you need higher update frequency.