create_scheduled_query
async
¶
create_scheduled_query(
name: ScheduledQueryName,
query_language: QueryLanguage,
query_string: QueryString,
schedule_expression: ScheduleExpression,
execution_role_arn: RoleArn,
*,
config_overrides: Optional[AsyncCloudWatchLogsClientConfig] = None,
description: Optional[ScheduledQueryDescription] = None,
log_group_identifiers: Optional[ScheduledQueryLogGroupIdentifiers] = None,
timezone: Optional[ScheduleTimezone] = None,
start_time_offset: Optional[StartTimeOffset] = None,
end_time_offset: Optional[EndTimeOffset] = None,
destination_configuration: Optional[DestinationConfiguration] = None,
schedule_start_time: Optional[Timestamp] = None,
schedule_end_time: Optional[Timestamp] = None,
state: Optional[ScheduledQueryState] = None,
tags: Optional[Tags] = None,
) -> CreateScheduledQueryResponse
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.
Parameters:
-
name(ScheduledQueryName) –The name of the scheduled query. The name must be unique within your account and region. Length must be between 1 and 300 characters.
-
description(Optional[ScheduledQueryDescription], default:None) –An optional description for the scheduled query to help identify its purpose and functionality.
-
query_language(QueryLanguage) –The query language to use for the scheduled query. Valid values are
CWLI,PPL, andSQL. -
query_string(QueryString) –The query string to execute. This is the same query syntax used in CloudWatch Logs Insights. Maximum length is 10,000 characters.
-
log_group_identifiers(Optional[ScheduledQueryLogGroupIdentifiers], default:None) –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.
-
schedule_expression(ScheduleExpression) –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(Optional[ScheduleTimezone], default:None) –The timezone for evaluating the schedule expression. This determines when the scheduled query executes relative to the specified timezone.
-
start_time_offset(Optional[StartTimeOffset], default:None) –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.
-
end_time_offset(Optional[EndTimeOffset], default:None) –The time offset in seconds that defines the end of the lookback period for the query. Together with
startTimeOffset, this determines the time window relative to the execution time over which the query runs. -
destination_configuration(Optional[DestinationConfiguration], default:None) –Configuration for where to deliver query results. Supports Amazon S3 destinations for storing query output and lookup table destinations for automatically refreshing lookup tables with query results. You can configure one or both destination types.
-
schedule_start_time(Optional[Timestamp], default:None) –The start time for the scheduled query in Unix epoch format. The query will not execute before this time.
-
schedule_end_time(Optional[Timestamp], default:None) –The end time for the scheduled query in Unix epoch format. The query will stop executing after this time.
-
execution_role_arn(RoleArn) –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(Optional[ScheduledQueryState], default:None) –The initial state of the scheduled query. Valid values are
ENABLEDandDISABLED. Default isENABLED. -
tags(Optional[Tags], default:None) –Key-value pairs to associate with the scheduled query for resource management and cost allocation.
Raises:
-
AccessDeniedException–You don't have sufficient permissions to perform this action.
-
ConflictException–This operation attempted to create a resource that already exists.
-
InternalServerException–An internal server error occurred while processing the request. This exception is returned when the service encounters an unexpected condition that prevents it from fulfilling the request.
-
ResourceNotFoundException–The specified resource does not exist.
-
ServiceQuotaExceededException–This request exceeds a service quota.
-
ThrottlingException–The request was throttled because of quota limits.
-
ValidationException–One of the parameters for the request is not valid.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_cloudwatch_logs/_services/async_cloud_watch_logs.py
1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 | |