AWS Tools for Windows PowerShell
Command Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Synopsis

Calls the Amazon CloudWatch PutLogAlarm API operation.

Syntax

Write-CWLogAlarm
-ActionLogLineCount <Int32>
-ActionLogLineRoleArn <String>
-ActionsEnabled <Boolean>
-ScheduledQueryConfiguration_AggregationExpression <String>
-AlarmAction <String[]>
-AlarmDescription <String>
-AlarmName <String>
-ComparisonOperator <ComparisonOperator>
-ScheduledQueryConfiguration_ScheduleConfiguration_EndTimeOffset <Int64>
-InsufficientDataAction <String[]>
-ScheduledQueryConfiguration_LogGroupIdentifier <String[]>
-OKAction <String[]>
-ScheduledQueryConfiguration_QueryARN <String>
-QueryResultsToAlarm <Int32>
-QueryResultsToEvaluate <Int32>
-ScheduledQueryConfiguration_QueryString <String>
-ScheduledQueryConfiguration_ScheduledQueryRoleARN <String>
-ScheduledQueryConfiguration_ScheduleConfiguration_ScheduleExpression <String>
-ScheduledQueryConfiguration_ScheduleConfiguration_StartTimeOffset <Int64>
-ScheduledQueryConfiguration_Tag <Tag[]>
-Tag <Tag[]>
-Threshold <Double>
-TreatMissingData <String>
-Select <String>
-Force <SwitchParameter>
-ClientConfig <AmazonCloudWatchConfig>

Description

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

-ActionLogLineCount <Int32>
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.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-ActionLogLineRoleArn <String>
The Amazon Resource Name (ARN) of an IAM role that CloudWatch assumes to retrieve log events for inclusion in alarm action notifications. Required when ActionLogLineCount is greater than 0.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-ActionsEnabled <Boolean>
Indicates whether actions should be executed during any changes to the alarm state. The default is true.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-AlarmAction <String[]>
The actions to execute when this alarm transitions to the ALARM state 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 Starting with version 4 of the SDK this property will default to null. If no data for this property is returned from the service the property will also be null. This was changed to improve performance and allow the SDK and caller to distinguish between a property not set or a property being empty to clear out a value. To retain the previous SDK behavior set the AWSConfigs.InitializeCollections static property to true.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesAlarmActions
-AlarmDescription <String>
The description for the alarm.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-AlarmName <String>
The name for the alarm. This name must be unique within the Amazon Web Services account and Region.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-ClientConfig <AmazonCloudWatchConfig>
Amazon.PowerShell.Cmdlets.CW.AmazonCloudWatchClientCmdlet.ClientConfig
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-ComparisonOperator <ComparisonOperator>
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, and LessThanOrEqualToThreshold.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
This parameter overrides confirmation prompts to force the cmdlet to continue its operation. This parameter should always be used with caution.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-InsufficientDataAction <String[]>
The actions to execute when this alarm transitions to the INSUFFICIENT_DATA state 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
Starting with version 4 of the SDK this property will default to null. If no data for this property is returned from the service the property will also be null. This was changed to improve performance and allow the SDK and caller to distinguish between a property not set or a property being empty to clear out a value. To retain the previous SDK behavior set the AWSConfigs.InitializeCollections static property to true.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesInsufficientDataActions
-OKAction <String[]>
The actions to execute when this alarm transitions to the OK state 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
Starting with version 4 of the SDK this property will default to null. If no data for this property is returned from the service the property will also be null. This was changed to improve performance and allow the SDK and caller to distinguish between a property not set or a property being empty to clear out a value. To retain the previous SDK behavior set the AWSConfigs.InitializeCollections static property to true.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesOKActions
-QueryResultsToAlarm <Int32>
The number of query results, out of the most recent QueryResultsToEvaluate results, that must breach the threshold to trigger the alarm to transition to ALARM (the M in M-of-N evaluation). Must be less than or equal to QueryResultsToEvaluate.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-QueryResultsToEvaluate <Int32>
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.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-ScheduledQueryConfiguration_AggregationExpression <String>
The expression that defines how to aggregate query results into one or more scalar values for alarm evaluation. For example, count(*) or avg(latency) by host | sort desc. Length constraints: minimum 1 character, maximum 2048 characters.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-ScheduledQueryConfiguration_LogGroupIdentifier <String[]>
The log groups to query. Each entry can be a log group name or ARN. Use the ARN form when querying log groups in a different account (for example, when running cross-account queries from a monitoring account). The list must contain between 1 and 50 entries. Starting with version 4 of the SDK this property will default to null. If no data for this property is returned from the service the property will also be null. This was changed to improve performance and allow the SDK and caller to distinguish between a property not set or a property being empty to clear out a value. To retain the previous SDK behavior set the AWSConfigs.InitializeCollections static property to true.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesScheduledQueryConfiguration_LogGroupIdentifiers
-ScheduledQueryConfiguration_QueryARN <String>
The Amazon Resource Name (ARN) of the CloudWatch Logs scheduled query that the alarm uses. This field is populated in DescribeAlarms responses.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-ScheduledQueryConfiguration_QueryString <String>
The CloudWatch Logs query to execute on each scheduled run. Length constraints: maximum of 10,000 characters.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-ScheduledQueryConfiguration_ScheduleConfiguration_EndTimeOffset <Int64>
The offset, in seconds, before the scheduled execution time at which the query time range ends. Must be non-negative and less than StartTimeOffset. The default is 0.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-ScheduledQueryConfiguration_ScheduleConfiguration_ScheduleExpression <String>
The schedule expression that defines how often the underlying CloudWatch Logs scheduled query runs. Specify a rate() expression, for example rate(5 minutes).
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-ScheduledQueryConfiguration_ScheduleConfiguration_StartTimeOffset <Int64>
The offset, in seconds, before the scheduled execution time at which the query time range begins. For example, an offset of 360 (6 minutes) on a query running at 12:05:00 starts the query time range at 11:59:00.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-ScheduledQueryConfiguration_ScheduledQueryRoleARN <String>
The Amazon Resource Name (ARN) of the IAM role that CloudWatch assumes when executing the scheduled query against the configured log groups.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-ScheduledQueryConfiguration_Tag <Tag[]>
A list of key-value pairs to associate with the underlying scheduled query resource. Starting with version 4 of the SDK this property will default to null. If no data for this property is returned from the service the property will also be null. This was changed to improve performance and allow the SDK and caller to distinguish between a property not set or a property being empty to clear out a value. To retain the previous SDK behavior set the AWSConfigs.InitializeCollections static property to true.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesScheduledQueryConfiguration_Tags
-Select <String>
Use the -Select parameter to control the cmdlet output. The cmdlet doesn't have a return value by default. Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.CloudWatch.Model.PutLogAlarmResponse). Specifying -Select '^ParameterName' will result in the cmdlet returning the selected cmdlet parameter value.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-Tag <Tag[]>
A list of key-value pairs to associate with the alarm. You can use tags to categorize and manage your alarms. Starting with version 4 of the SDK this property will default to null. If no data for this property is returned from the service the property will also be null. This was changed to improve performance and allow the SDK and caller to distinguish between a property not set or a property being empty to clear out a value. To retain the previous SDK behavior set the AWSConfigs.InitializeCollections static property to true.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesTags
-Threshold <Double>
The value to compare with the aggregated query result.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-TreatMissingData <String>
Sets how this alarm is to handle missing data points. Valid values are breaching, notBreaching, ignore, and missing. If this parameter is omitted, the default behavior of missing is used.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)

Common Credential and Region Parameters

-AccessKey <String>
The AWS access key for the user account. This can be a temporary access key if the corresponding session token is supplied to the -SessionToken parameter.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesAK
-Credential <AWSCredentials>
An AWSCredentials object instance containing access and secret key information, and optionally a token for session-based credentials.
Required?False
Position?Named
Accept pipeline input?True (ByValue, ByPropertyName)
-EndpointUrl <String>
The endpoint to make the call against.Note: This parameter is primarily for internal AWS use and is not required/should not be specified for normal usage. The cmdlets normally determine which endpoint to call based on the region specified to the -Region parameter or set as default in the shell (via Set-DefaultAWSRegion). Only specify this parameter if you must direct the call to a specific custom endpoint.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-NetworkCredential <PSCredential>
Used with SAML-based authentication when ProfileName references a SAML role profile. Contains the network credentials to be supplied during authentication with the configured identity provider's endpoint. This parameter is not required if the user's default network identity can or should be used during authentication.
Required?False
Position?Named
Accept pipeline input?True (ByValue, ByPropertyName)
-ProfileLocation <String>
Used to specify the name and location of the ini-format credential file (shared with the AWS CLI and other AWS SDKs)If this optional parameter is omitted this cmdlet will search the encrypted credential file used by the AWS SDK for .NET and AWS Toolkit for Visual Studio first. If the profile is not found then the cmdlet will search in the ini-format credential file at the default location: (user's home directory)\.aws\credentials.If this parameter is specified then this cmdlet will only search the ini-format credential file at the location given.As the current folder can vary in a shell or during script execution it is advised that you use specify a fully qualified path instead of a relative path.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesAWSProfilesLocation, ProfilesLocation
-ProfileName <String>
The user-defined name of an AWS credentials or SAML-based role profile containing credential information. The profile is expected to be found in the secure credential file shared with the AWS SDK for .NET and AWS Toolkit for Visual Studio. You can also specify the name of a profile stored in the .ini-format credential file used with the AWS CLI and other AWS SDKs.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesStoredCredentials, AWSProfileName
-Region <Object>
The system name of an AWS region or an AWSRegion instance. This governs the endpoint that will be used when calling service operations. Note that the AWS resources referenced in a call are usually region-specific.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesRegionToCall
-SecretKey <String>
The AWS secret key for the user account. This can be a temporary secret key if the corresponding session token is supplied to the -SessionToken parameter.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesSK, SecretAccessKey
-SessionToken <String>
The session token if the access and secret keys are temporary session-based credentials.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesST

Outputs

This cmdlet does not generate any output.The service response (type Amazon.CloudWatch.Model.PutLogAlarmResponse) be returned by specifying '-Select *'.

Supported Version

AWS Tools for PowerShell: 2.x.y.z