This page describes how to set up alerts for failed job executions of a Dataplex task.
To set up alerts, you can use the Logs Explorer in the Google Cloud console or the Monitoring API.
Terminology
- Incident autoclose duration: The duration after which an incident closes when there are no matching log entries..
- Time between notifications: Minimum amount of time between receiving notifications for logs that match a filter. Any matching log within the minimum amount of time are skipped. The minimum time you can set is 5 minutes.
Set up notifications using Logs Explorer
In the Google Cloud console, go to the Logs Explorer page.
Click the Show query toggle.
To set up an alert for a failed job execution of any Dataplex task in a project, type the following query:
severity=ERROR resource.type = "dataplex.googleapis.com/Task" logName = "projects/PROJECT_NAME/logs/dataplex.googleapis.com%2Fprocess" jsonPayload.state = "FAILED"
To set up an alert for a failed job execution for a specific Dataplex task in a project, type the following query:
severity=ERROR resource.type = "dataplex.googleapis.com/Task" resource.labels.task_id = TASK_ID logName = "projects/PROJECT_NAME/logs/dataplex.googleapis.com%2Fprocess" jsonPayload.state = "FAILED"
Click Create alert.
In the Alert Policy Name field, enter a name for the new alert.
In the Documentation field, enter the description you want to include in the notification. For more information about the content you can include in the documentation field of an alerting policy, see Using Markdown and variables in documentation templates.
Click Next.
Choose the logs you want to include in the alert, and click Next.
Set the Time between notifications and the Incident autoclose duration, and click Next.
Optional: Select a notification channel. For more information about configuring notification channels using the Google Cloud console, see Manage notification channels.
Click Save.
Set up notifications using Monitoring API
- Optional: Enable the Monitoring API and authorize users to access it. For more information, see Enable the Monitoring API.
- Optional: Set the roles or permissions needed to create an alerting policy. For more information, see Authorization required to create alerting policies.
- Create a notification channel by either using Google Cloud console or Google Cloud CLI.
Get the
channel_id
:gcloud beta monitoring channels list
Create a
policy.json
file with the following content for log-based-alerting-policy:Set up an alert for a failed job execution of any Dataplex task in a project:
{ "displayName": "Alert Using Monitoring API", "documentation": { "content": "Log-based alert in project PROJECT.", "mimeType": "text/markdown" }, "conditions": [ { "displayName": "Log match condition: Failed Job Execution", "conditionMatchedLog": { "filter": "severity=\"ERROR\" resource.type = \"dataplex.googleapis.com/Task\" logName = \"projects/PROJECT_ID/logs/dataplex.googleapis.com%2Fprocess\" jsonPayload.state = \"FAILED\"", }, } ], "combiner": "OR", "alertStrategy": { "notificationRateLimit": { "period": "300s" }, "autoClose": "604800s", }, "notificationChannels": [ "projects/PROJECT_ID/notificationChannels/CHANNEL_ID" ] }
Set up an alert for a failed job execution for a specific Dataplex task in a project:
{ "displayName": "Alert Using Monitoring API", "documentation": { "content": "Log-based alert in project PROJECT.", "mimeType": "text/markdown" }, "conditions": [ { "displayName": "Log match condition: Failed Job Execution", "conditionMatchedLog": { "filter": "severity=\"ERROR\" resource.type = \"dataplex.googleapis.com/Task\" logName = \"projects/PROJECT_ID/logs/dataplex.googleapis.com%2Fprocess\" jsonPayload.state = \"FAILED\" resource.labels.task_id = \"TASK_ID\"", }, } ], "combiner": "OR", "alertStrategy": { "notificationRateLimit": { "period": "300s" }, "autoClose": "604800s", }, "notificationChannels": [ "projects/PROJECT_ID/notificationChannels/CHANNEL_ID" ] }
Pass the
policy.json
file to thegcloud
CLI:gcloud alpha monitoring policies create --policy-from-file="policy.json"
If successful, the command returns the resource name of the new policy. For example:
Created alert policy [projects/PROJECT_ID/alertPolicies/*POLICY_ID*].
What's next
- Learn more about Cloud Logging.
- Learn about monitoring Dataplex metrics.