putAnomalyDetector method
When you call PutAnomalyDetector, the operation creates a new
anomaly detector if one doesn't exist, or updates an existing one. Each
call to this operation triggers a complete retraining of the detector,
which includes querying the minimum required samples and backfilling the
detector with historical data. This process occurs regardless of whether
you're making a minor change like updating the evaluation interval or
making more substantial modifications. The operation serves as the single
method for creating, updating, and retraining anomaly detectors.
May throw AccessDeniedException.
May throw ConflictException.
May throw InternalServerException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter anomalyDetectorId :
The identifier of the anomaly detector to update.
Parameter configuration :
The algorithm configuration for the anomaly detector.
Parameter workspaceId :
The identifier of the workspace containing the anomaly detector to update.
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.
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.
Implementation
Future<PutAnomalyDetectorResponse> putAnomalyDetector({
required String anomalyDetectorId,
required AnomalyDetectorConfiguration configuration,
required String workspaceId,
String? clientToken,
int? evaluationIntervalInSeconds,
Map<String, String>? labels,
AnomalyDetectorMissingDataAction? missingDataAction,
}) async {
_s.validateNumRange(
'evaluationIntervalInSeconds',
evaluationIntervalInSeconds,
30,
86400,
);
final $payload = <String, dynamic>{
'configuration': configuration,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
if (evaluationIntervalInSeconds != null)
'evaluationIntervalInSeconds': evaluationIntervalInSeconds,
if (labels != null) 'labels': labels,
if (missingDataAction != null) 'missingDataAction': missingDataAction,
};
final response = await _protocol.send(
payload: $payload,
method: 'PUT',
requestUri:
'/workspaces/${Uri.encodeComponent(workspaceId)}/anomalydetectors/${Uri.encodeComponent(anomalyDetectorId)}',
exceptionFnMap: _exceptionFns,
);
return PutAnomalyDetectorResponse.fromJson(response);
}