put_log_alarm
¶
put_log_alarm(
*,
config_overrides: Optional[CloudWatchClientConfig] = None,
alarm_name: Optional[AlarmName] = None,
alarm_description: Optional[AlarmDescription] = None,
scheduled_query_configuration: Optional[ScheduledQueryConfiguration] = None,
action_log_line_count: Optional[ActionLogLineCount] = None,
action_log_line_role_arn: Optional[ActionLogLineRoleArn] = None,
actions_enabled: Optional[ActionsEnabled] = None,
ok_actions: Optional[ResourceList] = None,
alarm_actions: Optional[ResourceList] = None,
insufficient_data_actions: Optional[ResourceList] = None,
query_results_to_evaluate: Optional[QueryResultsToEvaluate] = None,
query_results_to_alarm: Optional[QueryResultsToAlarm] = None,
threshold: Optional[Threshold] = None,
comparison_operator: Optional[ComparisonOperator] = None,
treat_missing_data: Optional[TreatMissingData] = None,
tags: Optional[TagList] = None,
warm_up_configuration: Optional[WarmUpConfiguration] = None,
) -> None
Creates or updates a log alarm. A log alarm evaluates the results of a CloudWatch Logs scheduled query against the configured threshold and comparison operator to determine its state.
When you create a log alarm, the operation creates a service-managed CloudWatch Logs scheduled query that runs the query string you provide on the schedule you configure. Each scheduled query execution returns one or more aggregated values determined by the AggregationExpression, and each aggregated value is compared against the alarm Threshold to determine the alarm state. The alarm uses M-out-of-N evaluation: if QueryResultsToAlarm out of the most recent QueryResultsToEvaluate query results breach the threshold, the alarm transitions to ALARM.
Log alarms support the alarm states (OK, ALARM, INSUFFICIENT_DATA). Configure transition actions using OKActions, AlarmActions, and InsufficientDataActions.
If you call this operation with the name of an existing log alarm, the operation replaces the previous configuration of that alarm.
Permissions
To create or update a log alarm, you must have the cloudwatch:PutLogAlarm permission. The IAM role specified in ScheduledQueryRoleARN must grant the CloudWatch Alarms service permission to execute scheduled queries on the specified log groups. If you set ActionLogLineCount, the role specified in ActionLogLineRoleArn must grant permission to retrieve log events for inclusion in alarm notifications.
Parameters:
-
alarm_name(Optional[AlarmName], default:None) –The name for the alarm. This name must be unique within the Amazon Web Services account and Region.
-
alarm_description(Optional[AlarmDescription], default:None) –The description for the alarm.
-
scheduled_query_configuration(Optional[ScheduledQueryConfiguration], default:None) –The configuration of the underlying CloudWatch Logs scheduled query that this alarm evaluates, including the query string, log groups, schedule, and aggregation expression.
-
action_log_line_count(Optional[ActionLogLineCount], default:None) –The number of log lines from the most recent scheduled query execution to include in alarm action notifications. Valid range is 0 through 50. The default is 0, which means no log lines are included.
-
action_log_line_role_arn(Optional[ActionLogLineRoleArn], default:None) –The Amazon Resource Name (ARN) of an IAM role that CloudWatch assumes to retrieve log events for inclusion in alarm action notifications. Required when
ActionLogLineCountis greater than 0. -
actions_enabled(Optional[ActionsEnabled], default:None) –Indicates whether actions should be executed during any changes to the alarm state. The default is
true. -
ok_actions(Optional[ResourceList], default:None) –The actions to execute when this alarm transitions to the
OKstate from any other state. Each action is specified as an Amazon Resource Name (ARN).Valid Values:
Amazon SNS actions:
arn:aws:sns:region:account-id:sns-topic-nameLambda actions:
-
Invoke the latest version of a Lambda function:
arn:aws:lambda:region:account-id:function:function-name -
Invoke a specific version of a Lambda function:
arn:aws:lambda:region:account-id:function:function-name:version-number -
Invoke a function by using an alias Lambda function:
arn:aws:lambda:region:account-id:function:function-name:alias-name
-
-
alarm_actions(Optional[ResourceList], default:None) –The actions to execute when this alarm transitions to the
ALARMstate from any other state. Each action is specified as an Amazon Resource Name (ARN).Valid Values:
Amazon SNS actions:
arn:aws:sns:region:account-id:sns-topic-nameLambda actions:
-
Invoke the latest version of a Lambda function:
arn:aws:lambda:region:account-id:function:function-name -
Invoke a specific version of a Lambda function:
arn:aws:lambda:region:account-id:function:function-name:version-number -
Invoke a function by using an alias Lambda function:
arn:aws:lambda:region:account-id:function:function-name:alias-name
Systems Manager actions:
arn:aws:ssm:region:account-id:opsitem:severity -
-
insufficient_data_actions(Optional[ResourceList], default:None) –The actions to execute when this alarm transitions to the
INSUFFICIENT_DATAstate from any other state. Each action is specified as an Amazon Resource Name (ARN).Valid Values:
Amazon SNS actions:
arn:aws:sns:region:account-id:sns-topic-nameLambda actions:
-
Invoke the latest version of a Lambda function:
arn:aws:lambda:region:account-id:function:function-name -
Invoke a specific version of a Lambda function:
arn:aws:lambda:region:account-id:function:function-name:version-number -
Invoke a function by using an alias Lambda function:
arn:aws:lambda:region:account-id:function:function-name:alias-name
-
-
query_results_to_evaluate(Optional[QueryResultsToEvaluate], default:None) –The number of most recent scheduled query results to evaluate against the threshold (the N in M-of-N evaluation). Valid range is 1 through 100.
-
query_results_to_alarm(Optional[QueryResultsToAlarm], default:None) –The number of query results, out of the most recent
QueryResultsToEvaluateresults, that must breach the threshold to trigger the alarm to transition toALARM(the M in M-of-N evaluation). Must be less than or equal toQueryResultsToEvaluate. -
threshold(Optional[Threshold], default:None) –The value to compare with the aggregated query result.
-
comparison_operator(Optional[ComparisonOperator], default:None) –The arithmetic operation to use when comparing the aggregated query result and the threshold. The aggregated query result is used as the first operand. Valid values are
GreaterThanThreshold,GreaterThanOrEqualToThreshold,LessThanThreshold, andLessThanOrEqualToThreshold. -
treat_missing_data(Optional[TreatMissingData], default:None) –Sets how this alarm is to handle missing data points. Valid values are
breaching,notBreaching,ignore, andmissing. If this parameter is omitted, the default behavior ofmissingis used. -
tags(Optional[TagList], default:None) –A list of key-value pairs to associate with the alarm. You can use tags to categorize and manage your alarms.
-
warm_up_configuration(Optional[WarmUpConfiguration], default:None) –The warm-up configuration for the alarm. A warm-up period delays alarm evaluation after you create or update the alarm. The warm-up period reduces alarm noise from missing data while a new resource or service starts publishing data.
For more information, see Alarm warm-up periods in the Amazon CloudWatch User Guide.
Raises:
-
LimitExceededFault–The quota for alarms for this customer has already been reached.
-
ResourceConflict–The operation could not be completed because the request conflicts with the current state of the alarm or its underlying scheduled query resource.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_cloudwatch/_services/cloud_watch.py
3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 | |