SearchComponents Struct
Search components for use with {@link Values.fromSearchComponents}.
| Source | aws-cloudwatch/lib/variable.ts |
|---|---|
| Type last changed |
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,
})],
});
python
import aws_cdk.aws_cloudwatch as cw
dashboard = cw.Dashboard(self, "Dash",
default_interval=Duration.days(7),
variables=[cw.DashboardVariable(
id="functionName",
type=cw.VariableType.PATTERN,
label="Function",
input_type=cw.VariableInputType.RADIO,
value="originalFuncNameInDashboard",
# equivalent to cw.Values.fromSearch('{AWS/Lambda,FunctionName} MetricName=\"Duration\"', 'FunctionName')
values=cw.Values.from_search_components(
namespace="AWS/Lambda",
dimensions=["FunctionName"],
metric_name="Duration",
populate_from="FunctionName"
),
default_value=cw.DefaultValue.FIRST,
visible=True
)]
)
java
import software.amazon.awscdk.services.cloudwatch.*;
Dashboard dashboard = Dashboard.Builder.create(this, "Dash")
.defaultInterval(Duration.days(7))
.variables(List.of(DashboardVariable.Builder.create()
.id("functionName")
.type(VariableType.PATTERN)
.label("Function")
.inputType(VariableInputType.RADIO)
.value("originalFuncNameInDashboard")
// equivalent to cw.Values.fromSearch('{AWS/Lambda,FunctionName} MetricName=\"Duration\"', 'FunctionName')
.values(Values.fromSearchComponents(SearchComponents.builder()
.namespace("AWS/Lambda")
.dimensions(List.of("FunctionName"))
.metricName("Duration")
.populateFrom("FunctionName")
.build()))
.defaultValue(DefaultValue.FIRST)
.visible(true)
.build()))
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.CloudWatch;
var dashboard = new Dashboard(this, "Dash", new DashboardProps {
DefaultInterval = Duration.Days(7),
Variables = new [] { new DashboardVariable(new DashboardVariableOptions {
Id = "functionName",
Type = VariableType.PATTERN,
Label = "Function",
InputType = VariableInputType.RADIO,
Value = "originalFuncNameInDashboard",
// equivalent to cw.Values.fromSearch('{AWS/Lambda,FunctionName} MetricName=\"Duration\"', 'FunctionName')
Values = Values.FromSearchComponents(new SearchComponents {
Namespace = "AWS/Lambda",
Dimensions = new [] { "FunctionName" },
MetricName = "Duration",
PopulateFrom = "FunctionName"
}),
DefaultValue = DefaultValue.FIRST,
Visible = true
}) }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"
dashboard := cw.NewDashboard(this, jsii.String("Dash"), &DashboardProps{
DefaultInterval: awscdk.Duration_Days(jsii.Number(7)),
Variables: []IVariable{
cw.NewDashboardVariable(&DashboardVariableOptions{
Id: jsii.String("functionName"),
Type: cw.VariableType_PATTERN,
Label: jsii.String("Function"),
InputType: cw.VariableInputType_RADIO,
Value: jsii.String("originalFuncNameInDashboard"),
// equivalent to cw.Values.fromSearch('{AWS/Lambda,FunctionName} MetricName=\"Duration\"', 'FunctionName')
Values: cw.Values_FromSearchComponents(&SearchComponents{
Namespace: jsii.String("AWS/Lambda"),
Dimensions: []*string{
jsii.String("FunctionName"),
},
MetricName: jsii.String("Duration"),
PopulateFrom: jsii.String("FunctionName"),
}),
DefaultValue: cw.DefaultValue_FIRST(),
Visible: jsii.Boolean(true),
}),
},
})
Properties
dimensionsstring[]dimensionstyping.List[str]dimensionsList<String>Dimensionsstring[]Dimensions*[]*string required #The list of dimensions to be used in the search expression.
The metric name to be used in the search expression.
The namespace to be used in the search expression.
populateFromstringpopulate_fromstrpopulateFromStringPopulateFromstringPopulateFrom*string required #The dimension name, that the search expression retrieves, whose values will be used to populate the values to choose from.