当前位置: 首页>>代码示例>>Java>>正文


Java CloudWatchLogsClient类代码示例

本文整理汇总了Java中software.amazon.awssdk.services.cloudwatchlogs.CloudWatchLogsClient的典型用法代码示例。如果您正苦于以下问题:Java CloudWatchLogsClient类的具体用法?Java CloudWatchLogsClient怎么用?Java CloudWatchLogsClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CloudWatchLogsClient类属于software.amazon.awssdk.services.cloudwatchlogs包,在下文中一共展示了CloudWatchLogsClient类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findLogGroupByName

import software.amazon.awssdk.services.cloudwatchlogs.CloudWatchLogsClient; //导入依赖的package包/类
/**
 * @return The LogGroup object included in the DescribeLogGroups response, or null if such group
 *         is not found.
 */
protected static LogGroup findLogGroupByName(final CloudWatchLogsClient awsLogs, final String groupName) {
    String nextToken = null;

    do {
        DescribeLogGroupsResponse result = awsLogs
                .describeLogGroups(DescribeLogGroupsRequest.builder().nextToken(nextToken).build());

        for (LogGroup group : result.logGroups()) {
            if (group.logGroupName().equals(groupName)) {
                return group;
            }
        }
        nextToken = result.nextToken();
    } while (nextToken != null);

    return null;
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:22,代码来源:IntegrationTestBase.java

示例2: findLogStreamByName

import software.amazon.awssdk.services.cloudwatchlogs.CloudWatchLogsClient; //导入依赖的package包/类
/**
 * @return The LogStream object included in the DescribeLogStreams response, or null if such
 *         stream is not found in the specified group.
 */
protected static LogStream findLogStreamByName(final CloudWatchLogsClient awsLogs,
                                               final String logGroupName,
                                               final String logStreamName) {
    String nextToken = null;

    do {
        DescribeLogStreamsResponse result = awsLogs
                .describeLogStreams(DescribeLogStreamsRequest.builder()
                                                             .logGroupName(logGroupName)
                                                             .nextToken(nextToken)
                                                             .build());

        for (LogStream stream : result.logStreams()) {
            if (stream.logStreamName().equals(logStreamName)) {
                return stream;
            }
        }
        nextToken = result.nextToken();
    } while (nextToken != null);

    return null;
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:27,代码来源:IntegrationTestBase.java

示例3: findMetricFilterByName

import software.amazon.awssdk.services.cloudwatchlogs.CloudWatchLogsClient; //导入依赖的package包/类
/**
 * @return The MetricFilter object included in the DescribeMetricFilters response, or null if
 *         such filter is not found in the specified group.
 */
protected static MetricFilter findMetricFilterByName(final CloudWatchLogsClient awsLogs,
                                                     final String logGroupName,
                                                     final String filterName) {
    String nextToken = null;

    do {
        DescribeMetricFiltersResponse result = awsLogs
                .describeMetricFilters(DescribeMetricFiltersRequest.builder()
                                                                   .logGroupName(logGroupName)
                                                                   .nextToken(nextToken)
                                                                   .build());

        for (MetricFilter mf : result.metricFilters()) {
            if (mf.filterName().equals(filterName)) {
                return mf;
            }
        }
        nextToken = result.nextToken();
    } while (nextToken != null);

    return null;
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:27,代码来源:IntegrationTestBase.java

示例4: main

import software.amazon.awssdk.services.cloudwatchlogs.CloudWatchLogsClient; //导入依赖的package包/类
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];

        CloudWatchLogsClient cwl = CloudWatchLogsClient.builder().build();

        PutSubscriptionFilterRequest request =
            PutSubscriptionFilterRequest.builder()
                .filterName(filter)
                .filterPattern(pattern)
                .logGroupName(log_group)
                .destinationArn(function_arn)
                .build();

        PutSubscriptionFilterResponse response =
            cwl.putSubscriptionFilter(request);

        System.out.printf(
            "Successfully created CloudWatch logs subscription filter %s",
            filter);
    }
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:41,代码来源:PutSubscriptionFilter.java

示例5: main

import software.amazon.awssdk.services.cloudwatchlogs.CloudWatchLogsClient; //导入依赖的package包/类
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];

        CloudWatchLogsClient logs = CloudWatchLogsClient.builder().build();

        DeleteSubscriptionFilterRequest request =
            DeleteSubscriptionFilterRequest.builder()
                .filterName(filter)
                .logGroupName(log_group).build();

        DeleteSubscriptionFilterResponse response =
                logs.deleteSubscriptionFilter(request);
    	System.out.printf(
                "Successfully deleted CloudWatch logs subscription filter %s",
                filter);
    }
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:28,代码来源:DeleteSubscriptionFilter.java

示例6: setupFixture

import software.amazon.awssdk.services.cloudwatchlogs.CloudWatchLogsClient; //导入依赖的package包/类
/**
 * Loads the AWS account info for the integration tests and creates an CloudWatch Logs client
 * for tests to use.
 */
@BeforeClass
public static void setupFixture() throws FileNotFoundException, IOException {
    awsLogs = CloudWatchLogsClient.builder().credentialsProvider(CREDENTIALS_PROVIDER_CHAIN).build();
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:9,代码来源:IntegrationTestBase.java


注:本文中的software.amazon.awssdk.services.cloudwatchlogs.CloudWatchLogsClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。