We are working on AWS Lambda and Cloudwatch logs. Now, I want fetch all the log events from the Cloudwatch logs without using logStreamName by Java.
Since we are generating the logstream in dynamic way, am not sure how to fetch all the logs from the Cloudwatch log group.
I know, If we have logstream name, then we can use the below code
ClientConfiguration clientConfig = getClientConfig();
AWSLogsClientBuilder builder = AWSLogsClientBuilder.standard();
AWSLogs logsClient= builder.withCredentials(new AWSStaticCredentialsProvider(new ProfileCredentialsProvider(profile).getCredentials())).withRegion(Regions.AP_SOUTHEAST_2).withClientConfiguration(clientConfig).build();
GetLogEventsRequest request = new GetLogEventsRequest()
.withStartTime(1531231200000L)
.withEndTime(1531576800000L)
.withLogGroupName("FlowLogs_GroupName")
.withLogStreamName("eni-xxxxx");
GetLogEventsResult result = logsClient.getLogEvents(request);
result.getEvents().forEach(outputLogEvent -> {
System.out.println(outputLogEvent.getMessage());
});
Since am new to this AWS, can anyone please help me with some code samples?