PromQLAlarm L2 construct
A CloudWatch Alarm based on a PromQL query expression.
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),
});
cloudwatch.PromQLAlarm(self, "HighLatencyAlarm",
alarm_description="P99 latency exceeds 500ms for 5 minutes",
query="histogram_quantile(0.99, rate(http_request_duration_seconds_bucket[5m])) > 0.5",
evaluation_interval=Duration.seconds(60),
pending_period=Duration.seconds(300),
recovery_period=Duration.seconds(600)
)
PromQLAlarm.Builder.create(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))
.build();
// Install: dotnet add package Amazon.CDK.Lib
new PromQLAlarm(this, "HighLatencyAlarm", new PromQLAlarmProps {
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)
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
cloudwatch.NewPromQLAlarm(this, jsii.String("HighLatencyAlarm"), &PromQLAlarmProps{
AlarmDescription: jsii.String("P99 latency exceeds 500ms for 5 minutes"),
Query: jsii.String("histogram_quantile(0.99, rate(http_request_duration_seconds_bucket[5m])) > 0.5"),
EvaluationInterval: awscdk.Duration_Seconds(jsii.Number(60)),
PendingPeriod: awscdk.Duration_*Seconds(jsii.Number(300)),
RecoveryPeriod: awscdk.Duration_*Seconds(jsii.Number(600)),
})
Initializer
new PromQLAlarm(scope: Construct, id: string, props: PromQLAlarmProps)
PromQLAlarm(scope: Construct, id: str, props: PromQLAlarmProps)
new PromQLAlarm(Construct scope, String id, PromQLAlarmProps props)
new PromQLAlarm(Construct scope, string id, PromQLAlarmProps props)
NewPromQLAlarm(Scope Construct, Id *string, Props PromQLAlarmProps)
Construct Props
actionsEnabledoptionalbooleanactions_enabledoptionalboolactionsEnabledoptionalBooleanActionsEnabledoptionalboolActionsEnabledoptional*bool= true#alarmDescriptionoptionalstringalarm_descriptionoptionalstralarmDescriptionoptionalStringAlarmDescriptionoptionalstringAlarmDescriptionoptional*string#Default: No description
alarmNameoptionalstringalarm_nameoptionalstralarmNameoptionalStringAlarmNameoptionalstringAlarmNameoptional*string#Default: Automatically generated name
evaluationIntervalDurationevaluation_intervalDurationevaluationIntervalDurationEvaluationIntervalDurationEvaluationIntervalDurationrequired#Must be between 10 seconds and 3600 seconds.
pendingPeriodoptionalDurationpending_periodoptionalDurationpendingPeriodoptionalDurationPendingPeriodoptionalDurationPendingPeriodoptionalDuration#Default: No pending period
Properties
alarmRefAlarmReferencealarm_refAlarmReferencealarmRefAlarmReferenceAlarmRefAlarmReferenceAlarmRefAlarmReference#envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironment#notes
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.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringstatic#Methods
addAlarmAction(...actions: IAlarmAction[]): voiddef add_alarm_action(self, actions: IAlarmAction) -> Nonepublic void addAlarmAction(IAlarmAction actions)public void AddAlarmAction(IAlarmAction actions)func AddAlarmAction(Actions IAlarmAction)#Typically SnsAction or AutoScalingAction.
addAlarmMuteRule(id: string, options: AlarmMuteRuleOptions): AlarmMuteRuledef add_alarm_mute_rule(self, id: str, options: AlarmMuteRuleOptions) -> AlarmMuteRulepublic AlarmMuteRule addAlarmMuteRule(String id, AlarmMuteRuleOptions options)public AlarmMuteRule AddAlarmMuteRule(string id, AlarmMuteRuleOptions options)func AddAlarmMuteRule(Id *string, Options AlarmMuteRuleOptions) AlarmMuteRule#addInsufficientDataAction(...actions: IAlarmAction[]): voiddef add_insufficient_data_action(self, actions: IAlarmAction) -> Nonepublic void addInsufficientDataAction(IAlarmAction actions)public void AddInsufficientDataAction(IAlarmAction actions)func AddInsufficientDataAction(Actions IAlarmAction)#Typically SnsAction or AutoScalingAction.
addOkAction(...actions: IAlarmAction[]): voiddef add_ok_action(self, actions: IAlarmAction) -> Nonepublic void addOkAction(IAlarmAction actions)public void AddOkAction(IAlarmAction actions)func AddOkAction(Actions IAlarmAction)#Typically SnsAction or AutoScalingAction.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#notes · 1 parameter
When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#notes
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).
fromPromQLAlarmArn(scope: Construct, id: string, alarmArn: string): IAlarm@staticmethod def from_prom_ql_alarm_arn(scope: Construct, id: str, alarm_arn: str) -> IAlarmpublic static IAlarm fromPromQLAlarmArn(Construct scope, String id, String alarmArn)public static IAlarm FromPromQLAlarmArn(Construct scope, string id, string alarmArn)func FromPromQLAlarmArn(Scope Construct, Id *string, AlarmArn *string) IAlarmstatic#fromPromQLAlarmName(scope: Construct, id: string, alarmName: string): IAlarm@staticmethod def from_prom_ql_alarm_name(scope: Construct, id: str, alarm_name: str) -> IAlarmpublic static IAlarm fromPromQLAlarmName(Construct scope, String id, String alarmName)public static IAlarm FromPromQLAlarmName(Construct scope, string id, string alarmName)func FromPromQLAlarmName(Scope Construct, Id *string, AlarmName *string) IAlarmstatic#isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#renderAlarmRule(): stringdef render_alarm_rule(self, ) -> strpublic String renderAlarmRule()public string RenderAlarmRule()func RenderAlarmRule() *string#toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#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.