- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
ListLogGroupsForQueryCommand
Returns a list of the log groups that were analyzed during a single CloudWatch Logs Insights query. This can be useful for queries that use log group name prefixes or the filterIndex
command, because the log groups are dynamically selected in these cases.
For more information about field indexes, see Create field indexes to improve query performance and reduce costs .
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { CloudWatchLogsClient, ListLogGroupsForQueryCommand } from "@aws-sdk/client-cloudwatch-logs"; // ES Modules import
// const { CloudWatchLogsClient, ListLogGroupsForQueryCommand } = require("@aws-sdk/client-cloudwatch-logs"); // CommonJS import
const client = new CloudWatchLogsClient(config);
const input = { // ListLogGroupsForQueryRequest
queryId: "STRING_VALUE", // required
nextToken: "STRING_VALUE",
maxResults: Number("int"),
};
const command = new ListLogGroupsForQueryCommand(input);
const response = await client.send(command);
// { // ListLogGroupsForQueryResponse
// logGroupIdentifiers: [ // LogGroupIdentifiers
// "STRING_VALUE",
// ],
// nextToken: "STRING_VALUE",
// };
ListLogGroupsForQueryCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
queryId Required | string | undefined | The ID of the query to use. This query ID is from the response to your StartQuery operation. |
maxResults | number | undefined | Limits the number of returned log groups to the specified number. |
nextToken | string | undefined | The token for the next set of items to return. The token expires after 24 hours. |
ListLogGroupsForQueryCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
logGroupIdentifiers | string[] | undefined | An array of the names and ARNs of the log groups that were processed in the query. |
nextToken | string | undefined | The token for the next set of items to return. The token expires after 24 hours. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
AccessDeniedException | client | You don't have sufficient permissions to perform this action. |
InvalidParameterException | client | A parameter is specified incorrectly. |
ResourceNotFoundException | client | The specified resource does not exist. |
ServiceUnavailableException | server | The service cannot complete the request. |
CloudWatchLogsServiceException | Base exception class for all service exceptions from CloudWatchLogs service. |