How to use the @aws-cdk/aws-cloudwatch.ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD function in @aws-cdk/aws-cloudwatch

To help you get started, we’ve selected a few @aws-cdk/aws-cloudwatch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eladb / cdk-watchful / lib / api-gateway.ts View on Github external
constructor(scope: Construct, id: string, props: WatchApiGatewayProps) {
    super(scope, id);

    this.api = props.restApi.node.findChild('Resource') as apigw.CfnRestApi;
    this.stage = props.restApi.deploymentStage.stageName;
    this.watchful = props.watchful;

    const alarmThreshold = props.serverErrorThreshold == null ? 1 : props.serverErrorThreshold;
    if (alarmThreshold) {
      this.watchful.addAlarm(
        this.createApiGatewayMetric(ApiGatewayMetric.FiveHundredError)
          .createAlarm(this, '5XXErrorAlarm', {
            alarmDescription: `at ${alarmThreshold}`,
            threshold: alarmThreshold,
            period: Duration.minutes(5),
            comparisonOperator: ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD,
            evaluationPeriods: 1,
            statistic: 'sum',
          })
      );
    }

    this.watchful.addSection(props.title, {
      links: [{ title: 'Amazon API Gateway Console', url: linkForApiGateway(props.restApi) }]
    });
    [undefined, ...props.watchedOperations || []].forEach(operation =>
      this.watchful.addWidgets(
        this.createCallGraphWidget(operation, alarmThreshold),
        ...props.cacheGraph ? [this.createCacheGraphWidget(operation)] : [],
        this.createLatencyGraphWidget(ApiGatewayMetric.Latency, operation),
        this.createLatencyGraphWidget(ApiGatewayMetric.IntegrationLatency, operation),
      )