Skip to content

/AWS1/IF_CWL=>CREATESCHEDULEDQUERY()

About CreateScheduledQuery

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.

Method Signature

METHODS /AWS1/IF_CWL~CREATESCHEDULEDQUERY
  IMPORTING
    !IV_NAME TYPE /AWS1/CWLSCHEDULEDQUERYNAME OPTIONAL
    !IV_DESCRIPTION TYPE /AWS1/CWLSCHEDULEDQUERYDESC OPTIONAL
    !IV_QUERYLANGUAGE TYPE /AWS1/CWLQUERYLANGUAGE OPTIONAL
    !IV_QUERYSTRING TYPE /AWS1/CWLQUERYSTRING OPTIONAL
    !IT_LOGGROUPIDENTIFIERS TYPE /AWS1/CL_CWLSCHDQUERYLOGGRID00=>TT_SCHEDULEDQUERYLOGGROUPIDS OPTIONAL
    !IV_SCHEDULEEXPRESSION TYPE /AWS1/CWLSCHEDULEEXPRESSION OPTIONAL
    !IV_TIMEZONE TYPE /AWS1/CWLSCHEDULETIMEZONE OPTIONAL
    !IV_STARTTIMEOFFSET TYPE /AWS1/CWLSTARTTIMEOFFSET OPTIONAL
    !IO_DESTINATIONCONFIGURATION TYPE REF TO /AWS1/CL_CWLDESTINATIONCONF OPTIONAL
    !IV_SCHEDULESTARTTIME TYPE /AWS1/CWLTIMESTAMP OPTIONAL
    !IV_SCHEDULEENDTIME TYPE /AWS1/CWLTIMESTAMP OPTIONAL
    !IV_EXECUTIONROLEARN TYPE /AWS1/CWLROLEARN OPTIONAL
    !IV_STATE TYPE /AWS1/CWLSCHEDULEDQUERYSTATE OPTIONAL
    !IT_TAGS TYPE /AWS1/CL_CWLTAGS_W=>TT_TAGS OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_cwlcreschddqueryrsp
  RAISING
    /AWS1/CX_CWLACCESSDENIEDEX
    /AWS1/CX_CWLCONFLICTEXCEPTION
    /AWS1/CX_CWLINTERNALSERVEREX
    /AWS1/CX_CWLRESOURCENOTFOUNDEX
    /AWS1/CX_CWLSERVICEQUOTAEXCDEX
    /AWS1/CX_CWLTHROTTLINGEX
    /AWS1/CX_CWLVALIDATIONEX
    /AWS1/CX_CWLCLIENTEXC
    /AWS1/CX_CWLSERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Required arguments:

iv_name TYPE /AWS1/CWLSCHEDULEDQUERYNAME /AWS1/CWLSCHEDULEDQUERYNAME

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.

iv_querylanguage TYPE /AWS1/CWLQUERYLANGUAGE /AWS1/CWLQUERYLANGUAGE

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

iv_querystring TYPE /AWS1/CWLQUERYSTRING /AWS1/CWLQUERYSTRING

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

iv_scheduleexpression TYPE /AWS1/CWLSCHEDULEEXPRESSION /AWS1/CWLSCHEDULEEXPRESSION

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.

iv_executionrolearn TYPE /AWS1/CWLROLEARN /AWS1/CWLROLEARN

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.

Optional arguments:

iv_description TYPE /AWS1/CWLSCHEDULEDQUERYDESC /AWS1/CWLSCHEDULEDQUERYDESC

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

it_loggroupidentifiers TYPE /AWS1/CL_CWLSCHDQUERYLOGGRID00=>TT_SCHEDULEDQUERYLOGGROUPIDS TT_SCHEDULEDQUERYLOGGROUPIDS

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.

iv_timezone TYPE /AWS1/CWLSCHEDULETIMEZONE /AWS1/CWLSCHEDULETIMEZONE

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

iv_starttimeoffset TYPE /AWS1/CWLSTARTTIMEOFFSET /AWS1/CWLSTARTTIMEOFFSET

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.

io_destinationconfiguration TYPE REF TO /AWS1/CL_CWLDESTINATIONCONF /AWS1/CL_CWLDESTINATIONCONF

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

iv_schedulestarttime TYPE /AWS1/CWLTIMESTAMP /AWS1/CWLTIMESTAMP

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

iv_scheduleendtime TYPE /AWS1/CWLTIMESTAMP /AWS1/CWLTIMESTAMP

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

iv_state TYPE /AWS1/CWLSCHEDULEDQUERYSTATE /AWS1/CWLSCHEDULEDQUERYSTATE

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

it_tags TYPE /AWS1/CL_CWLTAGS_W=>TT_TAGS TT_TAGS

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

RETURNING

oo_output TYPE REF TO /aws1/cl_cwlcreschddqueryrsp /AWS1/CL_CWLCRESCHDDQUERYRSP

Examples

Syntax Example

This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.

DATA(lo_result) = lo_client->createscheduledquery(
  io_destinationconfiguration = new /aws1/cl_cwldestinationconf(
    io_s3configuration = new /aws1/cl_cwls3configuration(
      iv_destinationidentifier = |string|
      iv_kmskeyid = |string|
      iv_owneraccountid = |string|
      iv_rolearn = |string|
    )
  )
  it_loggroupidentifiers = VALUE /aws1/cl_cwlschdqueryloggrid00=>tt_scheduledqueryloggroupids(
    ( new /aws1/cl_cwlschdqueryloggrid00( |string| ) )
  )
  it_tags = VALUE /aws1/cl_cwltags_w=>tt_tags(
    (
      VALUE /aws1/cl_cwltags_w=>ts_tags_maprow(
        key = |string|
        value = new /aws1/cl_cwltags_w( |string| )
      )
    )
  )
  iv_description = |string|
  iv_executionrolearn = |string|
  iv_name = |string|
  iv_querylanguage = |string|
  iv_querystring = |string|
  iv_scheduleendtime = 123
  iv_scheduleexpression = |string|
  iv_schedulestarttime = 123
  iv_starttimeoffset = 123
  iv_state = |string|
  iv_timezone = |string|
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  lv_arn = lo_result->get_scheduledqueryarn( ).
  lv_scheduledquerystate = lo_result->get_state( ).
ENDIF.