I am testing java code for filtering cloudwatch log group with following query:
Can someone help me with syntax because I get error InvalidParameterException: Invalid character(s) in term ‘@’?
this is query from aws:
fields @timestamp, @message, @logStream, @log
| sort @timestamp desc
| filter @message like "A_B"
| parse @message ""userInfo":"*"" as userInfo
| stats count(*) by userInfo
how to write this query in java?
ClientConfiguration clientConfig = new ClientConfiguration();
AWSLogsClientBuilder builder = AWSLogsClientBuilder.standard();
AWSLogs logsClient = builder.withCredentials( new AWSStaticCredentialsProvider( new ProfileCredentialsProvider().getCredentials() ) )
.withRegion( Regions.US_EAST_1 )
.withClientConfiguration( clientConfig ).build();
FilterLogEventsRequest request = new FilterLogEventsRequest()
.withLogGroupName(logGroupName)
.withLogStreamNames(logStreamName)
.withFilterPattern(queryString)
.withStartTime(firstDateTimestamp.toEpochMilli())
.withEndTime(lastDateTimestamp.toEpochMilli());
FilterLogEventsResult response = logsClient.filterLogEvents(request);
List<FilteredLogEvent> logEvents = response.getEvents();
4