{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/amazon-managed-prometheus/json-schema/amazon-managed-prometheus-create-anomaly-detector-request-schema.json",
  "title": "CreateAnomalyDetectorRequest",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/amazon-managed-prometheus-anomalydetectors-api-openapi.yml#/components/schemas/CreateAnomalyDetectorRequest",
  "type": "object",
  "properties": {
    "workspaceId": {
      "type": "string",
      "description": "The identifier of the workspace where the anomaly detector will be created."
    },
    "alias": {
      "type": "string",
      "description": "A user-friendly name for the anomaly detector."
    },
    "evaluationIntervalInSeconds": {
      "type": "integer",
      "description": "The frequency, in seconds, at which the anomaly detector evaluates metrics. The default value is 60 seconds."
    },
    "missingDataAction": {
      "$ref": "#/$defs/AnomalyDetectorMissingDataAction"
    },
    "configuration": {
      "$ref": "#/$defs/AnomalyDetectorConfiguration"
    },
    "labels": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      },
      "description": "The Amazon Managed Service for Prometheus metric labels to associate with the anomaly detector."
    },
    "clientToken": {
      "type": "string",
      "description": "A unique, case-sensitive identifier that you provide to ensure the idempotency of the request."
    },
    "tags": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      },
      "description": "The metadata to apply to the anomaly detector to assist with categorization and organization."
    }
  },
  "required": [
    "workspaceId",
    "alias",
    "configuration"
  ],
  "$defs": {
    "AnomalyDetectorConfiguration": {
      "type": "object",
      "properties": {
        "randomCutForest": {
          "$ref": "#/$defs/RandomCutForestConfiguration"
        }
      },
      "description": "Exactly one member is set."
    },
    "AnomalyDetectorMissingDataAction": {
      "type": "object",
      "properties": {
        "markAsAnomaly": {
          "type": "boolean",
          "description": "Marks missing data points as anomalies."
        },
        "skip": {
          "type": "boolean",
          "description": "Skips evaluation when data is missing."
        }
      },
      "description": "Exactly one member is set."
    },
    "IgnoreNearExpected": {
      "type": "object",
      "properties": {
        "amount": {
          "type": "number",
          "description": "The absolute amount by which values can differ from expected values before being considered anomalous."
        },
        "ratio": {
          "type": "number",
          "description": "The ratio by which values can differ from expected values before being considered anomalous."
        }
      },
      "description": "Exactly one member is set."
    },
    "RandomCutForestConfiguration": {
      "type": "object",
      "properties": {
        "query": {
          "type": "string",
          "description": "The Prometheus query used to retrieve the time-series data for anomaly detection. Random Cut Forest queries must be wrapped by a supported PromQL aggregation operator. For more information, see Aggregation operators on the Prometheus docs website. Supported PromQL aggregation operators: avg, count, group, max, min, quantile, stddev, stdvar, and sum."
        },
        "shingleSize": {
          "type": "integer",
          "description": "The number of consecutive data points used to create a shingle for the Random Cut Forest algorithm. The default number is 8 consecutive data points."
        },
        "sampleSize": {
          "type": "integer",
          "description": "The number of data points sampled from the input stream for the Random Cut Forest algorithm. The default number is 256 consecutive data points."
        },
        "ignoreNearExpectedFromAbove": {
          "$ref": "#/$defs/IgnoreNearExpected"
        },
        "ignoreNearExpectedFromBelow": {
          "$ref": "#/$defs/IgnoreNearExpected"
        }
      },
      "required": [
        "query"
      ]
    }
  }
}