# Unit

Unit for metric.

- Source: [`aws-cloudwatch/lib/metric-types.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-cloudwatch/lib/metric-types.ts#L99)

## Example

```ts
declare const logGroup: logs.LogGroup;
const mf = new logs.MetricFilter(this, 'MetricFilter', {
  logGroup,
  metricNamespace: 'MyApp',
  metricName: 'Latency',
  filterPattern: logs.FilterPattern.exists('$.latency'),
  metricValue: '$.latency',
  dimensions: {
    ErrorCode: '$.errorCode',
  },
  unit: cloudwatch.Unit.MILLISECONDS,
});

//expose a metric from the metric filter
const metric = mf.metric();

//you can use the metric to create a new alarm
new cloudwatch.Alarm(this, 'alarm from metric filter', {
  metric,
  threshold: 100,
  evaluationPeriods: 2,
});
```

## Members

| Member | Description |
| --- | --- |
| `SECONDS` | Seconds. |
| `MICROSECONDS` | Microseconds. |
| `MILLISECONDS` | Milliseconds. |
| `BYTES` | Bytes. |
| `KILOBYTES` | Kilobytes. |
| `MEGABYTES` | Megabytes. |
| `GIGABYTES` | Gigabytes. |
| `TERABYTES` | Terabytes. |
| `BITS` | Bits. |
| `KILOBITS` | Kilobits. |
| `MEGABITS` | Megabits. |
| `GIGABITS` | Gigabits. |
| `TERABITS` | Terabits. |
| `PERCENT` | Percent. |
| `COUNT` | Count. |
| `BYTES_PER_SECOND` | Bytes/second (B/s). |
| `KILOBYTES_PER_SECOND` | Kilobytes/second (kB/s). |
| `MEGABYTES_PER_SECOND` | Megabytes/second (MB/s). |
| `GIGABYTES_PER_SECOND` | Gigabytes/second (GB/s). |
| `TERABYTES_PER_SECOND` | Terabytes/second (TB/s). |
| `BITS_PER_SECOND` | Bits/second (b/s). |
| `KILOBITS_PER_SECOND` | Kilobits/second (kb/s). |
| `MEGABITS_PER_SECOND` | Megabits/second (Mb/s). |
| `GIGABITS_PER_SECOND` | Gigabits/second (Gb/s). |
| `TERABITS_PER_SECOND` | Terabits/second (Tb/s). |
| `COUNT_PER_SECOND` | Count/second. |
| `NONE` | None. |

## Referenced by

- [`CommonMetricOptions`](/v2/docs/aws-cdk-lib.aws_cloudwatch.CommonMetricOptions).unit
- [`Metric`](/v2/docs/aws-cdk-lib.aws_cloudwatch.Metric).unit
- [`MetricFilterOptions`](/v2/docs/aws-cdk-lib.aws_logs.MetricFilterOptions).unit
- [`MetricStatConfig`](/v2/docs/aws-cdk-lib.aws_cloudwatch.MetricStatConfig).unitFilter
