# SearchComponents

Search components for use with {@link Values.fromSearchComponents}.

- Source: [`aws-cloudwatch/lib/variable.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-cloudwatch/lib/variable.ts#L60)
- 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,
  })],
});
```

## Properties

- `dimensions`: string[] (required) — The list of dimensions to be used in the search expression.

- `metricName`: string (required) — The metric name to be used in the search expression.

- `namespace`: string (required) — The namespace to be used in the search expression.

- `populateFrom`: string (required) — The dimension name, that the search expression retrieves, whose values will be used to populate the values to choose from.
