updateLogAnomalyDetector method

Future<void> updateLogAnomalyDetector({
  1. required String anomalyDetectorArn,
  2. required bool enabled,
  3. int? anomalyVisibilityTime,
  4. EvaluationFrequency? evaluationFrequency,
  5. String? filterPattern,
})

Updates an existing log anomaly detector.

May throw InvalidParameterException. May throw OperationAbortedException. May throw ResourceNotFoundException. May throw ServiceUnavailableException.

Parameter anomalyDetectorArn : The ARN of the anomaly detector that you want to update.

Parameter enabled : Use this parameter to pause or restart the anomaly detector.

Parameter anomalyVisibilityTime : The number of days to use as the life cycle of anomalies. After this time, anomalies are automatically baselined and the anomaly detector model will treat new occurrences of similar event as normal. Therefore, if you do not correct the cause of an anomaly during this time, it will be considered normal going forward and will not be detected.

Parameter evaluationFrequency : Specifies how often the anomaly detector runs and look for anomalies. Set this value according to the frequency that the log group receives new logs. For example, if the log group receives new log events every 10 minutes, then setting evaluationFrequency to FIFTEEN_MIN might be appropriate.

Implementation

Future<void> updateLogAnomalyDetector({
  required String anomalyDetectorArn,
  required bool enabled,
  int? anomalyVisibilityTime,
  EvaluationFrequency? evaluationFrequency,
  String? filterPattern,
}) async {
  _s.validateNumRange(
    'anomalyVisibilityTime',
    anomalyVisibilityTime,
    7,
    90,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'Logs_20140328.UpdateLogAnomalyDetector'
  };
  await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'anomalyDetectorArn': anomalyDetectorArn,
      'enabled': enabled,
      if (anomalyVisibilityTime != null)
        'anomalyVisibilityTime': anomalyVisibilityTime,
      if (evaluationFrequency != null)
        'evaluationFrequency': evaluationFrequency.value,
      if (filterPattern != null) 'filterPattern': filterPattern,
    },
  );
}