getContainerLog method
Returns the log events of a container of your Amazon Lightsail container service.
If your container service has more than one node (i.e., a scale greater than 1), then the log events that are returned for the specified container are merged from all nodes on your container service.
May throw ServiceException. May throw InvalidInputException. May throw NotFoundException. May throw AccessDeniedException. May throw UnauthenticatedException.
Parameter containerName
:
The name of the container that is either running or previously ran on the
container service for which to return a log.
Parameter serviceName
:
The name of the container service for which to get a container log.
Parameter endTime
:
The end of the time interval for which to get log data.
Constraints:
- Specified in Coordinated Universal Time (UTC).
-
Specified in the Unix time format.
For example, if you wish to use an end time of October 1, 2018, at 9 PM UTC, specify
1538427600
as the end time.
Parameter filterPattern
:
The pattern to use to filter the returned log events to a specific term.
The following are a few examples of filter patterns that you can specify:
-
To return all log events, specify a filter pattern of
""
. -
To exclude log events that contain the
ERROR
term, and return all other log events, specify a filter pattern of"-ERROR"
. -
To return log events that contain the
ERROR
term, specify a filter pattern of"ERROR"
. -
To return log events that contain both the
ERROR
andException
terms, specify a filter pattern of"ERROR Exception"
. -
To return log events that contain the
ERROR
or theException
term, specify a filter pattern of"?ERROR ?Exception"
.
Parameter pageToken
:
The token to advance to the next page of results from your request.
To get a page token, perform an initial GetContainerLog
request. If your results are paginated, the response will return a next
page token that you can specify as the page token in a subsequent request.
Parameter startTime
:
The start of the time interval for which to get log data.
Constraints:
- Specified in Coordinated Universal Time (UTC).
-
Specified in the Unix time format.
For example, if you wish to use a start time of October 1, 2018, at 8 PM UTC, specify
1538424000
as the start time.
Implementation
Future<GetContainerLogResult> getContainerLog({
required String containerName,
required String serviceName,
DateTime? endTime,
String? filterPattern,
String? pageToken,
DateTime? startTime,
}) async {
ArgumentError.checkNotNull(containerName, 'containerName');
ArgumentError.checkNotNull(serviceName, 'serviceName');
_s.validateStringLength(
'serviceName',
serviceName,
1,
63,
isRequired: true,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Lightsail_20161128.GetContainerLog'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'containerName': containerName,
'serviceName': serviceName,
if (endTime != null) 'endTime': unixTimestampToJson(endTime),
if (filterPattern != null) 'filterPattern': filterPattern,
if (pageToken != null) 'pageToken': pageToken,
if (startTime != null) 'startTime': unixTimestampToJson(startTime),
},
);
return GetContainerLogResult.fromJson(jsonResponse.body);
}