DashboardVariable

class aws_cdk.aws_cloudwatch.DashboardVariable(*, id, input_type, type, value, default_value=None, label=None, values=None, visible=None)

Bases: object

Dashboard Variable.

ExampleMetadata:

infused

Example:

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
    )]
)
Parameters:
  • id (str) – Unique id.

  • input_type (VariableInputType) – The way the variable value is selected.

  • type (VariableType) – Type of the variable.

  • value (str) – Pattern or property value to replace.

  • default_value (Optional[DefaultValue]) – Optional default value. Default: - no default value is set

  • label (Optional[str]) – Optional label in the toolbar. Default: - the variable’s value

  • values (Optional[Values]) – Optional values (required for {@link VariableInputType.RADIO} and {@link VariableInputType.SELECT} dashboard variables). Default: - no values

  • visible (Optional[bool]) – Whether the variable is visible. Default: - true

Methods

to_json()

Return the variable JSON for use in the dashboard.

Return type:

Any