# DashboardVariable

Dashboard Variable.

Extends: DashboardVariable
Implements: IVariable

- Source: [`aws-cloudwatch/lib/variable.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-cloudwatch/lib/variable.ts#L230)
- Type last changed: v2.88.0 · 20 Jul 2023

## Example

```ts
import * as cw from 'aws-cdk-lib/aws-cloudwatch';

const dashboard = new cw.Dashboard(this, 'Dash', {
  defaultInterval: Duration.days(7),
  variables: [new cw.DashboardVariable({
    id: 'functionName',
    type: cw.VariableType.PATTERN,
    label: 'Function',
    inputType: cw.VariableInputType.RADIO,
    value: 'originalFuncNameInDashboard',
    // equivalent to cw.Values.fromSearch('{AWS/Lambda,FunctionName} MetricName=\"Duration\"', 'FunctionName')
    values: cw.Values.fromSearchComponents({
      namespace: 'AWS/Lambda',
      dimensions: ['FunctionName'],
      metricName: 'Duration',
      populateFrom: 'FunctionName',
    }),
    defaultValue: cw.DefaultValue.FIRST,
    visible: true,
  })],
});
```

## Initializer

```ts
new DashboardVariable(options: DashboardVariableOptions)
```

## Methods

- `toJson(): any` — Return the variable JSON for use in the dashboard.
