Amazon CloudWatch Logs
API Reference (API Version 2014-03-28)


Returns the results from the specified query. If the query is in progress, partial results of that current execution are returned. Only the fields requested in the query are returned.

GetQueryResults does not start a query execution. To run a query, use StartQuery.

Request Syntax

{ "queryId": "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.


The ID number of the query.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 256.

Required: Yes

Response Syntax

{ "results": [ [ { "field": "string", "value": "string" } ] ], "statistics": { "bytesScanned": number, "recordsMatched": number, "recordsScanned": number }, "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.


The log events that matched the query criteria during the most recent time it ran.

The results value is an array of arrays. Each log event is one object in the top-level array. Each of these log event objects is an array of field/value pairs.

Type: Array of arrays of ResultField objects


Includes the number of log events scanned by the query, the number of log events that matched the query criteria, and the total number of bytes in the log events that were scanned.

Type: QueryStatistics object


The status of the most recent running of the query. Possible values are Cancelled, Complete, Failed, Running, Scheduled, and Unknown.

Type: String

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


For information about the errors that are common to all actions, see Common Errors.


A parameter is specified incorrectly.

HTTP Status Code: 400


The specified resource does not exist.

HTTP Status Code: 400


The service cannot complete the request.

HTTP Status Code: 500


Get results from a recent query

The following returns the results from a specified query.

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.GetQueryResults { "queryId": "12ab3456-12ab-123a-789e-1234567890ab" }

Sample Response

HTTP/1.1 200 OK x-amzn-RequestId: <RequestId> Content-Type: application/x-amz-json-1.1 Content-Length: <PayloadSizeBytes> Date: <Date> { "results": [ [ { "field": "LogEvent1-field1-name", "value": "LogEvent1-field1-value" }, { "field": "LogEvent1-field2-name", "value": "LogEvent1-field2-value" }, ... { "field": "LogEvent1-fieldX-name", "value": "LogEvent1-fieldX-value" } ], [ { "field": "LogEvent2-field1-name", "value": "LogEvent2-field1-value" }, { "field": "LogEvent2-field2-name", "value": "LogEvent2-field2-value" }, ... { "field": "LogEvent2-fieldX-name", "value": "LogEvent2-fieldX-value" } ], [ { "field": "LogEventZ-field1-name", "value": "LogEventZ-field1-value" }, { "field": "LogEventZ-field2-name", "value": "LogEventZ-field2-value" }, ... { "field": "LogEventZ-fieldX-name", "value": "LogEventZ-fieldX-value" } ] ], "statistics": { "bytesScanned": 81349723, "recordsMatched": 360851, "recordsScanned": 610956 }, "status": "Completed" }

See Also

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