A newrelic runner for saltstack has been created to perform tasks like creation and updation of synthetics alerts on newrelic using newrelic APIs from SaltStack. Downlord newrelic.py and put it in salt runners directory and that's it, no need to restart salt-master.
-
Command to convert alert script to required format of synthetic alert
-
Command to update alert notification policy to synthetic alert
salt-run newrelic.synthetics_create <alert_name, required> <alert_frequency, default=15 minutes [number]> <slaThreshold, default = "10.0" [string]) <locations default = [ "AWS_US_WEST_1" ] [list])> <type default="script_browser" [string]>
salt-run newrelic.synthetics_create my_sample_alert
salt-run newrelic.synthetics_update <alert_current_name, required> <updated_name,default = "NA"[string]> <alert_frequency, default="NA" minutes [number]> <slaThreshold, default = "NA" [string]) <locations default = "NA" [list])> <type default="NA" [string]> <status , default = "NA">
To rename alert : salt-run newrelic.synthetics_update "my_sample_alert" "new_name_for_alert"
To change alert frequeny : salt-run newrelic.synthetics_update "new_name_for_alert" frequency=60
To mute notification : salt-run newrelic.synthetics_update "monitor_name" status="MUTED"
To enable notification : salt-run newrelic.synthetics_update "monitor_name" status="ENABLED"
To disable notification : salt-run newrelic.synthetics_update "monitor_name" status="DISABLED"
salt-run newrelic.synthetics_listAll <return_dict default='n'>
Args :
return_dict default = n , to print output in form of table
return_dict default = y , to print output in form of dictionary
salt-run newrelic.synthetics_listAll
salt-run newrelic.synthetics_updateScript <alert_name, required> <path_to_alert_script, required>
To upload/update alert script : salt-run newrelic.synthetics_update_script "my_sample_alert" /tmp/akshay.js
It will format script and save it same file and will convert backup file with orignal content with .bkp extenstion
salt-run newrelic.synthetics_formatScript <path_to_alert_script, required>
To change format : salt-run newrelic.synthetics_formatScript /tmp/akshay.js
It will attached newrelic alert to given notification policy with this function.
salt-run newrelic.synthetics_alertPolicy_add <alert_name, required> <policy_id, required> <action, default="true", [string]> <runbook, default="" [string]>
To rename alert : salt-run newrelic.synthetics_alertPolicy_add "my_sample_alert" 124473
It will update attached newrelic alert to given notification policy and you can enable/disable it with this function.
salt-run newrelic.synthetics_alertPolicy_update <alert_name, required> <policy_id, required> <action, default="true", [string]> <runbook, default="" [string]>
To rename alert : salt-run newrelic.synthetics_alertPolicy_update "my_sample_alert" 124473
It will list newrelic alerts of a given notification policy with this function.
salt-run newrelic.synthetics_alertPolicy_list <policy_id, required>
To rename alert : salt-run newrelic.synthetics_alertPolicy_list 124473