當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。