com.amazonaws.services.logs.model.LogGroup Java Examples
The following examples show how to use
com.amazonaws.services.logs.model.LogGroup.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CloudwatchTableResolver.java From aws-athena-query-federation with Apache License 2.0 | 6 votes |
/** * Optomizaiton that attempts to load a specific LogStream as identified by the TableName. * * @param schemaName The schemaName to load. * @return The CloudwatchTableName or null if not found. */ private String loadLogGroup(String schemaName) throws TimeoutException { DescribeLogGroupsRequest request = new DescribeLogGroupsRequest().withLogGroupNamePrefix(schemaName); DescribeLogGroupsResult result = invoker.invoke(() -> awsLogs.describeLogGroups(request)); for (LogGroup next : result.getLogGroups()) { String nextLogGroupName = next.getLogGroupName(); if (nextLogGroupName.equalsIgnoreCase(schemaName)) { logger.info("loadLogGroup: Matched {} for {}", nextLogGroupName, schemaName); return nextLogGroupName; } } return null; }
Example #2
Source File: CloudwatchTableResolver.java From aws-athena-query-federation with Apache License 2.0 | 5 votes |
/** * Loads the requested LogGroup as identified by the schemaName. * * @param schemaName The schemaName to load. * @return The actual LogGroup name in cloudwatch. * @note This method also primes the cache with other LogGroups found along the way while scanning Cloudwatch. */ private String loadLogGroups(String schemaName) throws TimeoutException { //As an optimization, see if the table name is an exact match (meaning likely no casing issues) String result = loadLogGroup(schemaName); if (result != null) { return result; } logger.info("loadLogGroups: Did not find a match for the schema, falling back to LogGroup scan for {}", schemaName); DescribeLogGroupsRequest validateSchemaRequest = new DescribeLogGroupsRequest(); DescribeLogGroupsResult validateSchemaResult; do { validateSchemaResult = invoker.invoke(() -> awsLogs.describeLogGroups(validateSchemaRequest)); for (LogGroup next : validateSchemaResult.getLogGroups()) { String nextLogGroupName = next.getLogGroupName(); schemaCache.put(schemaName.toLowerCase(), nextLogGroupName); if (nextLogGroupName.equalsIgnoreCase(schemaName)) { logger.info("loadLogGroups: Matched {} for {}", nextLogGroupName, schemaName); return nextLogGroupName; } } validateSchemaRequest.setNextToken(validateSchemaResult.getNextToken()); } while (validateSchemaResult.getNextToken() != null); //We could not find a match throw new IllegalArgumentException("No such schema " + schemaName); }
Example #3
Source File: CloudWatchAppender.java From cloudwatch-logback-appender with ISC License | 5 votes |
private void verifyLogGroupExists() { DescribeLogGroupsRequest request = new DescribeLogGroupsRequest().withLogGroupNamePrefix(logGroupName); DescribeLogGroupsResult result = awsLogsClient.describeLogGroups(request); for (LogGroup group : result.getLogGroups()) { if (logGroupName.equals(group.getLogGroupName())) { return; } } if (createLogDests) { callLogClientMethod("createLogGroup", new CreateLogGroupRequest(logGroupName)); } else { logWarn("Log-group '" + logGroupName + "' doesn't exist and not created", null); } }
Example #4
Source File: LocalstackContainerTest.java From testcontainers-java with MIT License | 5 votes |
@Test public void cloudWatchLogsTestOverBridgeNetwork() { AWSLogs logs = AWSLogsClientBuilder.standard() .withEndpointConfiguration(localstack.getEndpointConfiguration(CLOUDWATCHLOGS)) .withCredentials(localstack.getDefaultCredentialsProvider()).build(); logs.createLogGroup(new CreateLogGroupRequest("foo")); List<LogGroup> groups = logs.describeLogGroups().getLogGroups(); assertEquals("One log group should be created", 1, groups.size()); assertEquals("Name of created log group is [foo]", "foo", groups.get(0).getLogGroupName()); }
Example #5
Source File: CloudwatchMetadataHandlerTest.java From aws-athena-query-federation with Apache License 2.0 | 4 votes |
@Test public void doListSchemaNames() throws TimeoutException { logger.info("doListSchemas - enter"); when(mockAwsLogs.describeLogGroups(any(DescribeLogGroupsRequest.class))).thenAnswer((InvocationOnMock invocationOnMock) -> { DescribeLogGroupsRequest request = (DescribeLogGroupsRequest) invocationOnMock.getArguments()[0]; DescribeLogGroupsResult result = new DescribeLogGroupsResult(); Integer nextToken; if (request.getNextToken() == null) { nextToken = 1; } else if (Integer.valueOf(request.getNextToken()) < 3) { nextToken = Integer.valueOf(request.getNextToken()) + 1; } else { nextToken = null; } List<LogGroup> logGroups = new ArrayList<>(); if (request.getNextToken() == null || Integer.valueOf(request.getNextToken()) < 3) { for (int i = 0; i < 10; i++) { LogGroup nextLogGroup = new LogGroup(); nextLogGroup.setLogGroupName("schema-" + String.valueOf(i)); logGroups.add(nextLogGroup); } } result.withLogGroups(logGroups); if (nextToken != null) { result.setNextToken(String.valueOf(nextToken)); } return result; }); ListSchemasRequest req = new ListSchemasRequest(identity, "queryId", "default"); ListSchemasResponse res = handler.doListSchemaNames(allocator, req); logger.info("doListSchemas - {}", res.getSchemas()); assertTrue(res.getSchemas().size() == 30); verify(mockAwsLogs, times(4)).describeLogGroups(any(DescribeLogGroupsRequest.class)); verifyNoMoreInteractions(mockAwsLogs); logger.info("doListSchemas - exit"); }