How to use the @aws-cdk/aws-cloudwatch.Metric 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 duo-labs / cloudtrail-partitioner / lib / cloudtrail_partitioner-stack.js View on Github external
],
      actions: [
        "s3:GetBucketLocation",
        "s3:GetObject",
        "s3:ListBucket",
        "s3:ListBucketMultipartUploads",
        "s3:ListMultipartUploadParts",
        "s3:AbortMultipartUpload",
        "s3:CreateBucket",
        "s3:PutObject"
      ]
    }));

    // Create alarm for any errors
    const error_alarm =  new cloudwatch.Alarm(this, "error_alarm", {
      metric: new cloudwatch.Metric({
        namespace: 'cloudtrail_partitioner',
        metricName: "errors",
        statistic: "Sum"
      }),
      threshold: 0,
      evaluationPeriods: 1,
      datapointsToAlarm: 1,
      treatMissingData: cloudwatch.TreatMissingData.NOT_BREACHING,
      alarmDescription: "Detect errors",
      alarmName: "cloudtrail_partitioner_errors"
    });

    // Create SNS for alarms to be sent to
    const sns_topic = new sns.Topic(this, 'cloudtrail_partitioner_alarm', {
      displayName: 'cloudtrail_partitioner_alarm'
    });
github aws / aws-cdk / packages / @aws-cdk / aws-stepfunctions / lib / state-machine.ts View on Github external
public metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric {
        return new cloudwatch.Metric({
            namespace: 'AWS/States',
            metricName,
            dimensions: { StateMachineArn: this.stateMachineArn },
            statistic: 'sum',
            ...props
        });
    }
github aws / aws-cdk / packages / @aws-cdk / aws-stepfunctions / lib / activity.ts View on Github external
public metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric {
        return new cloudwatch.Metric({
            namespace: 'AWS/States',
            metricName,
            dimensions: { ActivityArn: this.activityArn },
            statistic: 'sum',
            ...props
        });
    }
github aws / aws-cdk / packages / @aws-cdk / aws-ec2 / lib / vpn.ts View on Github external
public static metricAll(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric {
    return new cloudwatch.Metric({
      namespace: 'AWS/VPN',
      metricName,
      ...props
    });
  }
github aws / aws-cdk / packages / @aws-cdk / aws-elasticloadbalancingv2 / lib / alb / application-load-balancer.ts View on Github external
public metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric {
    return new cloudwatch.Metric({
      namespace: 'AWS/ApplicationELB',
      metricName,
      dimensions: { LoadBalancer: this.loadBalancerFullName },
      ...props
    });
  }
github aws / aws-cdk / packages / @aws-cdk / aws-elasticloadbalancingv2 / lib / nlb / network-load-balancer.ts View on Github external
public metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric {
    return new cloudwatch.Metric({
      namespace: 'AWS/NetworkELB',
      metricName,
      dimensions: { LoadBalancer: this.loadBalancerFullName },
      ...props
    });
  }
github aws / aws-cdk / packages / @aws-cdk / aws-logs / lib / log-group.ts View on Github external
public extractMetric(jsonField: string, metricNamespace: string, metricName: string) {
    new MetricFilter(this, `${metricNamespace}_${metricName}`, {
      logGroup: this,
      metricNamespace,
      metricName,
      filterPattern: FilterPattern.exists(jsonField),
      metricValue: jsonField
    });

    return new cloudwatch.Metric({ metricName, namespace: metricNamespace });
  }
github aws / aws-cdk / packages / @aws-cdk / aws-ecs / lib / cluster.ts View on Github external
public metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric {
    return new cloudwatch.Metric({
      namespace: 'AWS/ECS',
      metricName,
      dimensions: { ClusterName: this.clusterName },
      ...props
    });
  }
}