Forum Discussion

matt_humphreys's avatar
2 years ago

API issue with /alert/alerts/ query

So I have been trying to work with the API to get a list of alerts with various bits of data for inclusion in our internal reporting portals and other systems and according to documentation I should be able to get information like the detailMessage from the full list of alerts as well as custom fields that we have created to return data from our ticketing system from the /alert/alerts return, however this does not appear to be the case:

I have included the structure of the query and the headers below showing version that we are requesting, the query and URL structure and some examples of the returned data
 

Key           Value
---           -----
Authorization LMv1 XXXXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXX
Content-Type  application/json
X-Version     3

URL                         https://XXXXXXX.logicmonitor.com/santaba/rest/alert/alerts?fields=id,sdted,cleared,detailMessage,monitorObjectId,type,monitorObjectName,internalId,acked,severity&size=1000&sort=id&filter=startEpoch>:1675074752

queryString                    fields=id,sdted,cleared,detailMessage,monitorObjectId,type,monitorObjectName,internalId,acked,severity&size=1000&sort=id&filter=startEpoch>:1675074752

Returned data example:

severity          : 2
sdted             : True
monitorObjectName : XXXXXXX-XXX
internalId        :XXXXXXXXXX
monitorObjectId   : 770
id                : XXXXXXXXX
type              : dataSourceAlert
cleared           : False
acked             : False

severity          : 2
sdted             : True
monitorObjectName : XXXXXXX-XXX
internalId        : XXXXXXXXX
monitorObjectId   : 770
id                : XXXXXXXXX
type              : dataSourceAlert
cleared           : False
acked             : False

  • Thats great @Stuart Weenig thank you very much, I have updated my support ticket with the further testing I have done, it also doesnt seem to supply the customColumns information either when you request it which is a shame.

    Again that information comes up just fine when you query a single alert based on the ID just not when you get all the alerts at once as a list.

  • Anonymous's avatar
    Anonymous

    It’s buried a bit deep in the swagger documentation, but you have to include a query parameter called “needMessage” set to a value of “true” to return the detailMessage. However, I just tested it and it doesn’t work. I’d reach out to support for this as the documentation shows that detailMessage should be in the response if needMessage=true is included in the query parameters.

  • I have just tested that “needMessage” part myself and can confirm it doesn't work for me either, the documentation where “needMessage” is mentioned seems to only relate to the v1 API, not sure if it's applicable if you put the request through v3.

    I have been able to get at the information needed by going a step further down the API tree using /alert/alerts/{id}

    Grab a list of ID’s from the /alert/alerts/ and then doing another API query to actually get at the information but it would be better to just get it from /alert/alerts/ if possible.

    I have raised a support ticket so lets see what they have to say.