Skip to content

Create Scheduled Query

cloudwatchlogs_create_scheduled_query R Documentation

Creates a scheduled query that runs CloudWatch Logs Insights queries at regular intervals

Description

Creates a scheduled query that runs CloudWatch Logs Insights queries at regular intervals. Scheduled queries enable proactive monitoring by automatically executing queries to detect patterns and anomalies in your log data. Query results can be delivered to Amazon S3 for analysis or further processing.

Usage

cloudwatchlogs_create_scheduled_query(name, description, queryLanguage,
  queryString, logGroupIdentifiers, scheduleExpression, timezone,
  startTimeOffset, destinationConfiguration, scheduleStartTime,
  scheduleEndTime, executionRoleArn, state, tags)

Arguments

name

[required] The name of the scheduled query. The name must be unique within your account and region. Valid characters are alphanumeric characters, hyphens, underscores, and periods. Length must be between 1 and 255 characters.

description

An optional description for the scheduled query to help identify its purpose and functionality.

queryLanguage

[required] The query language to use for the scheduled query. Valid values are CWLI, PPL, and SQL.

queryString

[required] The query string to execute. This is the same query syntax used in CloudWatch Logs Insights. Maximum length is 10,000 characters.

logGroupIdentifiers

An array of log group names or ARNs to query. You can specify between 1 and 50 log groups. Log groups can be identified by name or full ARN.

scheduleExpression

[required] A cron expression that defines when the scheduled query runs. The expression uses standard cron syntax and supports minute-level precision. Maximum length is 256 characters.

timezone

The timezone for evaluating the schedule expression. This determines when the scheduled query executes relative to the specified timezone.

startTimeOffset

The time offset in seconds that defines the lookback period for the query. This determines how far back in time the query searches from the execution time.

destinationConfiguration

Configuration for where to deliver query results. Currently supports Amazon S3 destinations for storing query output.

scheduleStartTime

The start time for the scheduled query in Unix epoch format. The query will not execute before this time.

scheduleEndTime

The end time for the scheduled query in Unix epoch format. The query will stop executing after this time.

executionRoleArn

[required] The ARN of the IAM role that grants permissions to execute the query and deliver results to the specified destination. The role must have permissions to read from the specified log groups and write to the destination.

state

The initial state of the scheduled query. Valid values are ENABLED and DISABLED. Default is ENABLED.

tags

Key-value pairs to associate with the scheduled query for resource management and cost allocation.

Value

A list with the following syntax:

list(
  scheduledQueryArn = "string",
  state = "ENABLED"|"DISABLED"
)

Request syntax

svc$create_scheduled_query(
  name = "string",
  description = "string",
  queryLanguage = "CWLI"|"SQL"|"PPL",
  queryString = "string",
  logGroupIdentifiers = list(
    "string"
  ),
  scheduleExpression = "string",
  timezone = "string",
  startTimeOffset = 123,
  destinationConfiguration = list(
    s3Configuration = list(
      destinationIdentifier = "string",
      roleArn = "string",
      ownerAccountId = "string",
      kmsKeyId = "string"
    )
  ),
  scheduleStartTime = 123,
  scheduleEndTime = 123,
  executionRoleArn = "string",
  state = "ENABLED"|"DISABLED",
  tags = list(
    "string"
  )
)