Adding Data
<?php
$apiKey = 'ACZ1DJFJJ6d5H977cMWALNAW'; // Use the API key as listed for this monitor
$url = 'https://observu.com/api/add';
$source = 'MyCurrentMonitor';
$data = array(
array(
'timestamp' => time(),
'monitor_tags' => array('role' => 'web'),
'data' => array(
'load:float' => 4.52,
'disks.dev_sda.available:bytes' => 523453,
'apache_running:boolean' => true,
)
)
);
$post = array(
'key' => $apiKey,
'source' => $source,
'records' => json_encode($data)
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
$res = curl_exec($ch);
echo '<pre>';
print_r(json_decode($res));
echo '</pre>';
?>
Add A Server (or Custom) Monitor
<?php
$url = 'https://observu.com/api/add-external-monitor';
$username = 'test';
$password = '1234';
$service_name = 'My Servers'; // Grouping together multiple servers
$monname = `hostname`; // use hostname as name for this monitor
$post = array(
'username'=> $username,
'password'=> $password,
'service_name'=> $service_name,
'monitor_name'=> $monname
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
$res = curl_exec($ch);
echo '<pre>';
print_r(json_decode($res));
echo '<pre>';
Retrieve Active Events
Retrieve all active events in the account of user test.
curl -u test:1234 -H 'Accept: application/json' https://observu.com/events?active=1
Example output
{"events":[
{
"id":"2116853",
"name":"High CPU Usage",
"rule_id":"3012",
"monitor_id":"938",
"priority":"2",
"property_name":"cpu.idle",
"property_ids":null,
"info":"0.034123869646818",
"event_timestamp":"1381910185",
"end_timestamp":"0",
"measurement_count":"1",
"sources_count":"1",
"against_measurement_count":"0",
"support":"1",
"ack":null,
"created":"2013-10-16 07:57:34",
"updated":"2013-10-16 07:57:34",
"app_id":null,
"rec_id":null,
"uid":null,
"archive":"0",
"status":null,
"duration":"1",
"monitor":{
"id":"938",
"name":"test.ec2",
"type":"5",
"service_id":"17",
"checker_settings":null,
"created":"2013-07-30 12:32:37",
"updated":"2013-07-30 12:32:37",
"app_id":null,
"rec_id":null,
"uid":"1",
"archive":"0",
"status":"1",
"meta":[],
"service":{
"id":"17",
"name":"Observu",
"type":"3",
"parent_id":null,
"auto_archive":null,
"created":"2011-02-11 11:36:40",
"updated":"2011-02-11 11:36:40",
"app_id":null,
"rec_id":null,
"uid":"1",
"archive":null,
"status":null}
},
"detail_url":"https:\/\/observu.com\/events\/2116853"
},
]
"conditions":
{
"min_duration":0,
"active":true
}
}