Skip to main content

scheduled_queries

Creates, updates, deletes, gets or lists a scheduled_queries resource.

Overview

Namescheduled_queries
TypeResource
Idaws.logs.scheduled_queries

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
namestringThe name of the scheduled query.
creation_timeinteger (int64)The timestamp when the scheduled query was created.
descriptionstringThe description of the scheduled query.
destination_configurationobjectConfiguration for where query results are delivered.
end_time_offsetinteger (int64)The time offset in seconds that defines the end of the lookback period for the query.
execution_role_arnstringThe ARN of the IAM role used to execute the query and deliver results.
last_execution_statusstringThe status of the most recent execution of the scheduled query. (Running, InvalidQuery, Complete, Failed, Timeout)
last_triggered_timeinteger (int64)The timestamp when the scheduled query was last executed.
last_updated_timeinteger (int64)The timestamp when the scheduled query was last updated.
log_group_identifiersarrayThe log groups queried by the scheduled query.
query_languagestringThe query language used by the scheduled query. (CWLI, SQL, PPL)
query_stringstringThe query string executed by the scheduled query.
schedule_end_timeinteger (int64)The end time for the scheduled query in Unix epoch format.
schedule_expressionstringThe cron expression that defines when the scheduled query runs.
schedule_start_timeinteger (int64)The start time for the scheduled query in Unix epoch format.
schedule_typestringThe schedule type of the scheduled query. Valid values are CUSTOMER_MANAGED and AWS_MANAGED. (CUSTOMER_MANAGED, AWS_MANAGED)
scheduled_query_arnstringThe ARN of the scheduled query.
start_time_offsetinteger (int64)The time offset in seconds that defines the lookback period for the query.
statestringThe current state of the scheduled query. (ENABLED, DISABLED)
timezonestringThe timezone used for evaluating the schedule expression.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_scheduled_queryselectregionRetrieves details about a specific scheduled query, including its configuration, execution status, and metadata.
list_scheduled_queriesselectregionLists all scheduled queries in your account and region. You can filter results by state to show only enabled or disabled queries.
create_scheduled_queryinsertregion, name, queryLanguage, queryString, scheduleExpression, executionRoleArnCreates 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.
update_scheduled_queryupdateregion, identifier, queryLanguage, queryString, scheduleExpression, executionRoleArnUpdates an existing scheduled query with new configuration. This operation uses PUT semantics, allowing modification of query parameters, schedule, and destinations.
delete_scheduled_querydeleteregionDeletes a scheduled query and stops all future executions. This operation also removes any configured actions and associated resources.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
regionstringAWS region (default: us-east-1)

SELECT examples

Retrieves details about a specific scheduled query, including its configuration, execution status, and metadata.

SELECT
name,
creation_time,
description,
destination_configuration,
end_time_offset,
execution_role_arn,
last_execution_status,
last_triggered_time,
last_updated_time,
log_group_identifiers,
query_language,
query_string,
schedule_end_time,
schedule_expression,
schedule_start_time,
schedule_type,
scheduled_query_arn,
start_time_offset,
state,
timezone
FROM aws.logs.scheduled_queries
WHERE region = '{{ region }}' -- required
;

INSERT examples

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.

INSERT INTO aws.logs.scheduled_queries (
name,
description,
queryLanguage,
queryString,
logGroupIdentifiers,
scheduleExpression,
timezone,
startTimeOffset,
endTimeOffset,
destinationConfiguration,
scheduleStartTime,
scheduleEndTime,
executionRoleArn,
state,
tags,
region
)
SELECT
'{{ name }}' /* required */,
'{{ description }}',
'{{ queryLanguage }}' /* required */,
'{{ queryString }}' /* required */,
'{{ logGroupIdentifiers }}',
'{{ scheduleExpression }}' /* required */,
'{{ timezone }}',
{{ startTimeOffset }},
{{ endTimeOffset }},
'{{ destinationConfiguration }}',
{{ scheduleStartTime }},
{{ scheduleEndTime }},
'{{ executionRoleArn }}' /* required */,
'{{ state }}',
'{{ tags }}',
'{{ region }}'
RETURNING
scheduled_query_arn,
state
;

UPDATE examples

Updates an existing scheduled query with new configuration. This operation uses PUT semantics, allowing modification of query parameters, schedule, and destinations.

UPDATE aws.logs.scheduled_queries
SET
identifier = '{{ identifier }}',
description = '{{ description }}',
queryLanguage = '{{ queryLanguage }}',
queryString = '{{ queryString }}',
logGroupIdentifiers = '{{ logGroupIdentifiers }}',
scheduleExpression = '{{ scheduleExpression }}',
timezone = '{{ timezone }}',
startTimeOffset = {{ startTimeOffset }},
endTimeOffset = {{ endTimeOffset }},
destinationConfiguration = '{{ destinationConfiguration }}',
scheduleStartTime = {{ scheduleStartTime }},
scheduleEndTime = {{ scheduleEndTime }},
executionRoleArn = '{{ executionRoleArn }}',
state = '{{ state }}'
WHERE
region = '{{ region }}' --required
AND identifier = '{{ identifier }}' --required
AND queryLanguage = '{{ queryLanguage }}' --required
AND queryString = '{{ queryString }}' --required
AND scheduleExpression = '{{ scheduleExpression }}' --required
AND executionRoleArn = '{{ executionRoleArn }}' --required
RETURNING
name,
creation_time,
description,
destination_configuration,
end_time_offset,
execution_role_arn,
last_execution_status,
last_triggered_time,
last_updated_time,
log_group_identifiers,
query_language,
query_string,
schedule_end_time,
schedule_expression,
schedule_start_time,
schedule_type,
scheduled_query_arn,
start_time_offset,
state,
timezone;

DELETE examples

Deletes a scheduled query and stops all future executions. This operation also removes any configured actions and associated resources.

DELETE FROM aws.logs.scheduled_queries
WHERE region = '{{ region }}' --required
;