GetLogEvents
Lists log events from the specified log stream. You can list all the log events or filter using a time range.
By default, this operation returns as many log events as can fit in a response size of 1MB (up to 10,000 log events). If the results include tokens, there are more log events available. You can get additional log events by specifying one of the tokens in a subsequent call.
Request Syntax
{
"endTime": number,
"limit": number,
"logGroupName": "string",
"logStreamName": "string",
"nextToken": "string",
"startFromHead": boolean,
"startTime": number
}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.
- endTime
The end of the time range, expressed as the number of milliseconds since Jan 1, 1970 00:00:00 UTC. Events with a timestamp later than this time are not included.
Type: Long
Valid Range: Minimum value of 0.
Required: No
- limit
The maximum number of log events returned. If you don't specify a value, the maximum is as many log events as can fit in a response size of 1MB, up to 10,000 log events.
Type: Integer
Valid Range: Minimum value of 1. Maximum value of 10000.
Required: No
- logGroupName
The name of the log group.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 512.
Pattern:
[\.\-_/#A-Za-z0-9]+Required: Yes
- logStreamName
The name of the log stream.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 512.
Pattern:
[^:*]*Required: Yes
- 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
- startFromHead
If the value is true, the earliest log events are returned first. If the value is false, the latest log events are returned first. The default value is false.
Type: Boolean
Required: No
- startTime
The start of the time range, expressed as the number of milliseconds since Jan 1, 1970 00:00:00 UTC. Events with a timestamp earlier than this time are not included.
Type: Long
Valid Range: Minimum value of 0.
Required: No
Response Syntax
{
"events": [
{
"ingestionTime": number,
"message": "string",
"timestamp": number
}
],
"nextBackwardToken": "string",
"nextForwardToken": "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.
- events
The events.
Type: array of OutputLogEvent objects
- nextBackwardToken
The token for the next set of items in the backward direction. The token expires after 24 hours.
Type: String
Length Constraints: Minimum length of 1.
- nextForwardToken
The token for the next set of items in the forward direction. The token expires after 24 hours.
Type: String
Length Constraints: Minimum length of 1.
Errors
For information about the errors that are common to all actions, see Common Errors.
Example
To list all the events for a log stream
The following example lists all events for the specified log stream.
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.GetLogEvents
{
"logGroupName": "my-log-group",
"logStreamName": "my-log-stream"
}Sample Response
HTTP/1.1 200 OK
x-amzn-RequestId: <RequestId>
Content-Type: application/x-amz-json-1.1
Content-Length: <PayloadSizeBytes>
Date: <Date>
{
"events": [
{
"ingestionTime": 1396035394997,
"timestamp": 1396035378988,
"message": "Example event 1"
},
{
"ingestionTime": 1396035394997,
"timestamp": 1396035378988,
"message": "Example event 2"
},
{
"ingestionTime": 1396035394997,
"timestamp": 1396035378989,
"message": "Example event 3"
}
],
"nextBackwardToken": "b/31132629274945519779805322857203735586714454643391594505",
"nextForwardToken": "f/31132629323784151764587387538205132201699397759403884544"
}See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following:

