DescribeQueries - Amazon CloudWatch Logs
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

DescribeQueries

Returns a list of CloudWatch Logs Insights queries that are scheduled, running, or have been run recently in this account. You can request all queries or limit it to queries of a specific log group or queries with a certain status.

Request Syntax

{ "logGroupName": "string", "maxResults": number, "nextToken": "string", "status": "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.

logGroupName

Limits the returned queries to only those for the specified log group.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 512.

Pattern: [\.\-_/#A-Za-z0-9]+

Required: No

maxResults

Limits the number of returned queries to the specified number.

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 1000.

Required: No

nextToken

The token for the next set of items to return. The token expires after 24 hours.

Type: String

Length Constraints: Minimum length of 1.

Required: No

status

Limits the returned queries to only those that have the specified status. Valid values are Cancelled, Complete, Failed, Running, and Scheduled.

Type: String

Valid Values: Scheduled | Running | Complete | Failed | Cancelled | Timeout | Unknown

Required: No

Response Syntax

{ "nextToken": "string", "queries": [ { "createTime": number, "logGroupName": "string", "queryId": "string", "queryString": "string", "status": "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.

nextToken

The token for the next set of items to return. The token expires after 24 hours.

Type: String

Length Constraints: Minimum length of 1.

queries

The list of queries that match the request.

Type: Array of QueryInfo objects

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

ResourceNotFoundException

The specified resource does not exist.

HTTP Status Code: 400

ServiceUnavailableException

The service cannot complete the request.

HTTP Status Code: 500

Examples

List the CloudWatch Logs Insights queries for a specific log group

The following example lists the successfully completed queries of the log group named MyLogGroup.

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.DescribeQueries { "logGroupName": "MyLogGroup", "status": "Completed" }

Sample Response

HTTP/1.1 200 OK x-amzn-RequestId: <RequestId> Content-Type: application/x-amz-json-1.1 Content-Length: <PayloadSizeBytes> Date: <Date> { "nextToken": "string", "queries": [ { "createTime": 1540923785, "logGroupName": "MyLogGroup", "queryId": "12ab3456-12ab-123a-789e-1234567890ab", "queryString": "filter @message like /Exception/ | stats count(*) as @exceptionCount by date_floor(@timestamp, 5m) | sort @exceptionCount desc", "status": "Completed" }, { "createTime": 1540025601, "logGroupName": "MyLogGroup", "queryId": "98ab3456-12ab-123a-789e-1234567890ab", "queryString": "stats count(*) by eventSource, eventName, awsRegion", "status": "Running" } ] }

See Also

For more information about using this API in one of the language-specific Amazon SDKs, see the following: