Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cloudwatch): CompositeAlarm #8498

Merged
merged 6 commits into from
Jun 22, 2020

Conversation

SeekerWing
Copy link
Contributor


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't had a look in detail, will do that Soon(tm) (promise), but first impressions.

I really like where this is going, with some caveats:

  • alarm1.toAlarmRule(AlarmState.ALARM): I'd prefer it if you could just write alarm1 here (compound ALARM states seem like they will be the 99% case of uses, why not optimize for it?)

You can do this by making IAlarm extend IAlarmRule.

  • new OrAlarmRule(), new AndAlarmRule(): technically, yeah, of course. But I think I'd prefer more discoverable static factory functions instead (friendlier to autocomplete).

Spitballing some alternative syntax here:

new CompositeAlarm(this, 'ComplicatedAlarmCondition', {
  alarmRule: AlarmRule.someOf(
    AlarmRule.allOf(
      alarm1,
      AlarmRule.fromAlarm(alarm2, AlarmState.OK),
      alarm3),
    AlarmRule.not(AlarmRule.fromAlarm(alarm4, AlarmState.INSUFFICIENT_DATA)),
    AlarmRule.fromBoolean(false),
  ),
});

What do you think?

Not entirely sure I'm in love with the AlarmRule.fromAlarm(alarm, STATE) either, but at least it's consistent. I can see the following alternatives:

1. alarm.toAlarmRule(AlarmState.OK)
2. AlarmRule.fromAlarm(alarm, AlarmState.OK)
3. AlarmRule.fromAlarmOk(alarm)

@rix0rrr
Copy link
Contributor

rix0rrr commented Jun 11, 2020

Probably also AlarmRule.fromString("LITERAL STRING HERE"). I'm starting to value escape hatch mechanisms more and more the more feature requests we get 🤣

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: cdf9431
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@SeekerWing
Copy link
Contributor Author

I'd prefer it if you could just write alarm1 here

i completely agree, i was unhappy about how that looked too. this is unnecessary verbosity. i think having Alarm implement the IAlarmRule interface will get the necessary brevity.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 471ccd5
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@SeekerWing SeekerWing requested a review from rix0rrr June 12, 2020 13:31
packages/@aws-cdk/aws-cloudwatch/lib/alarm.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-cloudwatch/README.md Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-cloudwatch/lib/alarm.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-cloudwatch/lib/alarm.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-cloudwatch/lib/alarm.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-cloudwatch/lib/composite-alarm.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-cloudwatch/lib/alarm.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-cloudwatch/lib/composite-alarm.ts Outdated Show resolved Hide resolved
@@ -99,7 +99,8 @@
"props-default-doc:@aws-cdk/aws-cloudwatch.MetricRenderingProperties.color",
"props-default-doc:@aws-cdk/aws-cloudwatch.MetricRenderingProperties.label",
"props-default-doc:@aws-cdk/aws-cloudwatch.MetricRenderingProperties.stat",
"duration-prop-type:@aws-cdk/aws-cloudwatch.MetricExpressionConfig.period"
"duration-prop-type:@aws-cdk/aws-cloudwatch.MetricExpressionConfig.period",
"resource-attribute:@aws-cdk/aws-cloudwatch.CompositeAlarm.compositeAlarmArn"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just solve the issue by putting @attribute in the docstring?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i tried, it didn't seem to work. it continued to complain about the missing attribute.

@SeekerWing SeekerWing requested a review from rix0rrr June 17, 2020 04:23
@rix0rrr
Copy link
Contributor

rix0rrr commented Jun 17, 2020

You closed a bunch of comments but I don't see a new revision. Missing push? :)

@mergify mergify bot dismissed rix0rrr’s stale review June 19, 2020 11:41

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 3ed0c0e
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 80cbc3b
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: bcc4252
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@rix0rrr rix0rrr changed the title feat(aws-cloudwatch): CompositeAlarm feat(cloudwatch): CompositeAlarm Jun 22, 2020
@mergify
Copy link
Contributor

mergify bot commented Jun 22, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 121cf5b
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Jun 22, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 1e6d293 into aws:master Jun 22, 2020
@SeekerWing SeekerWing deleted the composite_alarm_expression branch June 22, 2020 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Composite Alarm support on CDK
3 participants