Skip to content
v2.278.0

MetricConfig Struct ​

Properties of a rendered metric.

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',
  },
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_cloudwatch as cloudwatch

# metric: cloudwatch.Metric
# rendering_properties: Any
# value: Any

metric_config = cloudwatch.MetricConfig(
    math_expression=cloudwatch.MetricExpressionConfig(
        expression="expression",
        period=123,
        using_metrics={
            "using_metrics_key": metric
        },

        # the properties below are optional
        search_account="searchAccount",
        search_region="searchRegion"
    ),
    metric_stat=cloudwatch.MetricStatConfig(
        metric_name="metricName",
        namespace="namespace",
        period=cdk.Duration.minutes(30),
        statistic="statistic",

        # the properties below are optional
        account="account",
        account_override="accountOverride",
        dimensions=[cloudwatch.Dimension(
            name="name",
            value=value
        )],
        region="region",
        region_override="regionOverride",
        unit_filter=cloudwatch.Unit.SECONDS
    ),
    rendering_properties={
        "rendering_properties_key": rendering_properties
    },
    search_expression=cloudwatch.MetricExpressionConfig(
        expression="expression",
        period=123,
        using_metrics={
            "using_metrics_key": metric
        },

        # the properties below are optional
        search_account="searchAccount",
        search_region="searchRegion"
    )
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.cloudwatch.*;

Metric metric;
Object renderingProperties;
Object value;

MetricConfig metricConfig = MetricConfig.builder()
        .mathExpression(MetricExpressionConfig.builder()
                .expression("expression")
                .period(123)
                .usingMetrics(Map.of(
                        "usingMetricsKey", metric))

                // the properties below are optional
                .searchAccount("searchAccount")
                .searchRegion("searchRegion")
                .build())
        .metricStat(MetricStatConfig.builder()
                .metricName("metricName")
                .namespace("namespace")
                .period(Duration.minutes(30))
                .statistic("statistic")

                // the properties below are optional
                .account("account")
                .accountOverride("accountOverride")
                .dimensions(List.of(Dimension.builder()
                        .name("name")
                        .value(value)
                        .build()))
                .region("region")
                .regionOverride("regionOverride")
                .unitFilter(Unit.SECONDS)
                .build())
        .renderingProperties(Map.of(
                "renderingPropertiesKey", renderingProperties))
        .searchExpression(MetricExpressionConfig.builder()
                .expression("expression")
                .period(123)
                .usingMetrics(Map.of(
                        "usingMetricsKey", metric))

                // the properties below are optional
                .searchAccount("searchAccount")
                .searchRegion("searchRegion")
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.AWS.CloudWatch;

Metric metric;
var renderingProperties;
var value;

var metricConfig = new MetricConfig {
    MathExpression = new MetricExpressionConfig {
        Expression = "expression",
        Period = 123,
        UsingMetrics = new Dictionary<string, IMetric> {
            { "usingMetricsKey", metric }
        },

        // the properties below are optional
        SearchAccount = "searchAccount",
        SearchRegion = "searchRegion"
    },
    MetricStat = new MetricStatConfig {
        MetricName = "metricName",
        Namespace = "namespace",
        Period = Duration.Minutes(30),
        Statistic = "statistic",

        // the properties below are optional
        Account = "account",
        AccountOverride = "accountOverride",
        Dimensions = new [] { new Dimension {
            Name = "name",
            Value = value
        } },
        Region = "region",
        RegionOverride = "regionOverride",
        UnitFilter = Unit.SECONDS
    },
    RenderingProperties = new Dictionary<string, object> {
        { "renderingPropertiesKey", renderingProperties }
    },
    SearchExpression = new MetricExpressionConfig {
        Expression = "expression",
        Period = 123,
        UsingMetrics = new Dictionary<string, IMetric> {
            { "usingMetricsKey", metric }
        },

        // the properties below are optional
        SearchAccount = "searchAccount",
        SearchRegion = "searchRegion"
    }
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var metric Metric
var renderingProperties interface{}
var value interface{}

metricConfig := &MetricConfig{
	MathExpression: &MetricExpressionConfig{
		Expression: jsii.String("expression"),
		Period: jsii.Number(123),
		UsingMetrics: map[string]IMetric{
			"usingMetricsKey": metric,
		},

		// the properties below are optional
		SearchAccount: jsii.String("searchAccount"),
		SearchRegion: jsii.String("searchRegion"),
	},
	MetricStat: &MetricStatConfig{
		MetricName: jsii.String("metricName"),
		Namespace: jsii.String("namespace"),
		Period: cdk.Duration_Minutes(jsii.Number(30)),
		Statistic: jsii.String("statistic"),

		// the properties below are optional
		Account: jsii.String("account"),
		AccountOverride: jsii.String("accountOverride"),
		Dimensions: []Dimension{
			&Dimension{
				Name: jsii.String("name"),
				Value: value,
			},
		},
		Region: jsii.String("region"),
		RegionOverride: jsii.String("regionOverride"),
		UnitFilter: awscdk.Aws_cloudwatch.Unit_SECONDS,
	},
	RenderingProperties: map[string]interface{}{
		"renderingPropertiesKey": renderingProperties,
	},
	SearchExpression: &MetricExpressionConfig{
		Expression: jsii.String("expression"),
		Period: jsii.Number(123),
		UsingMetrics: map[string]IMetric{
			"usingMetricsKey": metric,
		},

		// the properties below are optional
		SearchAccount: jsii.String("searchAccount"),
		SearchRegion: jsii.String("searchRegion"),
	},
}

Properties ​

mathExpressionoptionalMetricExpressionConfigmath_expressionoptionalMetricExpressionConfigmathExpressionoptionalMetricExpressionConfigMathExpressionoptionalMetricExpressionConfigMathExpressionoptionalMetricExpressionConfig = None #
In case the metric is a math expression, the details of the math expression.
metricStatoptionalMetricStatConfigmetric_statoptionalMetricStatConfigmetricStatoptionalMetricStatConfigMetricStatoptionalMetricStatConfigMetricStatoptionalMetricStatConfig = None #
In case the metric represents a query, the details of the query.
renderingPropertiesoptional{ [key: string]: any }rendering_propertiesoptionaltyping.Mapping[str, Any]renderingPropertiesoptionalMap<String, Object>RenderingPropertiesoptionalIDictionary<string, object>RenderingPropertiesoptional*map[string]interface{} = 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.

searchExpressionoptionalMetricExpressionConfigsearch_expressionoptionalMetricExpressionConfigsearchExpressionoptionalMetricExpressionConfigSearchExpressionoptionalMetricExpressionConfigSearchExpressionoptionalMetricExpressionConfig = None #
In case the metric is a search expression, the details of the search expression.