Java Code Examples for com.amazonaws.services.logs.AWSLogsClientBuilder#defaultClient()

The following examples show how to use com.amazonaws.services.logs.AWSLogsClientBuilder#defaultClient() . 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: 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 3
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 4
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 5
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;
            }
        }
    }