选择您的 Cookie 首选项

我们使用必要 Cookie 和类似工具提供我们的网站和服务。我们使用性能 Cookie 收集匿名统计数据,以便我们可以了解客户如何使用我们的网站并进行改进。必要 Cookie 无法停用,但您可以单击“自定义”或“拒绝”来拒绝性能 Cookie。

如果您同意,AWS 和经批准的第三方还将使用 Cookie 提供有用的网站功能、记住您的首选项并显示相关内容,包括相关广告。要接受或拒绝所有非必要 Cookie,请单击“接受”或“拒绝”。要做出更详细的选择,请单击“自定义”。

AWS::Logs::QueryDefinition

聚焦模式
AWS::Logs::QueryDefinition - AWS CloudFormation
此页面尚未翻译为您的语言。 请求翻译
筛选器视图

Creates a query definition for CloudWatch Logs Insights. For more information, see Analyzing Log Data with CloudWatch Logs Insights.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::Logs::QueryDefinition", "Properties" : { "LogGroupNames" : [ String, ... ], "Name" : String, "QueryLanguage" : String, "QueryString" : String } }

YAML

Type: AWS::Logs::QueryDefinition Properties: LogGroupNames: - String Name: String QueryLanguage: String QueryString: String

Properties

LogGroupNames

Use this parameter if you want the query to query only certain log groups.

Required: No

Type: Array of String

Update requires: No interruption

Name

A name for the query definition.

Note

You can use the name to create a folder structure for your queries. To create a folder, use a forward slash (/) to prefix your desired query name with your desired folder name. For example, folder-name/query-name .

Required: Yes

Type: String

Minimum: 1

Maximum: 255

Update requires: No interruption

QueryLanguage

The query language used for this query. For more information about the query languages that CloudWatch Logs supports, see Supported query languages.

Required: No

Type: String

Allowed values: CWLI | SQL | PPL

Update requires: No interruption

QueryString

The query string to use for this query definition. For more information, see CloudWatch Logs Insights Query Syntax.

Required: Yes

Type: String

Minimum: 1

Maximum: 10000

Update requires: No interruption

Return values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the query definition ID.

For more information about using the Ref function, see Ref.

Fn::GetAtt

The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.

QueryDefinitionId

The ID of the query definition.

Examples

Query definition example

The following example creates a query definition.

JSON

"myQueryDefinition": { "Type": "AWS::Logs::QueryDefinition", "Properties": { "Name": "myQueryName", "QueryString": "fields @timestamp, @message | sort @timestamp desc | limit 20" } }

YAML

myQueryDefinition: Type: AWS::Logs::QueryDefinition Properties: Name: "myQueryName" QueryString: “fields @timestamp, @message | sort @timestamp desc | limit 20"

本页内容

隐私网站条款Cookie 首选项
© 2025, Amazon Web Services, Inc. 或其附属公司。保留所有权利。