# MetricConfig

Properties of a rendered metric.

- Source: [`aws-cloudwatch/lib/metric-types.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-cloudwatch/lib/metric-types.ts#L239)
- Type last changed: v2.207.0 · 24 Jul 2025

## Example

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_cloudwatch as cloudwatch } from 'aws-cdk-lib';

declare const metric: cloudwatch.Metric;
declare const renderingProperties: any;
declare const value: any;
const metricConfig: cloudwatch.MetricConfig = {
  mathExpression: {
    expression: 'expression',
    period: 123,
    usingMetrics: {
      usingMetricsKey: metric,
    },

    // the properties below are optional
    searchAccount: 'searchAccount',
    searchRegion: 'searchRegion',
  },
  metricStat: {
    metricName: 'metricName',
    namespace: 'namespace',
    period: cdk.Duration.minutes(30),
    statistic: 'statistic',

    // the properties below are optional
    account: 'account',
    accountOverride: 'accountOverride',
    dimensions: [{
      name: 'name',
      value: value,
    }],
    region: 'region',
    regionOverride: 'regionOverride',
    unitFilter: cloudwatch.Unit.SECONDS,
  },
  renderingProperties: {
    renderingPropertiesKey: renderingProperties,
  },
  searchExpression: {
    expression: 'expression',
    period: 123,
    usingMetrics: {
      usingMetricsKey: metric,
    },

    // the properties below are optional
    searchAccount: 'searchAccount',
    searchRegion: 'searchRegion',
  },
};
```

## Properties

- `mathExpression`: [MetricExpressionConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.MetricExpressionConfig.html) = None — In case the metric is a math expression, the details of the math expression.

- `metricStat`: [MetricStatConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.MetricStatConfig.html) = None — In case the metric represents a query, the details of the query.

- `renderingProperties`: { [key: string]: any } = None — Additional properties which will be rendered if the metric is used in a dashboard.

  Examples are 'label' and 'color', but any key in here will be
  added to dashboard graphs.

- `searchExpression`: [MetricExpressionConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.MetricExpressionConfig.html) = None — In case the metric is a search expression, the details of the search expression.
