Metrics are the fundamental concept in CloudWatch. A metric represents a time-ordered set of data points that are published to CloudWatch. Think of a metric as a variable to monitor, and the data points as representing the values of that variable over time. For example, the CPU usage of a particular EC2 instance is one metric provided by Amazon EC2. The data points themselves can come from any application or business activity from which you collect data.

AWS services send metrics to CloudWatch, and you can send your own custom metrics to CloudWatch. You can add the data points in any order, and at any rate you choose. You can retrieve statistics about those data points as an ordered set of time-series data.

Metrics exist only in the region in which they are created. Metrics cannot be deleted, but they automatically expire after 15 months if no new data is published to them. Data points older than 15 months expire on a rolling basis; as new data points come in, data older than 15 months is dropped.

Metrics are uniquely defined by a name, a namespace, and zero or more dimensions. Each data point in a metric has a time stamp, and (optionally) a unit of measure. You can retrieve statistics from CloudWatch for any metric.

see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Metric for more details.

Constructors

  • Parameters

    • args: MetricArgs
    • Optional resource: any

      Optional resource this is a metric for. This is only used for parenting purposes. i.e. if an [Alarm] is created from this [Metric], then [resource] will be used as the parent of the alarm by default.

    Returns Metric

Properties

color: Output<undefined | string>

The six-digit HTML hex color code to be used for this metric.

Only used if this metric is displayed in a [Dashboard] with a [MetricWidget].

dimensions: any

The dimensions for this metric. For the list of available dimensions see the AWS documentation here.

extendedStatistic: Output<undefined | number>

The percentile statistic for the metric associated with the alarm. Specify a value between [0.0] and [100].

label: Output<undefined | string>

The label to display for this metric in the graph legend. If this is not specified, the metric is given an autogenerated label that distinguishes it from the other metrics in the widget.

Only used if this metric is displayed in a [Dashboard] with a [MetricWidget].

name: Output<string>

The name for this metric. See docs for supported metrics.

namespace: Output<string>

The namespace for this metric. See docs for the list of namespaces. See docs for supported metrics.

period: Output<number>

The period in seconds over which the specified [statistic] is applied. Must be in multiples of 60. Periods are defined in numbers of seconds, and valid values for period are 1, 5, 10, 30, or any multiple of 60. For example, to specify a period of six minutes, use 360 as the period value. You can adjust how the data is aggregated by varying the length of the period. A period can be as short as one second or as long as one day (86,400 seconds). The default value is 60 seconds.

See https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html for more details.

resource: any

Optional resource this is a metric for. Used only for parenting purposes when making new alarms.

statistic: Output<MetricStatistic>

The statistic to apply to the alarm's associated metric. Either of the following is supported: SampleCount, Average, Sum, Minimum, Maximum.

Defaults to [Average] if [statistic] and [extendedStatistic] is unspecified.

unit: Output<undefined | MetricUnit>
visible: Output<boolean>

Set this to true to have the metric appear in the graph, or false to have it be hidden. The default is true.

Only used if this metric is displayed in a [Dashboard] with a [MetricWidget].

yAxis: Output<"left" | "right">

Where on the graph to display the y-axis for this metric. The default is left.

Only used if this metric is displayed in a [Dashboard] with a [MetricWidget].

Methods

  • Produces a new [Metric] instances with the specific [dimensions] of this instance overwritten with the [dimensions] pass in as arguments. Because this is a merging, to unset a particular dimension, pass in an explicit value of { name: undefined }. To clear all dimensions, pass in undefined for the entire argument.

    Parameters

    • dimensions: any

    Returns Metric

Generated using TypeDoc