

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

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

# ExecuteScheduledQuery
<a name="API_query_ExecuteScheduledQuery"></a>

 可使用此 API 手动运行计划查询。

如果已启用 `QueryInsights`，此 API 还会返回与您在 Amazon SNS 通知中所执行查询相关的见解和指标。`QueryInsights` 有助于调整查询的性能。有关 `QueryInsights` 的更多信息，请参阅[使用查询见解优化 Amazon Timestream 中的查询](https://docs.aws.amazon.com/timestream/latest/developerguide/using-query-insights.html)。

## 请求语法
<a name="API_query_ExecuteScheduledQuery_RequestSyntax"></a>

```
{
   "ClientToken": "string",
   "InvocationTime": number,
   "QueryInsights": { 
      "Mode": "string"
   },
   "ScheduledQueryArn": "string"
}
```

## 请求参数
<a name="API_query_ExecuteScheduledQuery_RequestParameters"></a>

有关所有操作的通用参数的信息，请参阅[常用参数](CommonParameters.md)。

请求接受采用 JSON 格式的以下数据。

 ** [ClientToken](#API_query_ExecuteScheduledQuery_RequestSyntax) **   <a name="timestream-query_ExecuteScheduledQuery-request-ClientToken"></a>
未使用。  
类型：字符串  
长度限制：最小长度为 32。最大长度为 128。  
必需：否

 ** [InvocationTime](#API_query_ExecuteScheduledQuery_RequestSyntax) **   <a name="timestream-query_ExecuteScheduledQuery-request-InvocationTime"></a>
UTC 中的时间戳。查询将以该时间戳被调用的形式运行。  
类型：时间戳  
是否必需：是

 ** [QueryInsights](#API_query_ExecuteScheduledQuery_RequestSyntax) **   <a name="timestream-query_ExecuteScheduledQuery-request-QueryInsights"></a>
封装用于启用 `QueryInsights` 的设置。  
启用 `QueryInsights` 返回见解和指标，作为所执行查询的 Amazon SNS 通知的一部分。可使用 `QueryInsights` 以调整查询性能和成本。  
类型：[ScheduledQueryInsights](API_query_ScheduledQueryInsights.md) 对象  
必需：否

 ** [ScheduledQueryArn](#API_query_ExecuteScheduledQuery_RequestSyntax) **   <a name="timestream-query_ExecuteScheduledQuery-request-ScheduledQueryArn"></a>
计划查询的 ARN。  
类型：字符串  
长度限制：最小长度为 1。最大长度为 2048。  
是否必需：是

## 响应元素
<a name="API_query_ExecuteScheduledQuery_ResponseElements"></a>

如果此操作成功，则该服务会发送回带有空 HTTP 正文的 HTTP 200 响应。

## 错误
<a name="API_query_ExecuteScheduledQuery_Errors"></a>

有关所有操作的常见错误的信息，请参阅[常见错误](CommonErrors.md)。

 ** AccessDeniedException **   
您没有访问账户设置所需的权限。  
HTTP 状态代码：400

 ** InternalServerException **   
处理请求时发生的内部服务器错误。  
HTTP 状态代码：400

 ** InvalidEndpointException **   
请求的端点无效。  
HTTP 状态代码：400

 ** ResourceNotFoundException **   
找不到请求的资源。    
 ** ScheduledQueryArn **   
计划查询的 ARN。
HTTP 状态代码：400

 ** ThrottlingException **   
该请求因请求过多而受到限制。  
HTTP 状态代码：400

 ** ValidationException **   
 请求无效或格式错误。  
HTTP 状态代码：400

## 示例
<a name="API_query_ExecuteScheduledQuery_Examples"></a>

### ENABLED\$1WITH\$1RATE\$1CONTROL 模式的计划查询通知消息
<a name="API_query_ExecuteScheduledQuery_Example_1"></a>

以下示例显示 `QueryInsights` 参数 `ENABLED_WITH_RATE_CONTROL` 模式下成功的计划查询通知消息。

```
"SuccessNotificationMessage": {
    "type": "MANUAL_TRIGGER_SUCCESS",
    "arn": "arn:aws:timestream:<Region>:<Account>:scheduled-query/sq-test-49c6ed55-c2e7-4cc2-9956-4a0ecea13420-80e05b035236a4c3",
    "scheduledQueryRunSummary": {
        "invocationEpochSecond": 1723710546,
        "triggerTimeMillis": 1723710547490,
        "runStatus": "MANUAL_TRIGGER_SUCCESS",
        "executionStats": {
            "executionTimeInMillis": 17343,
            "dataWrites": 1024,
            "bytesMetered": 0,
            "cumulativeBytesScanned": 600,
            "recordsIngested": 1,
            "queryResultRows": 1
        },
        "queryInsightsResponse": {
            "querySpatialCoverage": {
                "max": {
                    "value": 1.0,
                    "tableArn": "arn:aws:timestream:<Region>:<Account>:database/BaseDb/table/BaseTable",
                    "partitionKey": [
                        "measure_name"
                    ]
                }
            },
            "queryTemporalRange": {
                "max": {
                    "value": 2399999999999,
                    "tableArn": "arn:aws:timestream:<Region>:<Account>:database/BaseDb/table/BaseTable"
                }
            },
            "queryTableCount": 1,
            "outputRows": 1,
            "outputBytes": 59
        }
    }
}
```

### DISABLED 模式的计划查询通知消息
<a name="API_query_ExecuteScheduledQuery_Example_2"></a>

以下示例显示 `QueryInsights` 参数 `DISABLED` 模式下成功的计划查询通知消息。

```
"SuccessNotificationMessage": {
    "type": "MANUAL_TRIGGER_SUCCESS",
    "arn": "arn:aws:timestream:<Region>:<Account>:scheduled-query/sq-test-fa109d9e-6528-4a0d-ac40-482fa05e657f-140faaeecdc5b2a7",
    "scheduledQueryRunSummary": {
        "invocationEpochSecond": 1723711401,
        "triggerTimeMillis": 1723711402144,
        "runStatus": "MANUAL_TRIGGER_SUCCESS",
        "executionStats": {
            "executionTimeInMillis": 17992,
            "dataWrites": 1024,
            "bytesMetered": 0,
            "cumulativeBytesScanned": 600,
            "recordsIngested": 1,
            "queryResultRows": 1
        }
    }
}
```

### ENABLED\$1WITH\$1RATE\$1CONTROL 模式的失败通知消息
<a name="API_query_ExecuteScheduledQuery_Example_3"></a>

以下示例显示 `QueryInsights` 参数 `ENABLED_WITH_RATE_CONTROL` 模式下失败的计划查询通知消息。

```
"FailureNotificationMessage": {
    "type": "MANUAL_TRIGGER_FAILURE",
    "arn": "arn:aws:timestream:<Region>:<Account>:scheduled-query/sq-test-b261670d-790c-4116-9db5-0798071b18b1-b7e27a1d79be226d",
    "scheduledQueryRunSummary": {
        "invocationEpochSecond": 1727915513,
        "triggerTimeMillis": 1727915513894,
        "runStatus": "MANUAL_TRIGGER_FAILURE",
        "executionStats": {
            "executionTimeInMillis": 10777,
            "dataWrites": 0,
            "bytesMetered": 0,
            "cumulativeBytesScanned": 0,
            "recordsIngested": 0,
            "queryResultRows": 4
        },
        "errorReportLocation": {
            "s3ReportLocation": {
                "bucketName": "amzn-s3-demo-bucket",
                "objectKey": "4my-organization-f7a3c5d065a1a95e/1727915513/MANUAL/1727915513894/5e14b3df-b147-49f4-9331-784f749b68ae"
            }
        },
        "failureReason": "Schedule encountered some errors and is incomplete. Please take a look at error report for further details"
    }
}
```

### DISABLED 模式的失败通知消息
<a name="API_query_ExecuteScheduledQuery_Example_4"></a>

以下示例显示 `QueryInsights` 参数 `DISABLED` 模式下失败的计划查询通知消息。

```
"FailureNotificationMessage": {
    "type": "MANUAL_TRIGGER_FAILURE",
    "arn": "arn:aws:timestream:<Region>:<Account>:scheduled-query/sq-test-b261670d-790c-4116-9db5-0798071b18b1-b7e27a1d79be226d",
    "scheduledQueryRunSummary": {
        "invocationEpochSecond": 1727915194,
        "triggerTimeMillis": 1727915195119,
        "runStatus": "MANUAL_TRIGGER_FAILURE",
        "executionStats": {
            "executionTimeInMillis": 10777,
            "dataWrites": 0,
            "bytesMetered": 0,
            "cumulativeBytesScanned": 0,
            "recordsIngested": 0,
            "queryResultRows": 4
        },
        "errorReportLocation": {
            "s3ReportLocation": {
                "bucketName": "amzn-s3-demo-bucket",
                "objectKey": "4my-organization-b7e27a1d79be226d/1727915194/MANUAL/1727915195119/08dea9f5-9a0a-4e63-a5f7-ded23247bb98"
            }
        },
        "failureReason": "Schedule encountered some errors and is incomplete. Please take a look at error report for further details"
    }
}
```

## 另请参阅
<a name="API_query_ExecuteScheduledQuery_SeeAlso"></a>

有关以特定语言之一使用此 API 的更多信息 AWS SDKs，请参阅以下内容：
+  [AWS 命令行界面 V2](https://docs.aws.amazon.com/goto/cli2/timestream-query-2018-11-01/ExecuteScheduledQuery) 
+  [AWS 适用于.NET 的 SDK V4](https://docs.aws.amazon.com/goto/DotNetSDKV4/timestream-query-2018-11-01/ExecuteScheduledQuery) 
+  [AWS 适用于 C\$1\$1 的 SDK](https://docs.aws.amazon.com/goto/SdkForCpp/timestream-query-2018-11-01/ExecuteScheduledQuery) 
+  [AWS 适用于 Go v2 的 SDK](https://docs.aws.amazon.com/goto/SdkForGoV2/timestream-query-2018-11-01/ExecuteScheduledQuery) 
+  [AWS 适用于 Java 的 SDK V2](https://docs.aws.amazon.com/goto/SdkForJavaV2/timestream-query-2018-11-01/ExecuteScheduledQuery) 
+  [AWS JavaScript V3 版 SDK](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/timestream-query-2018-11-01/ExecuteScheduledQuery) 
+  [AWS 适用于 Kotlin 的 SDK](https://docs.aws.amazon.com/goto/SdkForKotlin/timestream-query-2018-11-01/ExecuteScheduledQuery) 
+  [AWS 适用于 PHP 的 SDK V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/timestream-query-2018-11-01/ExecuteScheduledQuery) 
+  [AWS Python 软件开发工具包](https://docs.aws.amazon.com/goto/boto3/timestream-query-2018-11-01/ExecuteScheduledQuery) 
+  [AWS 适用于 Ruby V3 的 SDK](https://docs.aws.amazon.com/goto/SdkForRubyV3/timestream-query-2018-11-01/ExecuteScheduledQuery) 