Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Get Extra properties from Alert using https://api.opsgenie.com/v2/alerts

Rakesh Panchal April 3, 2024

I am trying to get the "Extra properties" using the Alert API.  How should I construct the params to get all  "Extra properties" associated with alert?

I tried "isExtraPropertiesWithKey=true" but still it did not gave me the "Extra properties" in the Json response.

Postman-screenshot.png

2 answers

0 votes
Rakesh Panchal April 4, 2024

Hi @Nick H 

I tried to pull the individual alert as you mentioned. 

One of the alert I picked has the extra properties in the  alert as shown below

Screenshot 2024-04-04 at 4.46.58 PM.png

 

After getting the response in Postman I searched for the `alerts@splunkcloud.com` in Json body but it did not show it.

Screenshot 2024-04-04 at 4.48.29 PM.png

 

Even there is no details json attribute in the body

Nick H
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 5, 2024

Hi @Rakesh Panchal ,

I can't say for certain those aren't the same alerts, but the top screenshot in Opsgenie shows the alert being a P3, while your Postman screenshot shows the alert being P4 - which leads me to believe those are not the same.

Rakesh Panchal April 5, 2024

Sorry for the confusion @Nick H . Here is the better screenshots

Screenshot 2024-04-05 at 9.57.44 AM.png

Json response

Screenshot 2024-04-05 at 9.58.21 AM.png

Nick H
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 5, 2024

Not sure what parameter you are using in the URL, but can you try running a GET on the tiny ID of that alert to see if you have the same results? Your URL would be:

https://api.opsgenie.com/v2/alerts/87312?identifierType=tiny

This should return the extra properties in the details of the JSON body, and I'm assuming you might be querying on another alert still. For example:

ep4.jpgep5.jpg

Rakesh Panchal April 5, 2024

This worked Thanks a lot !!!

Like Nick H likes this
0 votes
Nick H
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 3, 2024

Hi @Rakesh Panchal ,

If you are running a GET on an individual alert, the extra properties should return in the JSON body without any sort of query needed under the details of the alert:

ep1.jpg

 

If you are trying to run a GET on alerts that contain extra properties, you would need to query on these using the details since this is where the extra properties parse.

Our documentation mentions using details, details.key and/or details.value - but you could also use something like this as well for null queries:

details.key is not null

ep2.jpgep3.jpg

 

After I know the query in the Opsgenie UI, I typically copy / paste it into a URL encoder to ensure I am using the correct parameters in the Alert API.

Rakesh Panchal April 3, 2024

Hi @Nick H 

Thanks for your response.

I am not doing GET on individual Alert. I am getting data based on "updatedAt" between a certain time frame. and in this case I am not getting the details  attribute in the Json response.

Here is the 

https://api.opsgenie.com/v2/alerts?query=updatedAt%3E1709477722%20AND%20updatedAt%3C1712156122&limit=100&offset=0&isExtraPropertiesWithKey=true 

 

Would you please able to guide me what else needs to be passed to get the details (extra properties)?

Nick H
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 3, 2024

I don't believe it's possible to return the extra properties on a List Alert API. There's a sample response in the documentation and not shown in it is the extra properties (aka the details) of the alerts.

So you would need to run an individual GET on each alert to return the extra properties, or create some script that runs a GET on each alert once you have the query needed. Unfortunately I don't have a script to share. 

Rakesh Panchal April 3, 2024

Thanks a lot @Nick H

Like Nick H likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events