-
-
Save serhatcan/47f68e6b84fb4c3785a74f1e104bfb58 to your computer and use it in GitHub Desktop.
create opsgenie alerts using a waterfall model with delay in between
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var opsgenie = require("opsgenie-sdk"); | |
opsgenie.configure({ | |
'api_key': '0d3deae3-a362-4c79-b485-dfd1ad56947c', | |
'host': "http://127.0.0.1:9000" | |
}); | |
function waterfall(func, timeout, iterations, index){ | |
console.log(index); | |
if(index == iterations){ | |
process.exit(1); | |
return; | |
} | |
setTimeout(function(){ | |
func(); | |
waterfall(func, timeout, iterations, index+1); | |
}, timeout); | |
} | |
var createAlert = function(){ | |
var create_alert_json = { | |
"message": "Test alert"+"_"+(new Date()).getTime() | |
}; | |
console.log("alert will be created ", create_alert_json); | |
opsgenie.alert.create(create_alert_json, function (error, alert) { | |
if (error) { | |
console.log(error); | |
} else { | |
console.log("alert created"); | |
} | |
}); | |
} | |
waterfall(createAlert, 50, 5000, 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment