Managing Alert Configurations

To configure alerts you will need a Remote API Key, which is not the same as the API Key you use to send CDR data. The Remote API Key is used for:
  • Adding / Configuring Alerts
  • Adding / Removing sub-API keys to your account
  • General Account Configuration
To obtain a Remote API Key for your account, visit the Settings->Remote API Keys section in the analytics interface.

Add Alerts

URL to post data: http://analytics.humbuglabs.org/index.php/remote_api/api_remote_add_alert/
Parameter Type Description
key string Your remote API Key, MD5 encrypted together with the salt parameter.
salt string A random string used to encrypt your API Key
apikey_ident string The API Key to add the alert to. Alternativly you may use 0 to apply the alert to all your associated API Keys collectivly, or -1 to add the alert for each of your API keys individually.
alert_id int The ID of the alert to add. See the reference table below.
config JSON JSON formatted alert configuration

Sample Alert Configuration POST Request

key=asoiufb9av8h9ahaq9vh98ahvaspdfiouaba8sy7f&salt=1981938447&apikey_ident=asdf08a7gf0asd8f7ga82f8gag98h&alert_id=18&config={"daily_cost":"120","email":"1","sms":"1"}

Response

You will receive a JSON response providing you with the status of the request, for example:
{"result":true,"msg":"OK"}


Remove Alerts

URL to post data: http://analytics.humbuglabs.org/index.php/remote_api/remote_del_alert/
Parameter Type Description
key string Your remote API Key, MD5 encrypted together with the salt parameter.
salt string A random string used to encrypt your API Key
apikey_ident string The API Key to add the alert to. Alternativly you may use 0 to apply the alert to all your associated API Keys collectivly, or -1 to add the alert for each of your API keys individually.
alert_id int The ID of the alert to remove.

Sample API Key Deletion POST Request

key=asoiufb9av8h9ahaq9vh98ahvaspdfiouaba8sy7f&salt=1981938447&apikey_ident=sd89f7hf0as978fg2s9f8h2as8f7gas0

Response

You will receive a JSON response:
{"result":true,"msg":"OK"}

Alert ID & Config Reference

Alert Name ID Sample Configuration
Blacklist 1 Remote Management Coming Soon
Blacklist Country 2 Remote Management Coming Soon
Unidentified Context 3 {"email":"1","sms":"0"}
Config Reload 4 {"email":"1","sms":"0"}
Blacklist Range 5 Remote Management Coming Soon
Premium Number 6 The ID of the alert to remove.
Timestamp 8 {"email":"1","sms":"0"}
Alarm 9 {"email":"1","sms":"0"}
Timerange 10 {"from_mo_hour":"08","from_mo_min":"00","to_mo_hour":"19","to_mo_min":"00", "from_tu_hour":"08","from_tu_min":"00","to_tu_hour":"19","to_tu_min":"00", "from_we_hour":"08","from_we_min":"00","to_we_hour":"19","to_we_min":"00", "from_th_hour":"08","from_th_min":"00","to_th_hour":"19","to_th_min":"00", "from_fr_hour":"08","from_fr_min":"00","to_fr_hour":"17","to_fr_min":"30", "from_sa_hour":"00","from_sa_min":"00","to_sa_hour":"00","to_sa_min":"00", "sa":"on","from_su_hour":"00","from_su_min":"00","to_su_hour":"00", "to_su_min":"00","su":"on","email":"1"}
Blacklist Community 11 {"email":"1","sms":"0"}
Collector Shutdown 12 {"email":"1","sms":"0"}
CDR Duration 13 {"cdr_duration":"6000","cdr_type":"all","email":"1","sms":"0"}
CDR Cost 14 {"cdr_cost":"10","cdr_type":"all","email":"1","sms":"0"}
CDR Cost Per Minute 15 {"cost_per_min":"1","cdr_type":"all","email":"1","sms":"0"}
Threshold - Hourly 47 {"volume_threshold":"120","duration_threshold":"400","cost_threshold":"40","email":"1","sms":"0"}
Threshold - Daily 48 {"volume_threshold":"120","duration_threshold":"400","cost_threshold":"40","email":"1","sms":"0"}
Threshold - Monthly 49 {"volume_threshold":"120","duration_threshold":"400","cost_threshold":"40","email":"1","sms":"0"}
Threshold - Country Hourly 30 Remote Management Coming Soon
Threshold - Country Daily 31 Remote Management Coming Soon
Lond Disance Hourly 32 {"local_country":"64","local_countryname":"Israel","volume_threshold":"5", "duration_threshold":"2","cost_threshold":"2","minimum_asr":"1","minimum_calls":""}
Lond Disance Daily 33 {"local_country":"64","local_countryname":"Israel","volume_threshold":"5", "duration_threshold":"2","cost_threshold":"2","minimum_asr":"1","minimum_calls":""}
Lond Disance Monthly 34 {"local_country":"64","local_countryname":"Israel","volume_threshold":"5", "duration_threshold":"2","cost_threshold":"2","minimum_asr":"1","minimum_calls":""}

Sample Code

PHP, Adding Alerts

								function set_humbug_alert() {
								      //the url we are sending data to
									  $url              = 'http://analytics.humbuglabs.org/index.php/remote_api/api_remote_add_alert/';
									
									  // your Remote API Key
									  $remote_apikey    = 'your-remote-apikey';
									  
									  //Encrypt the API Key using a random string (salt)
									  $salt 		 	= time();
									  $remote_apikey 	= md5($remote_apikey.$salt);
									  
									  //The API Key of the gateway/pbx that we want to add an alert to
									  $gateway_apikey	= 'your-pbx-apikey';
									  
									  //The ID of the alert we want to add. 
									  $alert_id   		= 18;
									  
									  //Sample JSON config for this alert. 
									  //maximum daily cost threshold of $100 and emailing alerts set to ON.
									  $config 			= '{"daily_cost":"100","email":"1"}';
									  
									  //in our example we're building an array of the values we need to send
								      $array = array (
											            'key'           => $remote_apikey,
											            'salt'          => $salt,
														'apikey_ident'  => $gateway_apikey,
											            'alert_id'      => $alert_id,
											            'config'        => $config
											         );
									
									  //turn the array into a key=value string for usage with cURL
									  $params    = "";
								      foreach($array as $key => $value) {
								            $params .= $key.'='.$value.'&';
								      }
								      rtrim($params,'&');
									  
									  //send the data
								      $ch = curl_init();
								      curl_setopt($ch,CURLOPT_URL,$url);
								      curl_setopt($ch,CURLOPT_POST,count($array));
								      curl_setopt($ch,CURLOPT_POSTFIELDS,$params);
								      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
								      $result = curl_exec($ch);
								      curl_close($ch);
									  print_r($result);
								}