createAnomalyDetector method

Future<CreateAnomalyDetectorResponse> createAnomalyDetector({
  1. required String alias,
  2. required AnomalyDetectorConfiguration configuration,
  3. required String workspaceId,
  4. String? clientToken,
  5. int? evaluationIntervalInSeconds,
  6. Map<String, String>? labels,
  7. AnomalyDetectorMissingDataAction? missingDataAction,
  8. Map<String, String>? tags,
})

Creates an anomaly detector within a workspace using the Random Cut Forest algorithm for time-series analysis. The anomaly detector analyzes Amazon Managed Service for Prometheus metrics to identify unusual patterns and behaviors.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter alias : A user-friendly name for the anomaly detector.

Parameter configuration : The algorithm configuration for the anomaly detector.

Parameter workspaceId : The identifier of the workspace where the anomaly detector will be created.

Parameter clientToken : A unique, case-sensitive identifier that you provide to ensure the idempotency of the request.

Parameter evaluationIntervalInSeconds : The frequency, in seconds, at which the anomaly detector evaluates metrics. The default value is 60 seconds.

Parameter labels : The Amazon Managed Service for Prometheus metric labels to associate with the anomaly detector.

Parameter missingDataAction : Specifies the action to take when data is missing during evaluation.

Parameter tags : The metadata to apply to the anomaly detector to assist with categorization and organization.

Implementation

Future<CreateAnomalyDetectorResponse> createAnomalyDetector({
  required String alias,
  required AnomalyDetectorConfiguration configuration,
  required String workspaceId,
  String? clientToken,
  int? evaluationIntervalInSeconds,
  Map<String, String>? labels,
  AnomalyDetectorMissingDataAction? missingDataAction,
  Map<String, String>? tags,
}) async {
  _s.validateNumRange(
    'evaluationIntervalInSeconds',
    evaluationIntervalInSeconds,
    30,
    86400,
  );
  final $payload = <String, dynamic>{
    'alias': alias,
    'configuration': configuration,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (evaluationIntervalInSeconds != null)
      'evaluationIntervalInSeconds': evaluationIntervalInSeconds,
    if (labels != null) 'labels': labels,
    if (missingDataAction != null) 'missingDataAction': missingDataAction,
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/workspaces/${Uri.encodeComponent(workspaceId)}/anomalydetectors',
    exceptionFnMap: _exceptionFns,
  );
  return CreateAnomalyDetectorResponse.fromJson(response);
}