DescribeLogGroups
Returns information about log groups. 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.
Request Syntax
{
"accountIdentifiers": [ "string
" ],
"includeLinkedAccounts": boolean
,
"limit": number
,
"logGroupClass": "string
",
"logGroupIdentifiers": [ "string
" ],
"logGroupNamePattern": "string
",
"logGroupNamePrefix": "string
",
"nextToken": "string
"
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
- accountIdentifiers
-
When
includeLinkedAccounts
is set totrue
, use this parameter to specify the list of accounts to search. You can specify as many as 20 account IDs in the array.Type: Array of strings
Array Members: Minimum number of 0 items. Maximum number of 20 items.
Length Constraints: Fixed length of 12.
Pattern:
^\d{12}$
Required: No
- includeLinkedAccounts
-
If you are using a monitoring account, set this to
true
to have the operation return log groups in the accounts listed inaccountIdentifiers
.If this parameter is set to
true
andaccountIdentifiers
contains a null value, the operation returns all log groups in the monitoring account and all log groups in all source accounts that are linked to the monitoring account.The default for this parameter is
false
.Type: Boolean
Required: No
- limit
-
The maximum number of items returned. If you don't specify a value, the default is up to 50 items.
Type: Integer
Valid Range: Minimum value of 1. Maximum value of 50.
Required: No
- logGroupClass
-
Use this parameter to limit the results to only those log groups in the specified log group class. If you omit this parameter, log groups of all classes can be returned.
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 AWS 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 each class, see Log classes
Type: String
Valid Values:
STANDARD | INFREQUENT_ACCESS | DELIVERY
Required: No
-
- logGroupIdentifiers
-
Use this array to filter the list of log groups returned. If you specify this parameter, the only other filter that you can choose to specify is
includeLinkedAccounts
.If you are using this operation in a monitoring account, you can specify the ARNs of log groups in source accounts and in the monitoring account itself. If you are using this operation in an account that is not a cross-account monitoring account, you can specify only log group names in the same account as the operation.
Type: Array of strings
Array Members: Minimum number of 1 item. Maximum number of 50 items.
Length Constraints: Minimum length of 1. Maximum length of 2048.
Pattern:
[\w#+=/:,.@-]*
Required: No
- logGroupNamePattern
-
If you specify a string for this parameter, the operation returns only log groups that have names that match the string based on a case-sensitive substring search. For example, if you specify
Foo
, log groups namedFooBar
,aws/Foo
, andGroupFoo
would match, butfoo
,F/o/o
andFroo
would not match.If you specify
logGroupNamePattern
in your request, then onlyarn
,creationTime
, andlogGroupName
are included in the response.Note
logGroupNamePattern
andlogGroupNamePrefix
are mutually exclusive. Only one of these parameters can be passed.Type: String
Length Constraints: Minimum length of 0. Maximum length of 512.
Pattern:
[\.\-_/#A-Za-z0-9]*
Required: No
- logGroupNamePrefix
-
The prefix to match.
Note
logGroupNamePrefix
andlogGroupNamePattern
are mutually exclusive. Only one of these parameters can be passed.Type: String
Length Constraints: Minimum length of 1. Maximum length of 512.
Pattern:
[\.\-_/#A-Za-z0-9]+
Required: No
- nextToken
-
The token for the next set of items to return. (You received this token from a previous call.)
Type: String
Length Constraints: Minimum length of 1.
Required: No
Response Syntax
{
"logGroups": [
{
"arn": "string",
"creationTime": number,
"dataProtectionStatus": "string",
"inheritedProperties": [ "string" ],
"kmsKeyId": "string",
"logGroupArn": "string",
"logGroupClass": "string",
"logGroupName": "string",
"metricFilterCount": number,
"retentionInDays": number,
"storedBytes": number
}
],
"nextToken": "string"
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
Errors
For information about the errors that are common to all actions, see Common Errors.
- InvalidParameterException
-
A parameter is specified incorrectly.
HTTP Status Code: 400
- ServiceUnavailableException
-
The service cannot complete the request.
HTTP Status Code: 500
Examples
To list all log groups
The following example lists all your log groups.
Sample Request
POST / HTTP/1.1
Host: logs.<region>.<domain>
X-Amz-Date: <DATE>
Authorization: AWS4-HMAC-SHA256 Credential=<Credential>, SignedHeaders=content-type;date;host;user-agent;x-amz-date;x-amz-target;x-amzn-requestid, Signature=<Signature>
User-Agent: <UserAgentString>
Accept: application/json
Content-Type: application/x-amz-json-1.1
Content-Length: <PayloadSizeBytes>
Connection: Keep-Alive
X-Amz-Target: Logs_20140328.DescribeLogGroups
Sample Response
HTTP/1.1 200 OK
x-amzn-RequestId: <RequestId>
Content-Type: application/x-amz-json-1.1
Content-Length: <PayloadSizeBytes>
Date: <Date>
{
"logGroups": [
{
"storageBytes": 1048576,
"arn": "arn:aws:logs:us-east-1:123456789012:log-group:my-log-group-1:*",
"creationTime": 1393545600000,
"logGroupName": "my-log-group-1",
"metricFilterCount": 0,
"retentionInDays": 14,
"kmsKeyId": "arn:aws:kms:us-east-1:123456789012:key/abcd1234-a123-456a-a12b-a123b4cd56ef"
},
{
"storageBytes": 5242880,
"arn": "arn:aws:logs:us-east-1:123456789012:log-group:my-log-group-2:*",
"creationTime": 1396224000000,
"logGroupName": "my-log-group-2",
"metricFilterCount": 0,
"retentionInDays": 30
}
]
}
To list all of the log groups in a monitoring account and all linked source accounts that have logGroup in their name
The following example lists all of the log groups in a monitoring account and all
linked source accounts that have logGroup
in their name.
Sample Request
{
"includeLinkedAccounts" : "true",
"logGroupNamePattern": "logGroup"
}
Sample Response
{
"logGroups": [
{
"arn": "arn:aws:logs:us-east-1:123456789012:log-group:monitoring-logGroup-1234:*",
"creationTime": 1393545600000,
"logGroupName": "monitoring-logGroup-1234"
},
{
"arn": "arn:aws:logs:us-east-1:012345678901:log-group:source-loggroup-5678:*",
"creationTime": 1396224000000,
"logGroupName": "source-loggroup-5678"
}
]
}
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: