本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}