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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

{{triggerDescription}} {{triggerUrl}} parameters via API

Good afternoon Everyone,

I am looking into OG alert API (and perhaps a python wrapper) at https://docs.opsgenie.com/docs/python-sdk-alert, and I cannot find triggerUrl and triggerDescription parameters in the json'ized parameter set. Anyone knows how can I get a handle on these?

Regards

2 answers

1 accepted

1 vote
Answer accepted
Rafael Meira
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Sep 22, 2023

Hey @matvey.teplov 

The `triggerUrl` and `triggerDescription` parameters won't be directly available in the OpsGenie Alert API. However, you can potentially use custom fields to include this information in an alert.

I will send you some suggestions below:

Looking at the OpsGenie Alert API documentation, you can pass extra properties as a dictionary using the `details` parameter when you create an alert. For example, you can do something like this:

```python
from opsgenie.swagger_client import AlertApi, AddAlertRequest, UserRecipient, TeamRecipient
from opsgenie.swagger_client.models import CreateAlertNoteRequest
from opsgenie.swagger_client.rest import ApiException

alert_api = AlertApi()

body = AddAlertRequest(
message="Server CPU Usage High",
alias="Server-1",
description="CPU Utilization has reached 90%",
responders=[
UserRecipient(username="john.doe@your-domain.com"),
TeamRecipient(name="ops_team")
],
actions=["Restart", "AnExampleAction"],
tags=["Overload", "Critical"],
details={
"triggerUrl": "http://example.com/triggerUrl",
"triggerDescription": "This is the trigger description"
},
entity="Server-1",
priority="P1"
)

try:
response = alert_api.create_alert(body=body)
print(response)
except ApiException as err:
print("Exception when calling AlertApi->create_alert: %s\n" % err)
```

In this example, we're using the `details` dictionary to add custom fields for `triggerUrl` and `triggerDescription`. Note that these fields should then be accessible in the alert details on the OpsGenie user interface.

Let me know if the information above was indeed useful.



Best,
Rafa

Hi  Rafa,

 

Yes, the payload can be manipulated like:

 

body = og.CreateAlertPayload(
message='Message from: ' + datetime.datetime.utcnow().isoformat(),
alias=str(uuid.uuid1()),
description='ABCDEF',
responders=[{
'name': 'SampleTeam',
'type': 'team'
}],
visible_to=[
{'name': 'Sample',
'type': 'team'}],
actions=['Restart', 'AnExampleAction'],
tags=['OverwriteQuietHours'],
details={'key1': 'value1',
'key2': 'value2',
'URI': "https://www.google.com",
'received': datetime.datetime.utcnow().isoformat()
},
entity='pack1/' + str(uuid.uuid1()),
priority=alert_priority,
source="Runaway",
note="Blah-blah-bla"
)

 

Thank you for your reply!

Regards Matt

Hi Rafa,

 

Yes, I did about that and it worked successfully. Thank you for replying, though!

 

 

Cheers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events