ListQueriesCommand

Returns a list of queries and query statuses for the past seven days. You must specify an ARN value for EventDataStore. Optionally, to shorten the list of results, you can specify a time range, formatted as timestamps, by adding StartTime and EndTime parameters, and a QueryStatus value. Valid values for QueryStatus include QUEUED, RUNNING, FINISHED, FAILED, TIMED_OUT, or CANCELLED.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { CloudTrailClient, ListQueriesCommand } from "@aws-sdk/client-cloudtrail"; // ES Modules import
// const { CloudTrailClient, ListQueriesCommand } = require("@aws-sdk/client-cloudtrail"); // CommonJS import
const client = new CloudTrailClient(config);
const input = { // ListQueriesRequest
  EventDataStore: "STRING_VALUE", // required
  NextToken: "STRING_VALUE",
  MaxResults: Number("int"),
  StartTime: new Date("TIMESTAMP"),
  EndTime: new Date("TIMESTAMP"),
  QueryStatus: "QUEUED" || "RUNNING" || "FINISHED" || "FAILED" || "CANCELLED" || "TIMED_OUT",
};
const command = new ListQueriesCommand(input);
const response = await client.send(command);
// { // ListQueriesResponse
//   Queries: [ // Queries
//     { // Query
//       QueryId: "STRING_VALUE",
//       QueryStatus: "QUEUED" || "RUNNING" || "FINISHED" || "FAILED" || "CANCELLED" || "TIMED_OUT",
//       CreationTime: new Date("TIMESTAMP"),
//     },
//   ],
//   NextToken: "STRING_VALUE",
// };

ListQueriesCommand Input

See ListQueriesCommandInput for more details

Parameter
Type
Description
EventDataStore
Required
string | undefined

The ARN (or the ID suffix of the ARN) of an event data store on which queries were run.

EndTime
Date | undefined

Use with StartTime to bound a ListQueries request, and limit its results to only those queries run within a specified time period.

MaxResults
number | undefined

The maximum number of queries to show on a page.

NextToken
string | undefined

A token you can use to get the next page of results.

QueryStatus
QueryStatus | undefined

The status of queries that you want to return in results. Valid values for QueryStatus include QUEUED, RUNNING, FINISHED, FAILED, TIMED_OUT, or CANCELLED.

StartTime
Date | undefined

Use with EndTime to bound a ListQueries request, and limit its results to only those queries run within a specified time period.

ListQueriesCommand Output

See ListQueriesCommandOutput for details

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
NextToken
string | undefined

A token you can use to get the next page of results.

Queries
Query[] | undefined

Lists matching query results, and shows query ID, status, and creation time of each query.

Throws

Name
Fault
Details
EventDataStoreARNInvalidException
client

The specified event data store ARN is not valid or does not map to an event data store in your account.

EventDataStoreNotFoundException
client

The specified event data store was not found.

InactiveEventDataStoreException
client

The event data store is inactive.

InvalidDateRangeException
client

A date range for the query was specified that is not valid. Be sure that the start time is chronologically before the end time. For more information about writing a query, see Create or edit a query  in the CloudTrail User Guide.

InvalidMaxResultsException
client

This exception is thrown if the limit specified is not valid.

InvalidNextTokenException
client

A token that is not valid, or a token that was previously used in a request with different parameters. This exception is thrown if the token is not valid.

InvalidParameterException
client

The request includes a parameter that is not valid.

InvalidQueryStatusException
client

The query status is not valid for the operation.

NoManagementAccountSLRExistsException
client

This exception is thrown when the management account does not have a service-linked role.

OperationNotPermittedException
client

This exception is thrown when the requested operation is not permitted.

UnsupportedOperationException
client

This exception is thrown when the requested operation is not supported.

CloudTrailServiceException
Base exception class for all service exceptions from CloudTrail service.