# CfnAnomalyDetectorProps

Properties for defining a `CfnAnomalyDetector`.

Used as props by: [CfnAnomalyDetector](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_aps.CfnAnomalyDetector.html)

- Source: Generated at build time
- Type last changed: v2.221.0 · 24 Oct 2025

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_aps as aps } from 'aws-cdk-lib';
const cfnAnomalyDetectorProps: aps.CfnAnomalyDetectorProps = {
  alias: 'alias',
  configuration: {
    randomCutForest: {
      query: 'query',

      // the properties below are optional
      ignoreNearExpectedFromAbove: {
        amount: 123,
        ratio: 123,
      },
      ignoreNearExpectedFromBelow: {
        amount: 123,
        ratio: 123,
      },
      sampleSize: 123,
      shingleSize: 123,
    },
  },
  workspace: 'workspace',

  // the properties below are optional
  evaluationIntervalInSeconds: 123,
  labels: [{
    key: 'key',
    value: 'value',
  }],
  missingDataAction: {
    markAsAnomaly: false,
    skip: false,
  },
  tags: [{
    key: 'key',
    value: 'value',
  }],
};
```

Python:

```python
from aws_cdk import CfnTag
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_aps as aps

cfn_anomaly_detector_props = aps.CfnAnomalyDetectorProps(
    alias="alias",
    configuration=aps.CfnAnomalyDetector.AnomalyDetectorConfigurationProperty(
        random_cut_forest=aps.CfnAnomalyDetector.RandomCutForestConfigurationProperty(
            query="query",

            # the properties below are optional
            ignore_near_expected_from_above=aps.CfnAnomalyDetector.IgnoreNearExpectedProperty(
                amount=123,
                ratio=123
            ),
            ignore_near_expected_from_below=aps.CfnAnomalyDetector.IgnoreNearExpectedProperty(
                amount=123,
                ratio=123
            ),
            sample_size=123,
            shingle_size=123
        )
    ),
    workspace="workspace",

    # the properties below are optional
    evaluation_interval_in_seconds=123,
    labels=[aps.CfnAnomalyDetector.LabelProperty(
        key="key",
        value="value"
    )],
    missing_data_action=aps.CfnAnomalyDetector.MissingDataActionProperty(
        mark_as_anomaly=False,
        skip=False
    ),
    tags=[CfnTag(
        key="key",
        value="value"
    )]
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.aps.*;

CfnAnomalyDetectorProps cfnAnomalyDetectorProps = CfnAnomalyDetectorProps.builder()
        .alias("alias")
        .configuration(AnomalyDetectorConfigurationProperty.builder()
                .randomCutForest(RandomCutForestConfigurationProperty.builder()
                        .query("query")

                        // the properties below are optional
                        .ignoreNearExpectedFromAbove(IgnoreNearExpectedProperty.builder()
                                .amount(123)
                                .ratio(123)
                                .build())
                        .ignoreNearExpectedFromBelow(IgnoreNearExpectedProperty.builder()
                                .amount(123)
                                .ratio(123)
                                .build())
                        .sampleSize(123)
                        .shingleSize(123)
                        .build())
                .build())
        .workspace("workspace")

        // the properties below are optional
        .evaluationIntervalInSeconds(123)
        .labels(List.of(LabelProperty.builder()
                .key("key")
                .value("value")
                .build()))
        .missingDataAction(MissingDataActionProperty.builder()
                .markAsAnomaly(false)
                .skip(false)
                .build())
        .tags(List.of(CfnTag.builder()
                .key("key")
                .value("value")
                .build()))
        .build();
```

C# / .NET:

```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.AWS.APS;

var cfnAnomalyDetectorProps = new CfnAnomalyDetectorProps {
    Alias = "alias",
    Configuration = new AnomalyDetectorConfigurationProperty {
        RandomCutForest = new RandomCutForestConfigurationProperty {
            Query = "query",

            // the properties below are optional
            IgnoreNearExpectedFromAbove = new IgnoreNearExpectedProperty {
                Amount = 123,
                Ratio = 123
            },
            IgnoreNearExpectedFromBelow = new IgnoreNearExpectedProperty {
                Amount = 123,
                Ratio = 123
            },
            SampleSize = 123,
            ShingleSize = 123
        }
    },
    Workspace = "workspace",

    // the properties below are optional
    EvaluationIntervalInSeconds = 123,
    Labels = new [] { new LabelProperty {
        Key = "key",
        Value = "value"
    } },
    MissingDataAction = new MissingDataActionProperty {
        MarkAsAnomaly = false,
        Skip = false
    },
    Tags = new [] { new CfnTag {
        Key = "key",
        Value = "value"
    } }
};
```

Golang:

```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 "github.com/aws/aws-cdk-go/awscdk"

cfnAnomalyDetectorProps := &CfnAnomalyDetectorProps{
	Alias: jsii.String("alias"),
	Configuration: &AnomalyDetectorConfigurationProperty{
		RandomCutForest: &RandomCutForestConfigurationProperty{
			Query: jsii.String("query"),

			// the properties below are optional
			IgnoreNearExpectedFromAbove: &IgnoreNearExpectedProperty{
				Amount: jsii.Number(123),
				Ratio: jsii.Number(123),
			},
			IgnoreNearExpectedFromBelow: &IgnoreNearExpectedProperty{
				Amount: jsii.Number(123),
				Ratio: jsii.Number(123),
			},
			SampleSize: jsii.Number(123),
			ShingleSize: jsii.Number(123),
		},
	},
	Workspace: jsii.String("workspace"),

	// the properties below are optional
	EvaluationIntervalInSeconds: jsii.Number(123),
	Labels: []interface{}{
		&LabelProperty{
			Key: jsii.String("key"),
			Value: jsii.String("value"),
		},
	},
	MissingDataAction: &MissingDataActionProperty{
		MarkAsAnomaly: jsii.Boolean(false),
		Skip: jsii.Boolean(false),
	},
	Tags: []CfnTag{
		&CfnTag{
			Key: jsii.String("key"),
			Value: jsii.String("value"),
		},
	},
}
```

## Properties

- `alias`: string (required) — The user-friendly name of the anomaly detector.

- `configuration`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnAnomalyDetector.AnomalyDetectorConfigurationProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_aps.CfnAnomalyDetector.AnomalyDetectorConfigurationProperty.html) (required) — The algorithm configuration of the anomaly detector.

- `evaluationIntervalInSeconds`: number = 60 — The frequency, in seconds, at which the anomaly detector evaluates metrics.

- `labels`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnAnomalyDetector.LabelProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_aps.CfnAnomalyDetector.LabelProperty.html)[] — The Amazon Managed Service for Prometheus metric labels associated with the anomaly detector.

- `missingDataAction`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnAnomalyDetector.MissingDataActionProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_aps.CfnAnomalyDetector.MissingDataActionProperty.html) — The action taken when data is missing during evaluation.

- `tags`: [CfnTag](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.CfnTag.html)[] — The tags applied to the anomaly detector.

- `workspace`: string (required) — An Amazon Managed Service for Prometheus workspace is a logical and isolated Prometheus server dedicated to ingesting, storing, and querying your Prometheus-compatible metrics.
