Create Alert
Create an alert in Opsgenie.
For more information on the API for creating an alert, see Create Alert (opens in a new tab).
SDK Import:
from admyral.actions import create_opsgenie_alert
Arguments:
Argument Name | Description | Required |
---|---|---|
Message message | Message of the alert. Limit: 130 characters | Yes |
Alias alias | Client-defined identifier of the alert, that is also the key element of Alert De-Duplication (opens in a new tab). Limit: 512 characters | - |
Description description | Description field of the alert that is generally used to provide a detailed information about the alert. Limit: 15,000 characters | - |
Responders responders | A JSON array of teams, users, escalations, and schedules that the alert will be routed to send notifications. The following schemas are allowed for the JSON objects: - {"type": "team", "id": "..."} - {"type": "team", "name": "..."} - {"type": "user", "id": ""} - {"type": "user", "username": ""} - {"type": "escalation", "id": ""} - {"type": "escalation", "name": ""} - {"type": "schedule", "id": ""} - {"type": "schedule", "name": ""} Limit: 50 teams, users, escalations, or schedules | - |
Visible To visible_to | A JSON array of teams and users that the alert will become visible to without sending any notification. The following schemas are allowed for the JSON objects: - {"type": "team", "id": "..."} - {"type": "team", "name": "..."} - {"type": "user", "id": ""} - {"type": "user", "username": ""} Note that the alert will be visible to the teams that are specified within Responders field by default, so there is no need to respecify them within the Visible To field. Limit: 50 teams or users in total | - |
Actions actions | A JSON array of custom actions that will be available for the alert. Limit: 10 x 50 characters | - |
Tags tags | A JSON array of tags of the alert. Limit: 20 x 50 characters | - |
Details details | Map of key-value pairs to use as custom properties of the alert. Limit: 8000 characters in total | - |
Entity entity | Entity field of the alert that is generally used to specify which domain alert is related to. Limit: 512 characters | - |
Source source | Source field of the alert. Default value is IP address of the incoming request. Limit: 100 characters | - |
Priority priority | Priority level of the alert. Possible values: P1 , P2 , P3 , P4 , P5 . Default: P3 | - |
User user | Display name of the request owner. Limit: 100 characters | - |
Note note | Additional note that will be added while creating the alert. Limit: 25000 characters | - |
Responders example input:
[
{
"id": "4513b7ea-3b91-438f-b7e4-e3e54af9147c",
"type": "team"
},
{
"name": "NOC",
"type": "team"
},
{
"id": "bb4d9938-c3c2-455d-aaab-727aa701c0d8",
"type": "user"
},
{
"username": "trinity@opsgenie.com",
"type": "user"
},
{
"id": "aee8a0de-c80f-4515-a232-501c0bc9d715",
"type": "escalation"
},
{
"name": "Nightwatch Escalation",
"type": "escalation"
},
{
"id": "80564037-1984-4f38-b98e-8a1f662df552",
"type": "schedule"
},
{
"name": "First Responders Schedule",
"type": "schedule"
}
]
Visible To example input:
{
"visibleTo": [
{
"id": "4513b7ea-3b91-438f-b7e4-e3e54af9147c",
"type": "team"
},
{
"name": "rocket_team",
"type": "team"
},
{
"id": "bb4d9938-c3c2-455d-aaab-727aa701c0d8",
"type": "user"
},
{
"username": "trinity@opsgenie.com",
"type": "user"
}
]
}
Details example input:
{
"property1": "value1",
"property2": "value2"
}
Returns
A JSON object.
Required Secrets
Secret Placeholder | Description |
---|---|
OPSGENIE_SECRET | Opsgenie secret. See Opsgenie setup |
SDK Example
response = create_opsgenie_alert(
message="New case created",
alias="dedup3",
description="A new case was created",
responders=[
{"type": "team", "name": "secops"},
{"type": "user", "username": "daniel@admyral.dev"},
],
visible_to=[
{"type": "team", "name": "secops"},
{"type": "user", "username": "daniel@admyral.dev"},
],
actions=["Create Jira Issue"],
tags=["case", "new"],
details={"key": "value"},
entity="case",
source="admyral",
priority="P5",
user="Me",
note="This is a new case",
secrets={
"OPSGENIE_SECRET": "my_stored_opsgenie_secret"
}
)
Example Output:
{
"data": {
"alias": "8743a1b2-11da-480e-8493-744660987bef",
"action": "Create",
"status": "Created alert",
"alertId": "6d441a86-2667-4408-9eb4-cc195aed22dd-1717680247711",
"success": true,
"isSuccess": true,
"processedAt": "2024-06-10T11:44:42.079Z",
"integrationId": "022d73c8-caba-4eaf-b0f7-4fc438f7274a"
},
"took": 0.003,
"requestId": "a82b9456-e8a6-4d4e-82cd-84d3903eecc9"
}