Salman Shaikh
Salman Shaikh

Reputation: 595

Get log events from all streams

I am using AWS Java SDK.

Is there any way to get log events from Log Group without specifying Log Stream name.

My use case is I want to get VPC Flow Logs , since the Log Streams are created in a dynamic way , it is difficult for me to manage the Log Streams associated with the VPC Flow log, Log Group.

I want some thing where I will specify only Log Group name and get all the log events from that Log Group.

Thank you.

Upvotes: 4

Views: 5992

Answers (1)

Anthony Neace
Anthony Neace

Reputation: 26031

FilterLogEvents will work for this use case. You can use FilterLogEvents to list all log events from the specified log group as long as the following values are not specified in the request:

  • a filter pattern (withFilterPattern)
  • a time range (withStartTime, withEndTime)
  • one or more log streams (withLogStreamNames)

These values are used to filter the log set, so if you don't want to filter any logs simply don't specify them.

You may need to make use of paging if you intend to retrieve all logs in this group. On the first response you receive back, use getNextToken() to set the 'NextToken' in your next request, using withNextToken(). Do this for each subsequent request until completion.

Signature:

public FilterLogEventsResult filterLogEvents(FilterLogEventsRequest filterLogEventsRequest)

Resources:

Upvotes: 6

Related Questions