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.

 

 

  • The problem here being that I need to be able to gather this information without a collector. UltraDNS is expecting me to be able to pull this information from an API call, which I can do. I want to be able to ingest that information into LM with that call via my API and have LM ingest that data, but it appears that the methods of auth may or may not work between the two end points. 

    Michael, 

    For the payload, the parameter values would be my auth token I'm assuming? They do have an expiry on the initial bearer token but we do have the ability to supply a refresh token that extends beyond the expiry of the initial bearer token. 

  • payload = "username=literal_username&typeId=com.tintri.api.rest.vcommon.dto.rbac.RestApiCredentials&password=literal_pass"


    From your description, I still can't figure out why/how you intend to do this without a collector.

    The com.santaba.agent.groovyapi.http.* classes are provided by LogicMonitor and may be hard to get working outside of the collector.

  • Anonymous's avatar
    Anonymous

    The way you would "ingest" the data is to have that script run on a Collector. If running the collector is a problem, you could always run it in a container in the cloud. 

    There are several advantages to this vs. trying to use the API to ingest the data:

    1) your UltraDNS credentials can be safely stored in LogicMonitor without hard coding them into your script. 

    2) Once you get authenticated to UltraDNS' API, you'd only need to output the data in a specific format, which isn't hard to do.

    The authentication to UltraDNS' API would be the same whether your running it on the Collector or on your laptop or on another server you might be building. As @Michael Rodrigues mentioned, the Santaba http classes won't be easy to get working on another system, so you may as well develop it 

    Once you get it working, you'd:

    1) Add the UltraDNS API as a resource in LogicMonitor. Simply go to your resources page and click Add >> One Device >> Expert. 

    a) Use "api.ultradns.com" as the "IP Address/DNS name"
    b) Give it whatever Name you'd like it to display as. "UltraDNS API" would work fine.
    c) Choose the Collector that will monitor it
    d) Add it into any static group (optional)
    e) Add a property called "system.categories" with a value of "NoPing" (optional, this will disable ping checks on the API)
    f) Add a property called "ultradns.user" with the value of whatever your username is
    g) Add a property called "ultradns.pass" with the value of whatever your password is
    h) Add a proeperty called "ultradns.accountName" with the value of your UltraDNS account name

     

    2) Create the UltraDNS DataSource. Go to Settings >> DataSources and click the Add >> DataSource option

    a) Choose an appropriate Name, Displayed as, Description
    b) Put in the Technical notes information about how this depends on the properties mentioned above existing on the device
    c) In the AppliesTo, put "ultradns.accountName && ultradns.pass && ultradns.user". You could experiment with other expressions, but this one is the simplest.
    d) Choose "Script" for the collector and choose your desired poll rate.
    e) Modify your script, replacing the literal username and password with the hostProp.get() calls you have in the first posted copy of your script. This is what will bring the property values into the script at runtime.
    f) Make sure your script output matches LM's scripted output format.
    g) Paste your script into the "Groovy Script"
    h) For each datapoint of your output, create a datapoint with the corresponding key
    i) You can test your script at this point, but it should work the same as it did on your laptop.

    I'm available to guide you through that process, but using a Collector is the way.

  • Ok so the first issue I have to overcome is that I have to perform a POST for the bearer token to a URL that I can provide via DM. Then once I get that POST response, that is my token (along with my userID, pwd and acct# that I have to pass as part of my GET (or can be in the body of the request, whichever way works best.) If I can get that to work, then the ingest of the data shouldnt be a huge issue. I hope that makes sense. UltraDNS doesn't just have a simple auth process when it comes to their API. I wish it were a simple un/pwd combo, but it's MFA, so they need the bearer token (or in our case ... a refresh Token) to pass to them for auth. 

  • Anonymous's avatar
    Anonymous

    Yeah, looking at their example Python, it looks like you need to post to "/v1/authorization/token" with your username, password, and "grant_type", which should be set to "password". It looks like it returns an access token and a refresh token. So, you'll need to grab the access_token it returns because you'll need it in subsequent calls.

    After that, it looks like you can do a GET with the headers "Accept":"application/json" and "Authorization":"Bearer THE_BEARER_TOKEN_FROM_THE_POST".

    Looks like it's possible they may send back an error even with a 200. If they do, it appears to mean that you need to do another post to /v1/authorization/token using the refresh token, which will give you a new access_token along with a new refresh_token. It's likely this won't ever happen because you will likely be doing a single GET right after obtaining the original access_token, i.e. before it expires. 

  • Can you provide me with an example of how I would need to construct that? Apologies for asking, but I see to be the only one on my team that's ever had to make this kind of request to UltraDNS.