How do I generate notifications for an Athena query timeout?

2 minute read
0

I want to receive an email or SMS notification when my Amazon Athena queries time out.

Short description

Athena uses default timeout limits for queries. If you want to receive a notification for queries that time out and fail, use an Amazon CloudWatch event rule to capture the event. Then, use Amazon Simple Notification Service (Amazon SNS) to set up notifications.

Resolution

Create an SNS topic

To create a standard topic, follow the steps in Creating an Amazon SNS topic. When you create the topic, choose Standard as the type. This lets you choose email or SMS as a subscription protocol in the section Subscribe to the topic. Remember your topic name so that you can add it as the target of a CloudWatch event rule in the following step. For example, name your topic athena-query-timeout.

Create a CloudWatch event rule

  1. To capture the failure event from Amazon EventBridge, create a CloudWatch Events rule.

  2. When you build the event pattern, choose the following options:
    For Event source, choose AWS events or EventBridge partner events.
    For Creation method, choose Custom pattern (JSON editor). Then, enter the following event pattern:

    {
        "source": \["aws.athena"\],
        "detail-type": \["Athena Query State Change"\],
        "detail": {
            "athenaError": {
                "errorMessage": \[{
                    "prefix": "Query timeout"
                }\]
            },
            "currentState": \["FAILED"\]
        }
    }
  3. When you add an AWS service as a target to the event rule, choose SNS topic as your target. Then, select the topic that you previously created. For example, select athena-query-timeout.

Subscribe to the topic

Create a subscription to your SNS topic. Use the same SNS topic that you previously created (for example, athena-query-timeout). For the subscription's Protocol, you can choose email or SMS to receive notifications. After you create the subscription, make sure that you confirm it with the verification link in your email.

AWS OFFICIAL
AWS OFFICIALUpdated 9 months ago