com.amazonaws.services.logs.AWSLogsClientBuilder Java Examples

The following examples show how to use com.amazonaws.services.logs.AWSLogsClientBuilder. 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: CloudwatchRecordHandler.java    From aws-athena-query-federation with Apache License 2.0 5 votes vote down vote up
public CloudwatchRecordHandler()
{
    this(AmazonS3ClientBuilder.defaultClient(),
            AWSSecretsManagerClientBuilder.defaultClient(),
            AmazonAthenaClientBuilder.defaultClient(),
            AWSLogsClientBuilder.defaultClient());
}
 
Example #2
Source File: AwsConfig.java    From cloudwatch-logback-appender with Apache License 2.0 5 votes vote down vote up
public AWSLogs createAWSLogs() {
    AWSLogsClientBuilder builder = AWSLogsClientBuilder.standard();

    if(region!=null) {
        builder.withRegion(region);
    }

    if(clientConfig!=null) {
        builder.withClientConfiguration(clientConfig);
    }

    if(profileName!=null) {
        builder.withCredentials(new ProfileCredentialsProvider(profileName));
    }
    else if(credentials!=null) {
        builder.withCredentials(new AWSStaticCredentialsProvider(credentials));
    }

    return builder.build();
}
 
Example #3
Source File: CloudwatchLogsLogEventPutter.java    From cloudwatchlogs-java-appender with Apache License 2.0 5 votes vote down vote up
static AWSLogs createLogsClient(CloudwatchLogsConfig config) {
    AWSLogsClientBuilder builder = AWSLogsClientBuilder.standard();
    if (config.getEndpoint() != null) {
        // Non-AWS mock endpoint
        builder.setCredentials(new AWSStaticCredentialsProvider(new AnonymousAWSCredentials()));
        builder.setEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(config.getEndpoint(), config.getRegion()));
    } else {
        builder.setRegion(config.getRegion());
    }
    return builder.build();
}
 
Example #4
Source File: PutSubscriptionFilter.java    From aws-doc-sdk-examples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {

        final String USAGE =
            "To run this example, supply:\n" +
            "* a filter name\n" +
            "* filter pattern\n" +
            "* log group name\n" +
            "* lambda function arn\n\n" +
            "Ex: PutSubscriptionFilter <filter-name> \\\n" +
            "                          <filter pattern> \\\n" +
            "                          <log-group-name> \\\n" +
            "                          <lambda-function-arn>\n";

        if (args.length != 4) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String filter = args[0];
        String pattern = args[1];
        String log_group = args[2];
        String function_arn = args[3];

        final AWSLogs cwl = AWSLogsClientBuilder.defaultClient();

        PutSubscriptionFilterRequest request =
            new PutSubscriptionFilterRequest()
                .withFilterName(filter)
                .withFilterPattern(pattern)
                .withLogGroupName(log_group)
                .withDestinationArn(function_arn);

        PutSubscriptionFilterResult response =
            cwl.putSubscriptionFilter(request);

        System.out.printf(
            "Successfully created CloudWatch logs subscription filter %s",
            filter);
    }
 
Example #5
Source File: DeleteSubscriptionFilter.java    From aws-doc-sdk-examples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {

        final String USAGE =
            "To run this example, supply a filter name and log group name\n" +
            "Ex: DeleteSubscriptionFilter <filter-name> <log-group-name>\n";

        if (args.length != 2) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String filter = args[0];
        String log_group = args[1];

        final AWSLogs logs = AWSLogsClientBuilder.defaultClient();

        DeleteSubscriptionFilterRequest request =
            new DeleteSubscriptionFilterRequest()
                .withFilterName(filter)
                .withLogGroupName(log_group);

        DeleteSubscriptionFilterResult response =
            logs.deleteSubscriptionFilter(request);

        System.out.printf(
            "Successfully deleted CloudWatch logs subscription filter %s",
            filter);
    }
 
Example #6
Source File: LocalstackContainerTest.java    From testcontainers-java with MIT License 5 votes vote down vote up
@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 #7
Source File: CloudwatchMetadataHandler.java    From aws-athena-query-federation with Apache License 2.0 4 votes vote down vote up
public CloudwatchMetadataHandler()
{
    super(SOURCE_TYPE);
    this.awsLogs = AWSLogsClientBuilder.standard().build();
    tableResolver = new CloudwatchTableResolver(invoker, awsLogs, MAX_RESULTS, MAX_RESULTS);
}
 
Example #8
Source File: CloudwatchMetricFilterPublisher.java    From lambda-monitoring with Apache License 2.0 4 votes vote down vote up
public CloudwatchMetricFilterPublisher(Log log) {
    // http://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html#credentials-default
    this.client = AWSLogsClientBuilder.defaultClient();
    this.log = log;
}
 
Example #9
Source File: DescribeSubscriptionFilters.java    From aws-doc-sdk-examples with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {

        final String USAGE =
            "To run this example, supply a log group name\n" +
            "Ex: DescribeSubscriptionFilters <log-group-name>\n";

        if (args.length != 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String log_group = args[0];

        final AWSLogs logs = AWSLogsClientBuilder.defaultClient();
        boolean done = false;

        DescribeSubscriptionFiltersRequest request =
                new DescribeSubscriptionFiltersRequest()
                    .withLogGroupName(log_group)
                    .withLimit(1);

        while(!done) {

            DescribeSubscriptionFiltersResult response =
                logs.describeSubscriptionFilters(request);

            for(SubscriptionFilter filter : response.getSubscriptionFilters()) {
                System.out.printf(
                    "Retrieved filter with name %s, " +
                    "pattern %s " +
                    "and destination arn %s",
                    filter.getFilterName(),
                    filter.getFilterPattern(),
                    filter.getDestinationArn());
            }

            request.setNextToken(response.getNextToken());

            if(response.getNextToken() == null) {
                done = true;
            }
        }
    }