

要获得与亚马逊 Timestream 类似的功能 LiveAnalytics，可以考虑适用于 InfluxDB 的亚马逊 Timestream。适用于 InfluxDB 的 Amazon Timestream 提供简化的数据摄取和个位数毫秒级的查询响应时间，以实现实时分析。点击[此处](https://docs.aws.amazon.com//timestream/latest/developerguide/timestream-for-influxdb.html)了解更多信息。

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

# 使用 API
<a name="Using.API"></a>

 除此之外 [SDKs](getting-started-sdks.md)，Amazon Timestream 还通过*终端节点发现*模式 LiveAnalytics 提供直接的 REST API 访问权限。下文介绍端点发现模式及其使用案例。

## 端点发现模式
<a name="Using-API.endpoint-discovery"></a>

由于 Timestream Live Analytics 旨在透明地与服务的架构（包括服务端点的管理和映射）配合使用，因此建议您 SDKs 对大多数应用程序使用。 SDKs 但是，在某些情况下，需要使用 Timestream for LiveAnalytics REST API 端点发现模式：
+ 您正在使用[带有 Timestream 的 VPC 终端节点 (AWS PrivateLink) LiveAnalytics](VPCEndpoints.md)
+ 应用程序使用的编程语言尚不支持 SDK
+ 需要对客户端实现进行更有效的控制

本部分包含有关端点发现模式的工作原理、如何实施端点发现模式以及使用说明的信息。选择以下主题以了解更多信息。

**Topics**
+ [

## 端点发现模式
](#Using-API.endpoint-discovery)
+ [

# 端点发现模式的工作原理
](Using-API.endpoint-discovery.how-it-works.md)
+ [

# 实施端点发现模式
](Using-API.endpoint-discovery.describe-endpoints.implementation.md)

# 端点发现模式的工作原理
<a name="Using-API.endpoint-discovery.how-it-works"></a>

 Timestream 使用[蜂窝架构](architecture.md#cells)进行构建，以确保更优的扩展性和流量隔离特性。由于每个客户账户都映射到区域中的特定单元格，因此应用程序必须使用与账户映射对应的正确单元格专用端点。使用时 SDKs，系统会为您透明地处理此映射，您无需管理单元特定的端点。然而，直接访问 REST API 时，您需要自行管理和映射正确的端点。此过程，即*端点发现模式*，如下所述：

1.  端点发现模式从调用 `DescribeEndpoints` 操作开始（如 [https://docs.aws.amazon.com/timestream/latest/developerguide/API_Reference.html](https://docs.aws.amazon.com/timestream/latest/developerguide/API_Reference.html) 部分所述）。

1.  应在返回的 time-to-live (TTL) 值 (the) 指定的时间内缓存和重复使用该[https://docs.aws.amazon.com/timestream/latest/developerguide/API_Endpoint.html#timestream-Type-Endpoint-CachePeriodInMinutes.html](https://docs.aws.amazon.com/timestream/latest/developerguide/API_Endpoint.html#timestream-Type-Endpoint-CachePeriodInMinutes.html)端点。可在 TTL 持续时间内调用 Timestream LiveAnalytics API。

1.  TTL 过期后， DescribeEndpoints 应重新调用以刷新终端节点（换句话说，从步骤 1 重新开始）。

**注意**  
 `DescribeEndpoints` 操作的语法、参数及其他用法信息，详见 [API 参考](https://docs.aws.amazon.com/timestream/latest/developerguide/API_DescribeEndpoints.html)。请注意，该`DescribeEndpoints`操作可通过两者使用 SDKs，并且每种操作都相同。

有关端点发现模式的实施，请参阅[实施端点发现模式](Using-API.endpoint-discovery.describe-endpoints.implementation.md)。

# 实施端点发现模式
<a name="Using-API.endpoint-discovery.describe-endpoints.implementation"></a>

 要实现端点发现模式，请选择一个 API（写入或查询），创建**DescribeEndpoints**请求，然后在返回的 TTL 值持续时间内使用返回的端点。实施过程如下所述。

**注意**  
确保您熟悉[使用说明](#Using-API.endpoint-discovery.describe-endpoints.usage-notes)。

## 实施过程
<a name="Using-API.endpoint-discovery.describe-endpoints.implementation.procedure"></a>

1.  使用 [https://docs.aws.amazon.com/timestream/latest/developerguide/API_DescribeEndpoints.html](https://docs.aws.amazon.com/timestream/latest/developerguide/API_DescribeEndpoints.html) 请求，获取您要对其进行调用（[写入](https://docs.aws.amazon.com/timestream/latest/developerguide/API_Operations_Amazon_Timestream_Write.html)或[查询](https://docs.aws.amazon.com/timestream/latest/developerguide/API_Operations_Amazon_Timestream_Query.html)）的 API 的端点。

   1.  使用下述两个端点之一，创建与目标 API（[写入](https://docs.aws.amazon.com/timestream/latest/developerguide/API_Operations_Amazon_Timestream_Write.html)或[查询](https://docs.aws.amazon.com/timestream/latest/developerguide/API_Operations_Amazon_Timestream_Query.html)）相对应的 [https://docs.aws.amazon.com/timestream/latest/developerguide/API_DescribeEndpoints.html](https://docs.aws.amazon.com/timestream/latest/developerguide/API_DescribeEndpoints.html) 请求。该请求没有输入参数。请务必阅读以下说明。  
*写入 SDK：*  

      ```
      ingest.timestream.<region>.amazonaws.com
      ```  
*查询 SDK：*  

      ```
      query.timestream.<region>.amazonaws.com
      ```

      以下是区域 `us-east-1` 的 CLI 调用示例。

      ```
      REGION_ENDPOINT="https://query.timestream.us-east-1.amazonaws.com"
      REGION=us-east-1
      aws timestream-write describe-endpoints \
      --endpoint-url $REGION_ENDPOINT \
      --region $REGION
      ```
**注意**  
 HTTP“主机”标头还*必须*包含 API 端点。如果未填充该标头，则请求将失败。这是所有 HTTP/1.1 请求的标准要求。如果使用支持 1.1 或更高版本的 HTTP 库，HTTP 库应自动为您填充标头。
**注意**  
*<region>*用请求所在区域的区域标识符替换，例如 `us-east-1`

   1. 解析响应，以提取端点并缓存 TTL 值。响应是一个或多个 [`Endpoint` 对象](https://docs.aws.amazon.com/timestream/latest/developerguide/API_Endpoint.html)的数组。每个 `Endpoint` 对象都包含一个端点地址（`Address`）和该端点的 TTL（`CachePeriodInMinutes`）。

1.  缓存端点，其 TTL 不超过指定值。

1.  TTL 到期后，请从实施步骤 1 重新开始，以检索新的端点。

## 端点发现模式的使用说明
<a name="Using-API.endpoint-discovery.describe-endpoints.usage-notes"></a>
+ 该**DescribeEndpoints**操作是 Timestream Live Analytics 区域端点识别的唯一操作。
+ 响应包含用于调用 Timestream LiveAnalytics API 的端点列表。
+  成功响应后，列表应至少包含一个端点。如果列表中包含多个端点，则其中任意一个均可用于 API 调用，调用者可随机选择使用其中一个端点。
+ 除端点的 DNS 地址外，列表中的每个端点还将指定允许使用该端点的生存时间（TTL），以分钟为单位。
+ 该端点应进行缓存和重复使用，时长由返回的 TTL 值所指定（以分钟为单位）。TTL 过期后，**DescribeEndpoints**应重新调用以刷新要使用的终端节点，因为 TTL 过期后终端节点将不再起作用。