Skip to content
v2.278.0

TreatMissingData Enum ​

Specify how missing data points are treated during alarm evaluation.

Example ​

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

const fn = new lambda.Function(this, 'MyFunction', {
   runtime: lambda.Runtime.NODEJS_LATEST,
   handler: 'index.handler',
   code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
   timeout: Duration.minutes(5),
});

if (fn.timeout) {
   new cloudwatch.Alarm(this, `MyAlarm`, {
      metric: fn.metricDuration().with({
         statistic: 'Maximum',
      }),
      evaluationPeriods: 1,
      datapointsToAlarm: 1,
      threshold: fn.timeout.toMilliseconds(),
      treatMissingData: cloudwatch.TreatMissingData.IGNORE,
      alarmName: 'My Lambda Timeout',
   });
}
python
import aws_cdk as cdk
import aws_cdk.aws_cloudwatch as cloudwatch


fn = lambda_.Function(self, "MyFunction",
    runtime=lambda_.Runtime.NODEJS_LATEST,
    handler="index.handler",
    code=lambda_.Code.from_asset(path.join(__dirname, "lambda-handler")),
    timeout=Duration.minutes(5)
)

if fn.timeout:
    cloudwatch.Alarm(self, "MyAlarm",
        metric=fn.metric_duration().with(
            statistic="Maximum"
        ),
        evaluation_periods=1,
        datapoints_to_alarm=1,
        threshold=fn.timeout.to_milliseconds(),
        treat_missing_data=cloudwatch.TreatMissingData.IGNORE,
        alarm_name="My Lambda Timeout"
    )
java
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.cloudwatch.*;


Function fn = Function.Builder.create(this, "MyFunction")
        .runtime(Runtime.NODEJS_LATEST)
        .handler("index.handler")
        .code(Code.fromAsset(join(__dirname, "lambda-handler")))
        .timeout(Duration.minutes(5))
        .build();

if (fn.getTimeout()) {
    Alarm.Builder.create(this, "MyAlarm")
            .metric(fn.metricDuration().with(MetricOptions.builder()
                    .statistic("Maximum")
                    .build()))
            .evaluationPeriods(1)
            .datapointsToAlarm(1)
            .threshold(fn.timeout.toMilliseconds())
            .treatMissingData(TreatMissingData.IGNORE)
            .alarmName("My Lambda Timeout")
            .build();
}
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK;
using Amazon.CDK.AWS.CloudWatch;


var fn = new Function(this, "MyFunction", new FunctionProps {
    Runtime = Runtime.NODEJS_LATEST,
    Handler = "index.handler",
    Code = Code.FromAsset(Join(__dirname, "lambda-handler")),
    Timeout = Duration.Minutes(5)
});

if (fn.Timeout)
{
    new Alarm(this, "MyAlarm", new AlarmProps {
        Metric = fn.MetricDuration().With(new MetricOptions {
            Statistic = "Maximum"
        }),
        EvaluationPeriods = 1,
        DatapointsToAlarm = 1,
        Threshold = fn.Timeout.ToMilliseconds(),
        TreatMissingData = TreatMissingData.IGNORE,
        AlarmName = "My Lambda Timeout"
    });
}
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import cdk "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"


fn := lambda.NewFunction(this, jsii.String("MyFunction"), &FunctionProps{
	Runtime: lambda.Runtime_NODEJS_LATEST(),
	Handler: jsii.String("index.handler"),
	Code: lambda.Code_FromAsset(path.join(__dirname, jsii.String("lambda-handler"))),
	Timeout: awscdk.Duration_Minutes(jsii.Number(5)),
})

if fn.Timeout {
	cloudwatch.NewAlarm(this, jsii.String("MyAlarm"), &AlarmProps{
		Metric: fn.metricDuration().With(&MetricOptions{
			Statistic: jsii.String("Maximum"),
		}),
		EvaluationPeriods: jsii.Number(1),
		DatapointsToAlarm: jsii.Number(1),
		Threshold: fn.*Timeout.ToMilliseconds(),
		TreatMissingData: cloudwatch.TreatMissingData_IGNORE,
		AlarmName: jsii.String("My Lambda Timeout"),
	})
}

Members ​

MemberDescription
BREACHINGMissing data points are treated as breaching the threshold.
NOT_BREACHINGMissing data points are treated as being within the threshold.
IGNOREThe current alarm state is maintained.
MISSINGThe alarm does not consider missing data points when evaluating whether to change state.

Referenced by ​