Skip to content

Creates an anomaly detection model for a CloudWatch metric

Description

Creates an anomaly detection model for a CloudWatch metric. You can use the model to display a band of expected normal values when the metric is graphed.

If you have enabled unified cross-account observability, and this account is a monitoring account, the metric can be in the same account or a source account. You can specify the account ID in the object you specify in the SingleMetricAnomalyDetector parameter.

For more information, see CloudWatch Anomaly Detection.

Usage

cloudwatch_put_anomaly_detector(Namespace, MetricName, Dimensions, Stat,
  Configuration, MetricCharacteristics, SingleMetricAnomalyDetector,
  MetricMathAnomalyDetector)

Arguments

  • Namespace

    The namespace of the metric to create the anomaly detection model for.

  • MetricName

    The name of the metric to create the anomaly detection model for.

  • Dimensions

    The metric dimensions to create the anomaly detection model for.

  • Stat

    The statistic to use for the metric and the anomaly detection model.

  • Configuration

    The configuration specifies details about how the anomaly detection model is to be trained, including time ranges to exclude when training and updating the model. You can specify as many as 10 time ranges.

    The configuration can also include the time zone to use for the metric.

  • MetricCharacteristics

    Use this object to include parameters to provide information about your metric to CloudWatch to help it build more accurate anomaly detection models. Currently, it includes the PeriodicSpikes parameter.

  • SingleMetricAnomalyDetector

    A single metric anomaly detector to be created.

    When using SingleMetricAnomalyDetector, you cannot include the following parameters in the same operation:

    • Dimensions
    • MetricName
    • Namespace
    • Stat
    • the MetricMathAnomalyDetector parameters of PutAnomalyDetectorInput

    Instead, specify the single metric anomaly detector attributes as part of the property SingleMetricAnomalyDetector.

  • MetricMathAnomalyDetector

    The metric math anomaly detector to be created.

    When using MetricMathAnomalyDetector, you cannot include the following parameters in the same operation:

    • Dimensions
    • MetricName
    • Namespace
    • Stat
    • the SingleMetricAnomalyDetector parameters of PutAnomalyDetectorInput

    Instead, specify the metric math anomaly detector attributes as part of the property MetricMathAnomalyDetector.

Value

A list with the following syntax:

list(
  AnomalyDetectorId = "string"
)

Request syntax

svc$put_anomaly_detector(
  Namespace = "string",
  MetricName = "string",
  Dimensions = list(
    list(
      Name = "string",
      Value = "string"
    )
  ),
  Stat = "string",
  Configuration = list(
    ExcludedTimeRanges = list(
      list(
        StartTime = as.POSIXct(
          "2015-01-01"
        ),
        EndTime = as.POSIXct(
          "2015-01-01"
        )
      )
    ),
    MetricTimezone = "string"
  ),
  MetricCharacteristics = list(
    PeriodicSpikes = TRUE|FALSE
  ),
  SingleMetricAnomalyDetector = list(
    AccountId = "string",
    Namespace = "string",
    MetricName = "string",
    Dimensions = list(
      list(
        Name = "string",
        Value = "string"
      )
    ),
    Stat = "string"
  ),
  MetricMathAnomalyDetector = list(
    MetricDataQueries = list(
      list(
        Id = "string",
        MetricStat = list(
          Metric = list(
            Namespace = "string",
            MetricName = "string",
            Dimensions = list(
              list(
                Name = "string",
                Value = "string"
              )
            )
          ),
          Period = 123,
          Stat = "string",
          Unit = "Seconds"|"Microseconds"|"Milliseconds"|"Bytes"|"Kilobytes"|"Megabytes"|"Gigabytes"|"Terabytes"|"Bits"|"Kilobits"|"Megabits"|"Gigabits"|"Terabits"|"Percent"|"Count"|"Bytes/Second"|"Kilobytes/Second"|"Megabytes/Second"|"Gigabytes/Second"|"Terabytes/Second"|"Bits/Second"|"Kilobits/Second"|"Megabits/Second"|"Gigabits/Second"|"Terabits/Second"|"Count/Second"|"None"
        ),
        Expression = "string",
        Label = "string",
        ReturnData = TRUE|FALSE,
        Period = 123,
        AccountId = "string"
      )
    )
  )
)