Share

Data Capture

Import Metric Data

API: Import Metric Data


Data is populated into the ServiceView database using agents. An agent is a script, usually running daily on the service infrastructure, collecting the data and then posting it to ServiceView. Agents can be written in any language as long as they are able to perform HTTP requests.

Use the follwoing API to send metric data for a given service:

http://<serviceview_url>/record.php?service=<servicecode>&metric=<metricname>&date=<date>&secret=<secret>&value=<value>&accumulate=0

Parameters

<servicecode>The unique code associated with each service entered from the add or edit service dialog.
<metricname>The name of the metric this data is for.
<date>The date the value applies to in either YYYY-MM-DD or DD-MM-YYYY. For example 31-01-2012. Note: Historic data can be entered by specifying dates in the past.
<secret>The value of the SECRET.
<value>The actual value of the data. For instance 98.7 for 98.7 percent. Note do not include the % symbol or units.
<accumulate>This parameter can be set to keep a running total for this metric rather than sending a total. For instance to record the number of password changes a day include accumulate=1 and submit the URL every time a password is changed. ServiceView will add up the total for the day. If accumulate is not passed or set to 0 each submission will overwrite the previous value.

Returns

SUCCESS or FAILURE

Comments

The HTTP request can either be sent using a HTTP GET or POST request.

The URL to use for each metric can be obtained on the services page under the reports tab. On the right side of each metric are three icons, the first is the URL to inject data.

If the metric or service hasn't been added do that first. See sections on adding services and metrics.

Sample Perl Code

#!/usr/bin/perl 

use LWP::Simple;
use CGI;

$service=<service_code>;

$url = 'http://<serviceview_url>/record.php
	     ?service=' . CGI::escape($service) . 
                        '&metric=' . CGI::escape($metric) .
                        '&date=' .  CGI::escape($date) .
                        '&secret=<secret> .
                        '&value=' . $value;
$result = get($url);
if ($result !~ /SUCCESS/) {
        print "Cannot post to ServiceView: ".$result;
}