log_anomaly_detectors
Creates, updates, deletes, gets or lists a log_anomaly_detectors resource.
Overview
| Name | log_anomaly_detectors |
| Type | Resource |
| Id | aws.logs.log_anomaly_detectors |
Fields
The following fields are returned by SELECT queries:
- get_log_anomaly_detector
- list_log_anomaly_detectors
| Name | Datatype | Description |
|---|---|---|
anomaly_detector_status | string | Specifies whether the anomaly detector is currently active. To change its status, use the enabled parameter in the UpdateLogAnomalyDetector operation. (INITIALIZING, TRAINING, ANALYZING, FAILED, DELETED, PAUSED) |
anomaly_visibility_time | integer (int64) | The number of days used 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. |
creation_time_stamp | integer (int64) | The date and time when this anomaly detector was created. |
detector_name | string | The name of the log anomaly detector |
evaluation_frequency | string | 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. (ONE_MIN, FIVE_MIN, TEN_MIN, FIFTEEN_MIN, THIRTY_MIN, ONE_HOUR) |
filter_pattern | string | A symbolic description of how CloudWatch Logs should interpret the data in each log event. For example, a log event can contain timestamps, IP addresses, strings, and so on. You use the filter pattern to specify what to look for in the log event message. |
kms_key_id | string | The ARN of the KMS key assigned to this anomaly detector, if any. |
last_modified_time_stamp | integer (int64) | The date and time when this anomaly detector was most recently modified. |
log_group_arn_list | array | An array of structures, where each structure contains the ARN of a log group associated with this anomaly detector. |
| Name | Datatype | Description |
|---|---|---|
anomaly_detector_arn | string | The ARN of the anomaly detector. (pattern: <code>[\w#+=/:,.@-]*</code>) |
anomaly_detector_status | string | Specifies the current status of the anomaly detector. To pause an anomaly detector, use the enabled parameter in the UpdateLogAnomalyDetector operation. (INITIALIZING, TRAINING, ANALYZING, FAILED, DELETED, PAUSED) |
anomaly_visibility_time | integer (int64) | The number of days used 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. |
creation_time_stamp | integer (int64) | The date and time when this anomaly detector was created. |
detector_name | string | The name of the anomaly detector. |
evaluation_frequency | string | Specifies how often the anomaly detector runs and look for anomalies. (ONE_MIN, FIVE_MIN, TEN_MIN, FIFTEEN_MIN, THIRTY_MIN, ONE_HOUR) |
filter_pattern | string | A symbolic description of how CloudWatch Logs should interpret the data in each log event. For example, a log event can contain timestamps, IP addresses, strings, and so on. You use the filter pattern to specify what to look for in the log event message. |
kms_key_id | string | The ARN of the KMS key assigned to this anomaly detector, if any. |
last_modified_time_stamp | integer (int64) | The date and time when this anomaly detector was most recently modified. |
log_group_arn_list | array | A list of the ARNs of the log groups that this anomaly detector watches. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_log_anomaly_detector | select | region | Retrieves information about the log anomaly detector that you specify. The KMS key ARN detected is valid. | |
list_log_anomaly_detectors | select | region | Retrieves a list of the log anomaly detectors in the account. | |
create_log_anomaly_detector | insert | region, logGroupArnList | Creates an anomaly detector that regularly scans one or more log groups and look for patterns and anomalies in the logs. An anomaly detector can help surface issues by automatically discovering anomalies in your log event traffic. An anomaly detector uses machine learning algorithms to scan log events and find patterns. A pattern is a shared text structure that recurs among your log fields. Patterns provide a useful tool for analyzing large sets of logs because a large number of log events can often be compressed into a few patterns. The anomaly detector uses pattern recognition to find anomalies, which are unusual log events. It uses the evaluationFrequency to compare current log events and patterns with trained baselines. Fields within a pattern are called tokens. Fields that vary within a pattern, such as a request ID or timestamp, are referred to as dynamic tokens and represented by <>. The following is an example of a pattern: [INFO] Request time: <> ms This pattern represents log events like [INFO] Request time: 327 ms and other similar log events that differ only by the number, in this csse 327. When the pattern is displayed, the different numbers are replaced by <*> Any parts of log events that are masked as sensitive data are not scanned for anomalies. For more information about masking sensitive data, see Help protect sensitive log data with masking. | |
update_log_anomaly_detector | update | region, anomalyDetectorArn, enabled | Updates an existing log anomaly detector. | |
delete_log_anomaly_detector | delete | region | Deletes the specified CloudWatch Logs anomaly detector. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
region | string | AWS region (default: us-east-1) |
SELECT examples
- get_log_anomaly_detector
- list_log_anomaly_detectors
Retrieves information about the log anomaly detector that you specify. The KMS key ARN detected is valid.
SELECT
anomaly_detector_status,
anomaly_visibility_time,
creation_time_stamp,
detector_name,
evaluation_frequency,
filter_pattern,
kms_key_id,
last_modified_time_stamp,
log_group_arn_list
FROM aws.logs.log_anomaly_detectors
WHERE region = '{{ region }}' -- required
;
Retrieves a list of the log anomaly detectors in the account.
SELECT
anomaly_detector_arn,
anomaly_detector_status,
anomaly_visibility_time,
creation_time_stamp,
detector_name,
evaluation_frequency,
filter_pattern,
kms_key_id,
last_modified_time_stamp,
log_group_arn_list
FROM aws.logs.log_anomaly_detectors
WHERE region = '{{ region }}' -- required
;
INSERT examples
- create_log_anomaly_detector
- Manifest
Creates an anomaly detector that regularly scans one or more log groups and look for patterns and anomalies in the logs. An anomaly detector can help surface issues by automatically discovering anomalies in your log event traffic. An anomaly detector uses machine learning algorithms to scan log events and find patterns. A pattern is a shared text structure that recurs among your log fields. Patterns provide a useful tool for analyzing large sets of logs because a large number of log events can often be compressed into a few patterns. The anomaly detector uses pattern recognition to find anomalies, which are unusual log events. It uses the evaluationFrequency to compare current log events and patterns with trained baselines. Fields within a pattern are called tokens. Fields that vary within a pattern, such as a request ID or timestamp, are referred to as dynamic tokens and represented by <>. The following is an example of a pattern: [INFO] Request time: <> ms This pattern represents log events like [INFO] Request time: 327 ms and other similar log events that differ only by the number, in this csse 327. When the pattern is displayed, the different numbers are replaced by <*> Any parts of log events that are masked as sensitive data are not scanned for anomalies. For more information about masking sensitive data, see Help protect sensitive log data with masking.
INSERT INTO aws.logs.log_anomaly_detectors (
logGroupArnList,
detectorName,
evaluationFrequency,
filterPattern,
kmsKeyId,
anomalyVisibilityTime,
tags,
region
)
SELECT
'{{ logGroupArnList }}' /* required */,
'{{ detectorName }}',
'{{ evaluationFrequency }}',
'{{ filterPattern }}',
'{{ kmsKeyId }}',
{{ anomalyVisibilityTime }},
'{{ tags }}',
'{{ region }}'
RETURNING
anomaly_detector_arn
;
# Description fields are for documentation purposes
- name: log_anomaly_detectors
props:
- name: region
value: "{{ region }}"
description: Required parameter for the log_anomaly_detectors resource.
- name: logGroupArnList
value:
- "{{ logGroupArnList }}"
description: |
An array containing the ARN of the log group that this anomaly detector will watch. You can specify only one log group ARN.
- name: detectorName
value: "{{ detectorName }}"
description: |
A name for this anomaly detector.
- name: evaluationFrequency
value: "{{ evaluationFrequency }}"
description: |
Specifies how often the anomaly detector is to run 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 15 minutes might be a good setting for evaluationFrequency .
valid_values: ['ONE_MIN', 'FIVE_MIN', 'TEN_MIN', 'FIFTEEN_MIN', 'THIRTY_MIN', 'ONE_HOUR']
- name: filterPattern
value: "{{ filterPattern }}"
description: |
You can use this parameter to limit the anomaly detection model to examine only log events that match the pattern you specify here. For more information, see Filter and Pattern Syntax.
- name: kmsKeyId
value: "{{ kmsKeyId }}"
description: |
Optionally assigns a KMS key to secure this anomaly detector and its findings. If a key is assigned, the anomalies found and the model used by this detector are encrypted at rest with the key. If a key is assigned to an anomaly detector, a user must have permissions for both this key and for the anomaly detector to retrieve information about the anomalies that it finds. Make sure the value provided is a valid KMS key ARN. For more information about using a KMS key and to see the required IAM policy, see Use a KMS key with an anomaly detector.
- name: anomalyVisibilityTime
value: {{ anomalyVisibilityTime }}
description: |
The number of days to have visibility on an anomaly. After this time period has elapsed for an anomaly, it will be automatically baselined and the anomaly detector will treat new occurrences of a similar anomaly as normal. Therefore, if you do not correct the cause of an anomaly during the time period specified in anomalyVisibilityTime, it will be considered normal going forward and will not be detected as an anomaly.
- name: tags
value: "{{ tags }}"
description: |
An optional list of key-value pairs to associate with the resource. For more information about tagging, see Tagging Amazon Web Services resources
UPDATE examples
- update_log_anomaly_detector
Updates an existing log anomaly detector.
UPDATE aws.logs.log_anomaly_detectors
SET
anomalyDetectorArn = '{{ anomalyDetectorArn }}',
evaluationFrequency = '{{ evaluationFrequency }}',
filterPattern = '{{ filterPattern }}',
anomalyVisibilityTime = {{ anomalyVisibilityTime }},
enabled = {{ enabled }}
WHERE
region = '{{ region }}' --required
AND anomalyDetectorArn = '{{ anomalyDetectorArn }}' --required
AND enabled = {{ enabled }} --required;
DELETE examples
- delete_log_anomaly_detector
Deletes the specified CloudWatch Logs anomaly detector.
DELETE FROM aws.logs.log_anomaly_detectors
WHERE region = '{{ region }}' --required
;