• 0
tiras

Post a crictical issue count to API server

Question

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

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

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

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.