Create an Alert
Create an alert (event subscription) through the OpenMetadata REST API or Python SDK, including a complete Observability alert that sends test case failures to a webhook.
POST
POST /v1/events/subscriptions
Create an Alert
Create an alert withPOST, or use PUT to create it if it doesn’t exist and update it if it does. With PUT, OpenMetadata matches on name.
The request body is described in the Alerts overview.
Examples
The example creates an Observability alert on the Test Case source. It fires when a test result with statusFailed is posted for any test case under svc.db.schema.orders, and it sends the event to a webhook signed with a hash-based message authentication code (HMAC) secret.
POST /v1/events/subscriptions
Sources, Filters, and Triggers
The valid sources, filters, triggers, and arguments depend on the alert type and source. To list them, see Available Sources, Filters, and Triggers. The table shows the names for each Observability source. For what each one does, see the Alert Behavior Reference.
Argument names and values:
filterByFqntakesfqnList,filterByDomaintakesdomainList,filterByOwnertakesownerNameList, andfilterByTableNameTestCaseBelongsTotakestableNameList.filterByUpdaterIsBottakes no arguments.GetTestCaseStatusUpdatesandGetTestSuiteStatusUpdatestaketestResultListwith valuesSuccess,Failed,Aborted, orQueued.GetTestCaseStatusUpdatesUnderSuitetakestestStatusListandtestSuiteList.GetPipelineStatusUpdatestakespipelineStateListwith valuesSuccessful,Failed,Pending, orSkipped.GetIngestionPipelineStatusUpdatestakesingestionPipelineStateListwith valuesqueued,running,success,partialSuccess,failed, orstopped.
Alert for Incident Events
To receive a webhook when an incident changes status, create aNotification alert on the task source, because incidents are tasks. The task source accepts only the filterByMentionedName filter, so omit input and filter the events in your receiver. Log a few real events from your environment to confirm the payload before you build on it.
Response
Returns the created alert. The response includes these fields:id,fullyQualifiedName, andversionfilteringRules: the filters and triggers as expanded conditionsstatusDetails: an object on each destination
Test a Destination Before You Create the Alert
POST /v1/events/subscriptions/testDestination sends a test message to one or more destinations and returns the result for each. At least one destination is required.