Search in sources :

Example 1 with PutSubscriptionFilterRequest

use of com.amazonaws.services.logs.model.PutSubscriptionFilterRequest in project aws-doc-sdk-examples by awsdocs.

the class PutSubscriptionFilter method main.

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);
}
Also used : PutSubscriptionFilterResult(com.amazonaws.services.logs.model.PutSubscriptionFilterResult) PutSubscriptionFilterRequest(com.amazonaws.services.logs.model.PutSubscriptionFilterRequest) AWSLogs(com.amazonaws.services.logs.AWSLogs)

Aggregations

AWSLogs (com.amazonaws.services.logs.AWSLogs)1 PutSubscriptionFilterRequest (com.amazonaws.services.logs.model.PutSubscriptionFilterRequest)1 PutSubscriptionFilterResult (com.amazonaws.services.logs.model.PutSubscriptionFilterResult)1