ftkg
ftkg

Reputation: 1772

API to fetch logs from CloudWatch

Is there any currently?

From what I could find, I can only process these logs by sending them through a kinesis stream or to a lambda receptor.

Upvotes: 3

Views: 9571

Answers (1)

Anthony Neace
Anthony Neace

Reputation: 26031

In CloudWatch Logs, individual logs are called 'Log Events'. There are a couple of APIs that will be relevant here:

GetLogEvents

This API lists log events from the specified log stream. You can list all the log events or filter using a time range.

FilterLogEvents

This API lists log events from the specified log group. You can list all the log events or filter the results using a filter pattern, a time range, and the name of the log stream.

This API primarily differs from GetLogEvents inthat you can use the filterPattern parameter to filter for all events matching some pattern, and that you can search across one or more log streams with the logStreamNames parameter.


Both APIs maximum response size is 1MB or 10,000 logs -- whichever you hit first. If you hit that limit and there are more logs available, the API will also respond with nextToken (linked example for GetLogEvents). Use it to make subsequent requests to iterate through all logs that can be returned with your request.

These APIs will also have a variant in the SDKs, just search in the CloudWatch Logs section of the documentation for the SDK you need.

Upvotes: 9

Related Questions