tiras 0 Posted October 7, 2016 Share Posted October 7, 2016 Hi I want to POST an critical issue count to my API server. My python script is as follow. import json from urllib import parse, request from config import (USER, PASSWORD, COMPANY) def rpc(action, params): """ Make a call to the LogicMonitor RPC library and return the response Reference: https://www.logicmonitor.com/support/rpc-api-developers-guide/overview/using-logicmonitors-rpc-api/ """ print("Calling action: {action}".format(action=action)) print("Parameters: {params}".format(params=params)) param_str = parse.urlencode(params) creds = parse.urlencode({"c": COMPANY, "u": USER, "p": PASSWORD}) if param_str: param_str = param_str + "&" param_str = param_str + creds try: url = "https://{0}.logicmonitor.com/santaba/rpc/{1}?{2}" f = request.urlopen(url.format(COMPANY, action, param_str)) return f.read() except IOError as ioe: print(ioe) # end try # end rpc def main(): response = rpc("getAlerts", {"level": "critical"}) tmp_text = response.decode("utf-8") instance = json.loads(tmp_text) count = len(instance.get('data').get('alerts')) if __name__ == "__main__": main() I know to do this job in python webserver, but I want to use `LogicMonitor` integration. How can I convert it to `Custom HTTP Delivery`? I have been reading the docs for a while, but it seems not answer exactly what I want at all Hope communities can support me figure out how to finish this job Best regards Sarit Quote Link to post Share on other sites
0 LogicMonitor Staff Sarah Terry 20 Posted October 7, 2016 LogicMonitor Staff Share Posted October 7, 2016 Hi Sarit, It sounds like you're looking to send a count of critical alerts to an external server or application, is that correct? The Custom HTTP Delivery option in LogicMonitor is intended to provide a way to send an HTTP request in response to an alert, and since there isn't an alert to trigger based on here I'm not sure it's the best fit for this scenario. Can you explain a little bit more about what you're trying to accomplish? Thanks, Sarah Quote Link to post Share on other sites
0 tiras 0 Posted October 8, 2016 Author Share Posted October 8, 2016 Thank you Sarah. My customer raises a new issue and would like me an alternative approach I will come back to forum again with new question Thanks Sarit Quote Link to post Share on other sites
Question
tiras 0
Hi
I want to POST an critical issue count to my API server. My python script is as follow.
I know to do this job in python webserver, but I want to use `LogicMonitor` integration.
How can I convert it to `Custom HTTP Delivery`?
I have been reading the docs for a while, but it seems not answer exactly what I want at all
Hope communities can support me figure out how to finish this job
Best regards
Sarit
Link to post
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.