AWS CloudWatch Query Definition
This page shows how to write Terraform and CloudFormation for CloudWatch Query Definition and write them securely.
aws_cloudwatch_query_definition (Terraform)
The Query Definition in CloudWatch can be configured in Terraform with the resource name aws_cloudwatch_query_definition
. The following sections describe 2 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_cloudwatch_query_definition" "admin-api-50X-errors" {
name = "ADMIN & API - 50X errors"
log_group_names = [
local.eks_application_log_group
]
resource "aws_cloudwatch_query_definition" "non_healthcheck_requests" {
name = "no_healthchecks_or_scanning_output"
query_string = <<QUERY
fields @timestamp, status, request_uri, @message
| sort @timestamp desc
Parameters
-
id
optional computed - string -
log_group_names
optional - list of string -
name
required - string -
query_definition_id
optional computed - string -
query_string
required - string
Explanation in Terraform Registry
Provides a CloudWatch Logs query definition resource.
AWS::CloudWatch::InsightRule (CloudFormation)
The InsightRule in CloudWatch can be configured in CloudFormation with the resource name AWS::CloudWatch::InsightRule
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
-
RuleState
required - String -
RuleBody
required - String -
RuleName
required - String -
Tags
optional - Tags
Explanation in CloudFormation Registry
Creates or updates a Contributor Insights rule. Rules evaluate log events in a CloudWatch Logs log group, enabling you to find contributor data for the log events in that log group. For more information, see Using Contributor Insights to Analyze High-Cardinality Data in the Amazon CloudWatch User Guide.
Frequently asked questions
What is AWS CloudWatch Query Definition?
AWS CloudWatch Query Definition is a resource for CloudWatch of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS CloudWatch Query Definition?
For Terraform, the cds-snc/notification-terraform and ministryofjustice/opg-digideps source code examples are useful. See the Terraform Example section for further details.