

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

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

# AWS Lambda
<a name="Lambda"></a>

 您可以为创建与 Timestream 交互的 Lambda 函数。 LiveAnalytics例如，您可以创建定期运行的 Lambda 函数，用于在 Timestream 上执行查询，并根据满足一个或多个条件的查询结果发送 SNS 通知。要了解有关 Lambda 的更多信息，请参阅 [AWS Lambda 文档](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html)。

**Topics**
+ [使用 AWS Amazon Tim LiveAnalytics estream 为 Python 构建 Lambda 函数](#Lambda.w-python)
+ [使用 Amazon Timestre AWS am 构建 Lambda 函数 LiveAnalytics JavaScript](#Lambda.w-js)
+ [使用 Amazon Tim LiveAnalytics estre AWS am 为 Go 构建 Lambda 函数](#Lambda.w-go)
+ [使用 Amazon Tim LiveAnalytics estre AWS am 为 C\$1 构建 Lambda 函数](#Lambda.w-c-sharp)

## 使用 AWS Amazon Tim LiveAnalytics estream 为 Python 构建 Lambda 函数
<a name="Lambda.w-python"></a>

 要使用 LiveAnalytics 带有 Python 的 Amazon Timestream 构建 AWS Lambda 函数，请按照以下步骤操作。

1.  创建 IAM 角色以供 Lambda 代入，该角色将授予访问 Timestream 服务所需的权限，如[提供访问时间 LiveAnalytics 流](accessing.md#getting-started.prereqs.iam-user)中所述。

1. 编辑 IAM 角色的信任关系，以添加 Lambda 服务。您可以使用以下命令更新现有角色，以便 AWS Lambda 可以代入该角色：

   1. 创建信任策略文档：

      ```
      cat > Lambda-Role-Trust-Policy.json << EOF
      {
        "Version": "2012-10-17",		 	 	 
        "Statement": [
          {
            "Effect": "Allow",
            "Principal": {
              "Service": [
                "lambda.amazonaws.com"
              ]
            },
            "Action": "sts:AssumeRole"
          }
        ]
      }
      EOF
      ```

   1. 使用信任文档更新上述步骤中的角色

      ```
      aws iam update-assume-role-policy --role-name <name_of_the_role_from_step_1> --policy-document file://Lambda-Role-Trust-Policy.json
      ```

相关参考文献位于[TimestreamWrite](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/timestream-write.html)和[TimestreamQuery](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/timestream-query.html)。

## 使用 Amazon Timestre AWS am 构建 Lambda 函数 LiveAnalytics JavaScript
<a name="Lambda.w-js"></a>

 [要使用 Amazon Time LiveAnalytics stre AWS am for with 构建 Lambda 函数，请按照此处概述的说明进行操作。 JavaScript](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-package.html#nodejs-package-dependencies)

相关参考文献位于 [Timestream Write Client- JavaScript v3 版 AWS SDK](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-timestream-write/index.html) 和适用于 v3 的 [Timestream Query AWS JavaScript ](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-timestream-query/index.html)

## 使用 Amazon Tim LiveAnalytics estre AWS am 为 Go 构建 Lambda 函数
<a name="Lambda.w-go"></a>

 [要使用带有 Go 的 Amazon Time LiveAnalytics stream 构建 AWS Lambda 函数，请按照此处概述的说明进行操作。](https://docs.aws.amazon.com/lambda/latest/dg/golang-package.html)

相关参考请参阅 [timestreamwrite](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/timestreamwrite) 和 [timestreamquery](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/timestreamquery)。

## 使用 Amazon Tim LiveAnalytics estre AWS am 为 C\$1 构建 Lambda 函数
<a name="Lambda.w-c-sharp"></a>

 [要使用带有 C\$1 的 Amazon Time LiveAnalytics stream 构建 AWS Lambda 函数，请按照此处概述的说明进行操作。](https://docs.aws.amazon.com/lambda/latest/dg/csharp-package.html)

相关参考资料可在 [Amazon 上找到。 TimestreamWrite](https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/TimestreamWrite/NTimestreamWrite.html)还有[亚马逊。 TimestreamQuery](https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/TimestreamQuery/NTimestreamQuery.html)。