Skip to main content

log_groups

Creates, updates, deletes, gets or lists a log_groups resource.

Overview

Namelog_groups
TypeResource
Idaws.logs.log_groups

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
arnstringThe Amazon Resource Name (ARN) of the log group. This version of the ARN includes a trailing :* after the log group name. Use this version to refer to the ARN in IAM policies when specifying permissions for most API actions. The exception is when specifying permissions for TagResource, UntagResource, and ListTagsForResource. The permissions for those three actions require the ARN version that doesn't include a trailing :*.
bearer_token_authentication_enabledbooleanIndicates whether bearer token authentication is enabled for this log group. When enabled, bearer token authentication is allowed on operations until it is explicitly disabled.
creation_timeinteger (int64)The creation time of the log group, expressed as the number of milliseconds after Jan 1, 1970 00:00:00 UTC.
data_protection_statusstringDisplays whether this log group has a protection policy, or whether it had one in the past. For more information, see PutDataProtectionPolicy. (ACTIVATED, DELETED, ARCHIVED, DISABLED)
deletion_protection_enabledbooleanIndicates whether deletion protection is enabled for this log group. When enabled, deletion protection blocks all deletion operations until it is explicitly disabled.
inherited_propertiesarrayDisplays all the properties that this log group has inherited from account-level settings.
kms_key_idstringThe Amazon Resource Name (ARN) of the KMS key to use when encrypting log data.
log_group_arnstringThe Amazon Resource Name (ARN) of the log group. This version of the ARN doesn't include a trailing :* after the log group name. Use this version to refer to the ARN in the following situations: In the logGroupIdentifier input field in many CloudWatch Logs APIs. In the resourceArn field in tagging APIs In IAM policies, when specifying permissions for TagResource, UntagResource, and ListTagsForResource.
log_group_classstringThis specifies the log group class for this log group. There are three classes: The Standard log class supports all CloudWatch Logs features. The Infrequent Access log class supports a subset of CloudWatch Logs features and incurs lower costs. Use the Delivery log class only for delivering Lambda logs to store in Amazon S3 or Amazon Data Firehose. Log events in log groups in the Delivery class are kept in CloudWatch Logs for only one day. This log class doesn't offer rich CloudWatch Logs capabilities such as CloudWatch Logs Insights queries. For details about the features supported by the Standard and Infrequent Access classes, see Log classes (STANDARD, INFREQUENT_ACCESS, DELIVERY)
log_group_namestringThe name of the log group. (pattern: <code>[.-_/#A-Za-z0-9]+</code>)
metric_filter_countintegerThe number of metric filters.
retention_in_daysintegerThe number of days to retain the log events in the specified log group. Possible values are: 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1096, 1827, 2192, 2557, 2922, 3288, and 3653. To set a log group so that its log events do not expire, use DeleteRetentionPolicy.
stored_bytesinteger (int64)The number of bytes stored.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_log_groupsselectregionReturns information about log groups, including data sources that ingest into each log group. You can return all your log groups or filter the results by prefix. The results are ASCII-sorted by log group name. CloudWatch Logs doesn't support IAM policies that control access to the DescribeLogGroups action by using the aws:ResourceTag/key-name condition key. Other CloudWatch Logs actions do support the use of the aws:ResourceTag/key-name condition key to control access. For more information about using tags to control access, see Controlling access to Amazon Web Services resources using tags. If you are using CloudWatch cross-account observability, you can use this operation in a monitoring account and view data from the linked source accounts. For more information, see CloudWatch cross-account observability.
create_log_groupinsertregion, logGroupNameCreates a log group with the specified name. You can create up to 1,000,000 log groups per Region per account. You must use the following guidelines when naming a log group: Log group names must be unique within a Region for an Amazon Web Services account. Log group names can be between 1 and 512 characters long. Log group names consist of the following characters: a-z, A-Z, 0-9, '_' (underscore), '-' (hyphen), '/' (forward slash), '.' (period), and '#' (number sign) Log group names can't start with the string aws/ When you create a log group, by default the log events in the log group do not expire. To set a retention policy so that events expire and are deleted after a specified time, use PutRetentionPolicy. If you associate an KMS key with the log group, ingested data is encrypted using the KMS key. This association is stored as long as the data encrypted with the KMS key is still within CloudWatch Logs. This enables CloudWatch Logs to decrypt this data whenever it is requested. If you attempt to associate a KMS key with the log group but the KMS key does not exist or the KMS key is disabled, you receive an InvalidParameterException error. CloudWatch Logs supports only symmetric KMS keys. Do not associate an asymmetric KMS key with your log group. For more information, see Using Symmetric and Asymmetric Keys.
put_bearer_token_authenticationreplaceregion, logGroupIdentifier, bearerTokenAuthenticationEnabledEnables or disables bearer token authentication for the specified log group. When enabled on a log group, bearer token authentication is enabled on operations until it is explicitly disabled. For information about the parameters that are common to all actions, see Common Parameters.
put_log_group_deletion_protectionreplaceregion, logGroupIdentifier, deletionProtectionEnabledEnables or disables deletion protection for the specified log group. When enabled on a log group, deletion protection blocks all deletion operations until it is explicitly disabled. For information about the parameters that are common to all actions, see Common Parameters.
put_retention_policyreplaceregion, logGroupName, retentionInDaysSets the retention of the specified log group. With a retention policy, you can configure the number of days for which to retain log events in the specified log group. CloudWatch Logs doesn't immediately delete log events when they reach their retention setting. It typically takes up to 72 hours after that before log events are deleted, but in rare situations might take longer. To illustrate, imagine that you change a log group to have a longer retention setting when it contains log events that are past the expiration date, but haven't been deleted. Those log events will take up to 72 hours to be deleted after the new retention date is reached. To make sure that log data is deleted permanently, keep a log group at its lower retention setting until 72 hours after the previous retention period ends. Alternatively, wait to change the retention setting until you confirm that the earlier log events are deleted. When log events reach their retention setting they are marked for deletion. After they are marked for deletion, they do not add to your archival storage costs anymore, even if they are not actually deleted until later. These log events marked for deletion are also not included when you use an API to retrieve the storedBytes value to see how many bytes a log group is storing.
delete_log_groupdeleteregionDeletes the specified log group and permanently deletes all the archived log events associated with the log group.
delete_retention_policyexecregion, logGroupNameDeletes the specified retention policy. Log events do not expire if they belong to log groups without a retention policy.
list_log_groupsexecregionReturns a list of log groups in the Region in your account. If you are performing this action in a monitoring account, you can choose to also return log groups from source accounts that are linked to the monitoring account. For more information about using cross-account observability to set up monitoring accounts and source accounts, see CloudWatch cross-account observability. You can optionally filter the results by log group class, log group name pattern, field indexes, data sources, field index names, or log group tags. If you specify more than one filter type, the results include log groups that satisfy all filters. This operation is paginated. By default, your first use of this operation returns 50 results, and includes a token to use in a subsequent operation to return more results.

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.

NameDatatypeDescription
regionstringAWS region (default: us-east-1)

SELECT examples

Returns information about log groups, including data sources that ingest into each log group. You can return all your log groups or filter the results by prefix. The results are ASCII-sorted by log group name. CloudWatch Logs doesn't support IAM policies that control access to the DescribeLogGroups action by using the aws:ResourceTag/key-name condition key. Other CloudWatch Logs actions do support the use of the aws:ResourceTag/key-name condition key to control access. For more information about using tags to control access, see Controlling access to Amazon Web Services resources using tags. If you are using CloudWatch cross-account observability, you can use this operation in a monitoring account and view data from the linked source accounts. For more information, see CloudWatch cross-account observability.

SELECT
arn,
bearer_token_authentication_enabled,
creation_time,
data_protection_status,
deletion_protection_enabled,
inherited_properties,
kms_key_id,
log_group_arn,
log_group_class,
log_group_name,
metric_filter_count,
retention_in_days,
stored_bytes
FROM aws.logs.log_groups
WHERE region = '{{ region }}' -- required
;

INSERT examples

Creates a log group with the specified name. You can create up to 1,000,000 log groups per Region per account. You must use the following guidelines when naming a log group: Log group names must be unique within a Region for an Amazon Web Services account. Log group names can be between 1 and 512 characters long. Log group names consist of the following characters: a-z, A-Z, 0-9, '_' (underscore), '-' (hyphen), '/' (forward slash), '.' (period), and '#' (number sign) Log group names can't start with the string aws/ When you create a log group, by default the log events in the log group do not expire. To set a retention policy so that events expire and are deleted after a specified time, use PutRetentionPolicy. If you associate an KMS key with the log group, ingested data is encrypted using the KMS key. This association is stored as long as the data encrypted with the KMS key is still within CloudWatch Logs. This enables CloudWatch Logs to decrypt this data whenever it is requested. If you attempt to associate a KMS key with the log group but the KMS key does not exist or the KMS key is disabled, you receive an InvalidParameterException error. CloudWatch Logs supports only symmetric KMS keys. Do not associate an asymmetric KMS key with your log group. For more information, see Using Symmetric and Asymmetric Keys.

INSERT INTO aws.logs.log_groups (
logGroupName,
kmsKeyId,
tags,
logGroupClass,
deletionProtectionEnabled,
region
)
SELECT
'{{ logGroupName }}' /* required */,
'{{ kmsKeyId }}',
'{{ tags }}',
'{{ logGroupClass }}',
{{ deletionProtectionEnabled }},
'{{ region }}'
;

REPLACE examples

Enables or disables bearer token authentication for the specified log group. When enabled on a log group, bearer token authentication is enabled on operations until it is explicitly disabled. For information about the parameters that are common to all actions, see Common Parameters.

REPLACE aws.logs.log_groups
SET
logGroupIdentifier = '{{ logGroupIdentifier }}',
bearerTokenAuthenticationEnabled = {{ bearerTokenAuthenticationEnabled }}
WHERE
region = '{{ region }}' --required
AND logGroupIdentifier = '{{ logGroupIdentifier }}' --required
AND bearerTokenAuthenticationEnabled = {{ bearerTokenAuthenticationEnabled }} --required;

DELETE examples

Deletes the specified log group and permanently deletes all the archived log events associated with the log group.

DELETE FROM aws.logs.log_groups
WHERE region = '{{ region }}' --required
;

Lifecycle Methods

Deletes the specified retention policy. Log events do not expire if they belong to log groups without a retention policy.

EXEC aws.logs.log_groups.delete_retention_policy
@region='{{ region }}' --required
@@json=
'{
"logGroupName": "{{ logGroupName }}"
}'
;