Amazon SNS message delivery status
Amazon SNS provides support to log the delivery status of notification messages sent to topics with the following Amazon SNS endpoints:
-
HTTP
-
Amazon Data Firehose
-
AWS Lambda
-
Platform application endpoint
-
Amazon Simple Queue Service
After you configure the message delivery status attributes, log entries are sent to CloudWatch Logs for messages sent to topic subscribers. Logging message delivery status helps provide better operational insight, such as the following:
-
Knowing whether a message was delivered to the Amazon SNS endpoint.
-
Identifying the response sent from the Amazon SNS endpoint to Amazon SNS.
-
Determining the message dwell time (the time between the publish timestamp and just before handing off to an Amazon SNS endpoint).
To configure topic attributes for message delivery status, you can use the AWS Management Console, AWS software development kits (SDKs), query API, or AWS CloudFormation.
Topics
Configuring delivery status logging using the AWS Management Console
Sign in to the Amazon SNS console
. -
On the navigation panel, choose Topics.
-
On the Topics page, choose a topic and then choose Edit.
-
On the Edit
MyTopic
page, expand the Delivery status logging section. -
Choose the protocol for which you want to log delivery status; for example AWS Lambda.
-
Enter the Success sample rate (the percentage of successful messages for which you want to receive CloudWatch Logs.
-
In the IAM roles section, do one of the following:
-
To choose an existing service role from your account, choose Use existing service role and then specify IAM roles for successful and failed deliveries.
-
To create a new service role in your account, choose Create new service role, choose Create new roles to define the IAM roles for successful and failed deliveries in the IAM console.
To give Amazon SNS write access to use CloudWatch Logs on your behalf, choose Allow.
-
-
Choose Save changes.
You can now view and parse the CloudWatch Logs containing the message delivery status. For more information about using CloudWatch, see the CloudWatch Documentation
.
Configuring delivery status logging using the AWS SDKs
The AWS SDKs provide APIs in several languages for using message delivery status attributes with Amazon SNS.
Topic attributes
You can use the following topic attribute name values for message delivery status:
HTTP
-
HTTPSuccessFeedbackRoleArn
– Indicates successful message delivery status for an Amazon SNS topic that is subscribed to an HTTP endpoint. -
HTTPSuccessFeedbackSampleRate
– Indicates percentage of successful messages to sample for an Amazon SNS topic that is subscribed to an HTTP endpoint. -
HTTPFailureFeedbackRoleArn
– Indicates failed message delivery status for an Amazon SNS topic that is subscribed to an HTTP endpoint.
Amazon Data Firehose
-
FirehoseSuccessFeedbackRoleArn
– Indicates successful message delivery status for an Amazon SNS topic that is subscribed to an Amazon Kinesis Data Firehose endpoint. -
FirehoseSuccessFeedbackSampleRate
– Indicates percentage of successful messages to sample for an Amazon SNS topic that is subscribed to an Amazon Kinesis Data Firehose endpoint. -
FirehoseFailureFeedbackRoleArn
– Indicates failed message delivery status for an Amazon SNS topic that is subscribed to an Amazon Kinesis Data Firehose endpoint.
AWS Lambda
-
LambdaSuccessFeedbackRoleArn
– Indicates successful message delivery status for an Amazon SNS topic that is subscribed to an Lambda endpoint. -
LambdaSuccessFeedbackSampleRate
– Indicates percentage of successful messages to sample for an Amazon SNS topic that is subscribed to an Lambda endpoint. -
LambdaFailureFeedbackRoleArn
– Indicates failed message delivery status for an Amazon SNS topic that is subscribed to an Lambda endpoint.
Platform application endpoint
-
ApplicationSuccessFeedbackRoleArn
– Indicates successful message delivery status for an Amazon SNS topic that is subscribed to an AWS application endpoint. -
ApplicationSuccessFeedbackSampleRate
– Indicates percentage of successful messages to sample for an Amazon SNS topic that is subscribed to an AWS application endpoint. -
ApplicationFailureFeedbackRoleArn
– Indicates failed message delivery status for an Amazon SNS topic that is subscribed to an AWS application endpoint.Note
In addition to being able to configure topic attributes for message delivery status of notification messages sent to Amazon SNS application endpoints, you can also configure application attributes for the delivery status of push notification messages sent to push notification services. For more information, see Using Amazon SNS Application Attributes for Message Delivery Status.
Amazon SQS
-
SQSSuccessFeedbackRoleArn
– Indicates successful message delivery status for an Amazon SNS topic that is subscribed to an Amazon SQS endpoint. -
SQSSuccessFeedbackSampleRate
– Indicates percentage of successful messages to sample for an Amazon SNS topic that is subscribed to an Amazon SQS endpoint. -
SQSFailureFeedbackRoleArn
– Indicates failed message delivery status for an Amazon SNS topic that is subscribed to an Amazon SQS endpoint.
Note
The <ENDPOINT>SuccessFeedbackRoleArn
and
<ENDPOINT>FailureFeedbackRoleArn
attributes are used to
give Amazon SNS write access to use CloudWatch Logs on your behalf. The
<ENDPOINT>SuccessFeedbackSampleRate
attribute is for
specifying the sample rate percentage (0-100) of successfully delivered
messages. After you configure the
<ENDPOINT>FailureFeedbackRoleArn
attribute, then all
failed message deliveries generate CloudWatch Logs.
AWS SDK examples to configure topic attributes
The following code examples show how to set Amazon SNS topic attributes.
Configuring delivery status logging using AWS CloudFormation
To configure DeliveryStatusLogging
using AWS CloudFormation, use a JSON or YAML
template to create an AWS CloudFormation stack. For more information, see the
DeliveryStatusLogging
property of the AWS::SNS::Topic
resource in the AWS CloudFormation User Guide. Below are examples of AWS CloudFormation templates in JSON and YAML
to create a new topic or update an existing topic with all
DeliveryStatusLogging
attributes for the Amazon SQS protocol.