startLiveTail method
Starts a Live Tail streaming session for one or more log groups. A Live Tail session returns a stream of log events that have been recently ingested in the log groups. For more information, see Use Live Tail to view logs in near real time.
The response to this operation is a response stream, over which the server sends live log events and the client receives them.
The following objects are sent over the stream:
- A single LiveTailSessionStart object is sent at the start of the session.
-
Every second, a LiveTailSessionUpdate
object is sent. Each of these objects contains an array of the actual log
events.
If no new log events were ingested in the past second, the
LiveTailSessionUpdateobject will contain an empty array.The array of log events contained in a
LiveTailSessionUpdatecan include as many as 500 log events. If the number of log events matching the request exceeds 500 per second, the log events are sampled down to 500 log events to be included in eachLiveTailSessionUpdateobject.If your client consumes the log events slower than the server produces them, CloudWatch Logs buffers up to 10
LiveTailSessionUpdateevents or 5000 log events, after which it starts dropping the oldest events. - A SessionStreamingException object is returned if an unknown error occurs on the server side.
- A SessionTimeoutException object is returned when the session times out, after it has been kept open for three hours.
May throw AccessDeniedException.
May throw InvalidOperationException.
May throw InvalidParameterException.
May throw LimitExceededException.
May throw ResourceNotFoundException.
Parameter logGroupIdentifiers :
An array where each item in the array is a log group to include in the
Live Tail session.
Specify each log group by its ARN.
If you specify an ARN, the ARN can't end with an asterisk (*).
Parameter logEventFilterPattern :
An optional pattern to use to filter the results to include only log
events that match the pattern. For example, a filter pattern of
error 404 causes only log events that include both
error and 404 to be included in the Live Tail
stream.
Regular expression filter patterns are supported.
For more information about filter pattern syntax, see Filter and Pattern Syntax.
Parameter logStreamNamePrefixes :
If you specify this parameter, then only log events in the log streams
that have names that start with the prefixes that you specify here are
included in the Live Tail session.
If you specify this field, you can't also specify the
logStreamNames field.
Parameter logStreamNames :
If you specify this parameter, then only log events in the log streams
that you specify here are included in the Live Tail session.
If you specify this field, you can't also specify the
logStreamNamePrefixes field.
Implementation
Future<StartLiveTailResponse> startLiveTail({
required List<String> logGroupIdentifiers,
String? logEventFilterPattern,
List<String>? logStreamNamePrefixes,
List<String>? logStreamNames,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Logs_20140328.StartLiveTail'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'logGroupIdentifiers': logGroupIdentifiers,
if (logEventFilterPattern != null)
'logEventFilterPattern': logEventFilterPattern,
if (logStreamNamePrefixes != null)
'logStreamNamePrefixes': logStreamNamePrefixes,
if (logStreamNames != null) 'logStreamNames': logStreamNames,
},
hostPrefix: 'stream-',
);
return StartLiveTailResponse.fromJson(jsonResponse.body);
}