

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 使用 Athena 分析在 Amazon S3 中存储的 Amazon SNS 消息
<a name="firehose-message-analysis-s3"></a>

本页面介绍如何分析通过传输流发送到 Amazon Simple Storage Service（Amazon S3）目标的 Amazon SNS 消息。

**要分析通过 Firehose 传输流发送到 Amazon S3 目标的 SNS 消息**

1. 配置 Amazon S3 资源。有关说明，请参阅 *Amazon Simple Storage Service 用户指南*中的[创建存储桶](https://docs.aws.amazon.com/AmazonS3/latest/userguide/CreatingABucket.html)和 *Amazon Simple Storage Service 用户指南*中的[使用 Amazon S3 存储桶](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingBucket.html)。

1. 配置传输流。有关说明，请参阅《Amazon Data Firehose 开发人员指南》**中的[选择 Amazon S3 作为目标](https://docs.aws.amazon.com/firehose/latest/dev/create-destination.html#create-destination-s3)。

1. 使用 [Amazon Athena](https://console.aws.amazon.com/athena) 通过标准的 SQL 查询 Amazon S3 对象。有关更多信息，请参阅 *Amazon Athena 用户指南*中的[入门](https://docs.aws.amazon.com/athena/latest/ug/getting-started.html)。

## 示例查询
<a name="example-s3-query"></a>

在本示例查询中，我们假设满足以下条件：
+ 消息存储在 `default` schema 的 `notifications` 表中。
+ `notifications` 表包含一个类型为 `string` 的 `timestamp` 列。

以下查询返回在指定日期范围内收到的所有 SNS 消息：

```
SELECT * 
FROM default.notifications
WHERE from_iso8601_timestamp(timestamp) BETWEEN TIMESTAMP '2020-12-01 00:00:00' AND TIMESTAMP '2020-12-02 00:00:00';
```