Forum Discussion

Doug_Ancil's avatar
3 years ago

API ingest from UltraDNS into Logic Monitor

I am attempting to ingest data from UltraDNS to create an alarm in LM and have spoken with their support but I am seeming to run into a dead end. I am trying to create an API call into LM that would populate an usage report. I am able to gather that data from UltraDNS but have no idea how to push that data into LogicMonitor. UDNS uses a bearer token for authentication but when I spoke with LM support, they say that only accept basic token authentication. Has anyone created an API call like this or can anyone offer any assistance? If I don't have to reinvent the wheel, I would really rather not have to do so. Thank you in advance.

 

 

  •  

    Stuart,

    What we are attempting to monitor is the amount of DNS queries we receive per month. The output of that report shows us rough numbers, but we start to incur costs after 65 million. We're trying to set up an alert that notifies us when we get to approx 62 million so that will be our threshold. The code I sent above presents me with all kinds of errors when I'm building it though so I'm not sure what I'm missing. If you'd like I can post you a screen shot of the errors I get when I try to test that code in LM.

  • Anonymous's avatar
    Anonymous

    This is great progress. So, now you need to figure out how your data is going to be organized on the LM side. Will you be gathering stats about the resource itself? That might be the case, since you're going to be doing a get request to /reports/dns/usage_summary after getting authenticated. What does that API endpoint return? This will determine if your DataSource will be single instance or multi-instance. Let's look at some examples:

    single instance: ping, RAM utilization, system uptime

    multi-instance: hard disks, network interfaces, CPU cores

    I don't really know what it is that you're trying to monitor, so I can't answer this for you. Once you answer this question, it will determine next steps.

  • Stuart,

    The script that we have is built around groovy, but is just something that is pieced together. 

    // instantiate an http client object for the target system
    ip="api.ultradns.com"
    httpClient = HTTP.open(ip, 443);
    
    user = hostProps.get("ultradns.user");
    pass = hostProps.get("ultradns.pass");
    
    // use an authentication API call to initiate a session
    // specify the url to which we want to post
    url = "https://"+ip+"/authorization/token";
    def payload = '{"username":"myusername","typeId":"com.tintri.api.rest.vcommon.dto.rbac.
        RestApiCredentials","password":"mypassword"}';
     
    // do the post
    def postResponse = httpClient.post(url, payload,["Content-Type":"application/json"]);
    // does the response indicate a successful authentication?
    if ( !(httpClient.getStatusCode() =~ /200/) ) 
    {
        // no -- report an error, and return a non-zero exit code
        println "authentication failure";
        return(1);
    }
    // we are now authenticated. Subsequent GETs with the httpClient will pass in the session cookie 
    url="https://"+ip+"/reports/dns/usage_summary";
    def getResponse=httpClient.get(url);
    // print some data
    println httpClient.getResponseBody();

    With the params ultradns.user and ultradns.pass being values I pass into the script. I can show you what we have written on the postman side that is calling the data from Ultra that works if needed. Again, I apologize for being a novice at this but this is my first time working with an API into LogicMonitor. 

  • Anonymous's avatar
    Anonymous

    Ok, so the first thing I'd do is figure out how to get a script working that will pull the data and output it using print statements. That doesn't have to be groovy, it can be powershell if you're running windows collectors, or it can be any other language (like python) as long as the Collector has that language installed. It's pretty easy to use python scripts on your collector if you're running Linux Collectors. A little trickier on Windows, but not impossible.

    Depending on the type of data you're wanting to fetch, it maybe single instance or multi-instance, script or batch script. All of that is secondary to actually having a script that will fetch the data and print it to the screen.

  • Stuart, that may be the case. I'm fairly new to doing this in LM and was kind of given a quick run thru a few days ago. for the DataSource, as of this writing, all we can do is to ping the URL of where I am needing to pull data from. We found a groovy script to try to run that supposedly will GET the data, but it doesnt seem to work. Not sure exactly what the issue is. 

  • Anonymous's avatar
    Anonymous

    Sounds like a couple things are going on. Let's clarify some stuff:

    1) You have API access to UltraDNS and you may have built a script that pulls that data through the API. Now you're wondering how to get that data into LM?  If so, the answer is DataSource and you wouldn't do anything with the LM API. So, the question about our API token is irrelevant.

    2) You have API access to UltraDNS which has alerts and you may have built a script that pulls those alerts? If so, the answer is an EventSource. Let's tackle these one at a time, because if you get the DataSource working, the EventSource will be easy.