Forum Discussion

Jeff_Batchelor's avatar
10 months ago

PowerShell to Get Alerts through API with ticketid

I am trying to utilize the PowerShell cmdlets from PowerShell gallery to pull back alerts from our portal from a specific time windows and include the ##externalticketid## field.

In Python it says to update the queryParams with customColumns=%2523%2523externalticketid%2523%2523 but that does not seem to work in PowerShell.

Has anyone been able to utilize the API to pull back alerts and include the ##externalticketid## field so you can relate it to things like the ServiceNow INC being created for LogicMontior Alerts?

This is using API v2.

  • Hey y’all, so the old V1 documentation does include this still. 

    However, it looks like the v2 and v3 swagger docs have been corrected to remove the “customColumns” being available as a parameter.  This is due to performance impacts that parameter had on the “alert/alerts” api endpoint.  Instead, if you need to pull custom columns you will need to make the API call to “alert/alerts/{ID}” where it is still a valid parameter. 

    https://www.logicmonitor.com/swagger-ui-master/api-v3/dist/#/Alerts/getAlertById 

    The URL encoding does remain the same as what is described in the v1 article:

    %2523%2523externalticketid%2523%2523

  • Anonymous's avatar
    Anonymous

    Use APIv3. v1 and v2 will get cut off at some point and you don’t want to have to rebuild it.

    If you can’t get something to work in powershell, take your code out of the equation by issuing the call in a rest client like postman.

    I tried this in v3 and it doesn’t work, even in postman. This means it’s not a powershell issue, but probably that they changed the way to get at the externalticketid in v2 and v3 of the api and didn’t update their documentation/examples from the v1 stuff. I would recommend you reach out to support. Let them know you attempted the documented solution and what might be wrong with your syntax. When you find out what the issue is, ask them to submit a doc ticket to have the documentation updated (and let us know here).