class PromQLAlarm (construct)
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.CloudWatch.PromQLAlarm |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awscloudwatch#PromQLAlarm |
Java | software.amazon.awscdk.services.cloudwatch.PromQLAlarm |
Python | aws_cdk.aws_cloudwatch.PromQLAlarm |
TypeScript (source) | aws-cdk-lib » aws_cloudwatch » PromQLAlarm |
Implements
IConstruct, IDependable, IResource, IEnvironment, IAlarm, IAlarm, IAlarm
A CloudWatch Alarm based on a PromQL query expression.
See also: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/alarm-promql.html
Example
new cloudwatch.PromQLAlarm(this, 'HighLatencyAlarm', {
alarmDescription: 'P99 latency exceeds 500ms for 5 minutes',
query: 'histogram_quantile(0.99, rate(http_request_duration_seconds_bucket[5m])) > 0.5',
evaluationInterval: Duration.seconds(60),
pendingPeriod: Duration.seconds(300),
recoveryPeriod: Duration.seconds(600),
});
Initializer
new PromQLAlarm(scope: Construct, id: string, props: PromQLAlarmProps)
Parameters
- scope
Construct - id
string - props
PromQLAlarm Props
Construct Props
| Name | Type | Description |
|---|---|---|
| evaluation | Duration | The frequency at which the alarm is evaluated. |
| query | string | The PromQL query that the alarm evaluates. |
| actions | boolean | Whether the actions for this alarm are enabled. |
| alarm | string | Description for the alarm. |
| alarm | string | Name of the alarm. |
| pending | Duration | The duration that a contributor must continuously breach before the contributor transitions to ALARM state. |
| recovery | Duration | The duration that a contributor must continuously not be breaching before it transitions back to the OK state. |
evaluationInterval
Type:
Duration
The frequency at which the alarm is evaluated.
Must be between 10 seconds and 3600 seconds.
query
Type:
string
The PromQL query that the alarm evaluates.
actionsEnabled?
Type:
boolean
(optional, default: true)
Whether the actions for this alarm are enabled.
alarmDescription?
Type:
string
(optional, default: No description)
Description for the alarm.
alarmName?
Type:
string
(optional, default: Automatically generated name)
Name of the alarm.
pendingPeriod?
Type:
Duration
(optional, default: No pending period)
The duration that a contributor must continuously breach before the contributor transitions to ALARM state.
recoveryPeriod?
Type:
Duration
(optional, default: No recovery period)
The duration that a contributor must continuously not be breaching before it transitions back to the OK state.
Properties
| Name | Type | Description |
|---|---|---|
| alarm | string | ARN of this alarm. |
| alarm | string | Name of this alarm. |
| alarm | Alarm | A reference to a Alarm resource. |
| env | Resource | The environment this resource belongs to. |
| node | Node | The tree node. |
| stack | Stack | The stack in which this resource is defined. |
| static PROPERTY_INJECTION_ID | string | Uniquely identifies this class. |
alarmArn
Type:
string
ARN of this alarm.
alarmName
Type:
string
Name of this alarm.
alarmRef
Type:
Alarm
A reference to a Alarm resource.
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed in a Stack (those created by
creating new class instances like new Role(), new Bucket(), etc.), this
is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like
Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be
different than the stack they were imported into.
node
Type:
Node
The tree node.
stack
Type:
Stack
The stack in which this resource is defined.
static PROPERTY_INJECTION_ID
Type:
string
Uniquely identifies this class.
Methods
| Name | Description |
|---|---|
| add | Trigger this action if the alarm fires. |
| add | Trigger this action if there is insufficient data to evaluate the alarm. |
| add | Trigger this action if the alarm returns from breaching state into ok state. |
| apply | Apply the given removal policy to this resource. |
| render | AlarmRule indicating ALARM state for Alarm. |
| to | Returns a string representation of this construct. |
| with(...mixins) | Applies one or more mixins to this construct. |
| static from | Import an existing CloudWatch alarm provided an ARN. |
| static from | Import an existing CloudWatch alarm provided a Name. |
addAlarmAction(...actions)
public addAlarmAction(...actions: IAlarmAction[]): void
Parameters
- actions
IAlarmAction
Trigger this action if the alarm fires.
Typically SnsAction or AutoScalingAction.
addInsufficientDataAction(...actions)
public addInsufficientDataAction(...actions: IAlarmAction[]): void
Parameters
- actions
IAlarmAction
Trigger this action if there is insufficient data to evaluate the alarm.
Typically SnsAction or AutoScalingAction.
addOkAction(...actions)
public addOkAction(...actions: IAlarmAction[]): void
Parameters
- actions
IAlarmAction
Trigger this action if the alarm returns from breaching state into ok state.
Typically SnsAction or AutoScalingAction.
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
RemovalPolicy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN).
renderAlarmRule()
public renderAlarmRule(): string
Returns
string
AlarmRule indicating ALARM state for Alarm.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
with(...mixins)
public with(...mixins: IMixin[]): IConstruct
Parameters
- mixins
IMixin
Returns
Applies one or more mixins to this construct.
Mixins are applied in order. The list of constructs is captured at the
start of the call, so constructs added by a mixin will not be visited.
Use multiple with() calls if subsequent mixins should apply to added
constructs.
static fromPromQLAlarmArn(scope, id, alarmArn)
public static fromPromQLAlarmArn(scope: Construct, id: string, alarmArn: string): IAlarm
Parameters
- scope
Construct - id
string - alarmArn
string
Returns
Import an existing CloudWatch alarm provided an ARN.
static fromPromQLAlarmName(scope, id, alarmName)
public static fromPromQLAlarmName(scope: Construct, id: string, alarmName: string): IAlarm
Parameters
- scope
Construct - id
string - alarmName
string
Returns
Import an existing CloudWatch alarm provided a Name.

.NET
Go
Java
Python
TypeScript (