本文整理汇总了Java中com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder类的典型用法代码示例。如果您正苦于以下问题:Java AmazonCloudWatchClientBuilder类的具体用法?Java AmazonCloudWatchClientBuilder怎么用?Java AmazonCloudWatchClientBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AmazonCloudWatchClientBuilder类属于com.amazonaws.services.cloudwatch包,在下文中一共展示了AmazonCloudWatchClientBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: withAutoShutdown
import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; //导入依赖的package包/类
/**
* Convenience factory method to create a CloudWatchRecorder and register a JVM
* shutdown hook to automatically shut it down on application exit.
* The created recorder will use its own internal client to CloudWatch,
* using the default jitter and publish settings.
*
* @param namespace CloudWatch namespace to publish under.
* @param dimensionMapper Configuration specifying which dimensions to sent
* to CloudWatch for each metric event.
* @return A CloudWatchRecorder instance that will automatically shutdown on JVM exit.
*/
public static final CloudWatchRecorder withAutoShutdown(
final String namespace,
final DimensionMapper dimensionMapper)
{
CloudWatchRecorder recorder = new CloudWatchRecorder(
AmazonCloudWatchClientBuilder.defaultClient(),
namespace,
DEFAULT_JITTER,
DEFAULT_PUBLISH_FREQ,
dimensionMapper);
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
recorder.shutdown();
}));
return recorder;
}
开发者ID:awslabs,项目名称:swage,代码行数:29,代码来源:CloudWatchRecorder.java
示例2: amazonCloudWatchClient
import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; //导入依赖的package包/类
@Bean
public AmazonCloudWatch amazonCloudWatchClient(final AWSCredentialsProvider awsCredentialsProvider,
final ClientConfiguration awsClientConfig, final Region awsRegion) {
return AmazonCloudWatchClientBuilder.standard()
.withCredentials(awsCredentialsProvider)
.withClientConfiguration(awsClientConfig)
.withRegion(awsRegion.getName())
.build();
}
开发者ID:shinesolutions,项目名称:aem-orchestrator,代码行数:10,代码来源:AwsConfig.java
示例3: main
import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; //导入依赖的package包/类
public static void main(String[] args) {
final String USAGE =
"To run this example, supply an alarm name\n" +
"Ex: DisableAlarmActions <alarm-name>\n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String alarmName = args[0];
final AmazonCloudWatch cw =
AmazonCloudWatchClientBuilder.defaultClient();
DisableAlarmActionsRequest request = new DisableAlarmActionsRequest()
.withAlarmNames(alarmName);
DisableAlarmActionsResult response = cw.disableAlarmActions(request);
System.out.printf(
"Successfully disabled actions on alarm %s", alarmName);
}
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:25,代码来源:DisableAlarmActions.java
示例4: main
import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; //导入依赖的package包/类
public static void main(String[] args) {
final String USAGE =
"To run this example, supply an alarm name\n" +
"Ex: DeleteAlarm <alarm-name>\n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String alarm_name = args[0];
final AmazonCloudWatch cw =
AmazonCloudWatchClientBuilder.defaultClient();
DeleteAlarmsRequest request = new DeleteAlarmsRequest()
.withAlarmNames(alarm_name);
DeleteAlarmsResult response = cw.deleteAlarms(request);
System.out.printf("Successfully deleted alarm %s", alarm_name);
}
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:24,代码来源:DeleteAlarm.java
示例5: main
import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; //导入依赖的package包/类
public static void main(String[] args) {
final String USAGE =
"To run this example, supply an alarm name\n" +
"Ex: EnableAlarmActions <alarm-name>\n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String alarm = args[0];
final AmazonCloudWatch cw =
AmazonCloudWatchClientBuilder.defaultClient();
EnableAlarmActionsRequest request = new EnableAlarmActionsRequest()
.withAlarmNames(alarm);
EnableAlarmActionsResult response = cw.enableAlarmActions(request);
System.out.printf(
"Successfully enabled actions on alarm %s", alarm);
}
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:25,代码来源:EnableAlarmActions.java
示例6: main
import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; //导入依赖的package包/类
public static void main(String[] args) {
final AmazonCloudWatch cw =
AmazonCloudWatchClientBuilder.defaultClient();
boolean done = false;
DescribeAlarmsRequest request = new DescribeAlarmsRequest();
while(!done) {
DescribeAlarmsResult response = cw.describeAlarms(request);
for(MetricAlarm alarm : response.getMetricAlarms()) {
System.out.printf("Retrieved alarm %s", alarm.getAlarmName());
}
request.setNextToken(response.getNextToken());
if(response.getNextToken() == null) {
done = true;
}
}
}
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:24,代码来源:DescribeAlarms.java
示例7: main
import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; //导入依赖的package包/类
public static void main(String[] args) {
final String USAGE =
"To run this example, supply a metric name and metric namespace\n" +
"Ex: ListMetrics <metric-name> <metric-namespace>\n";
if (args.length != 2) {
System.out.println(USAGE);
System.exit(1);
}
String name = args[0];
String namespace = args[1];
final AmazonCloudWatch cw =
AmazonCloudWatchClientBuilder.defaultClient();
ListMetricsRequest request = new ListMetricsRequest()
.withMetricName(name)
.withNamespace(namespace);
boolean done = false;
while(!done) {
ListMetricsResult response = cw.listMetrics(request);
for(Metric metric : response.getMetrics()) {
System.out.printf(
"Retrieved metric %s", metric.getMetricName());
}
request.setNextToken(response.getNextToken());
if(response.getNextToken() == null) {
done = true;
}
}
}
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:39,代码来源:ListMetrics.java
示例8: main
import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; //导入依赖的package包/类
public static void main(String[] args) {
final String USAGE =
"To run this example, supply a data point:\n" +
"Ex: PutMetricData <data_point>\n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
Double data_point = Double.parseDouble(args[0]);
final AmazonCloudWatch cw =
AmazonCloudWatchClientBuilder.defaultClient();
Dimension dimension = new Dimension()
.withName("UNIQUE_PAGES")
.withValue("URLS");
MetricDatum datum = new MetricDatum()
.withMetricName("PAGES_VISITED")
.withUnit(StandardUnit.None)
.withValue(data_point)
.withDimensions(dimension);
PutMetricDataRequest request = new PutMetricDataRequest()
.withNamespace("SITE/TRAFFIC")
.withMetricData(datum);
PutMetricDataResult response = cw.putMetricData(request);
System.out.printf("Successfully put data point %f", data_point);
}
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:35,代码来源:PutMetricData.java
示例9: getCloudWatchClient
import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; //导入依赖的package包/类
@Override
public AmazonCloudWatch getCloudWatchClient() {
AmazonCloudWatchClientBuilder clientBuilder =
AmazonCloudWatchClientBuilder.standard().withCredentials(getCredentialsProvider());
if (serviceEndpoint == null) {
clientBuilder.withRegion(region);
} else {
clientBuilder.withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration(serviceEndpoint, region.getName()));
}
return clientBuilder.build();
}
开发者ID:apache,项目名称:beam,代码行数:13,代码来源:KinesisIO.java
示例10: createCloudWatchClient
import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; //导入依赖的package包/类
public static AmazonCloudWatchClient createCloudWatchClient() {
BasicCredentialsProvider credentials = BasicCredentialsProvider.standard();
AmazonCloudWatchClient client = !credentials.isValid() ? null : (AmazonCloudWatchClient)
AmazonCloudWatchClientBuilder.standard()
.withCredentials(credentials)
.withRegion("eu-west-1")
.build();
return client;
}
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:10,代码来源:CloudWatchUtils.java
示例11: CloudwatchClient
import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; //导入依赖的package包/类
public CloudwatchClient(HasCloudwatchConfig cloudwatchConfig) {
amazonCloudWatch = AmazonCloudWatchClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(cloudwatchConfig))
.withRegion(cloudwatchConfig.getRegion())
.build();
}
开发者ID:Espenhh,项目名称:panopticon,代码行数:7,代码来源:CloudwatchClient.java
示例12: main
import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; //导入依赖的package包/类
public static void main(String[] args) {
final String USAGE =
"To run this example, supply an alarm name and instance id\n" +
"Ex: DeleteAlarm <alarm-name> <instance-id>\n";
if (args.length != 2) {
System.out.println(USAGE);
System.exit(1);
}
String alarmName = args[0];
String instanceId = args[1];
final AmazonCloudWatch cw =
AmazonCloudWatchClientBuilder.defaultClient();
Dimension dimension = new Dimension()
.withName("InstanceId")
.withValue(instanceId);
PutMetricAlarmRequest request = new PutMetricAlarmRequest()
.withAlarmName(alarmName)
.withComparisonOperator(
ComparisonOperator.GreaterThanThreshold)
.withEvaluationPeriods(1)
.withMetricName("CPUUtilization")
.withNamespace("AWS/EC2")
.withPeriod(60)
.withStatistic(Statistic.Average)
.withThreshold(70.0)
.withActionsEnabled(false)
.withAlarmDescription(
"Alarm when server CPU utilization exceeds 70%")
.withUnit(StandardUnit.Seconds)
.withDimensions(dimension);
PutMetricAlarmResult response = cw.putMetricAlarm(request);
System.out.printf(
"Successfully created alarm with name %s", alarmName);
}
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:44,代码来源:PutMetricAlarm.java
示例13: CloudWatch
import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; //导入依赖的package包/类
public CloudWatch(AWSCredentialsProvider credentials, Regions region) {
cloudWatch = AmazonCloudWatchClientBuilder.standard().withRegion(region).withCredentials(credentials).build();
}
开发者ID:neowu,项目名称:cmn-project,代码行数:4,代码来源:CloudWatch.java
示例14: CloudWatchAccessor
import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; //导入依赖的package包/类
private CloudWatchAccessor() throws CandlestackException {
metricsReaderWriter = MetricsReaderWriter.getInstance();
detailedMonitoringEnabled = GlobalAWSProperties.isCloudWatchDetailedMonitoringEnabled();
requestPeriod = detailedMonitoringEnabled ? DETAILED_REQUEST_PERIOD : NON_DETAILED_REQUEST_PERIOD;
maxTimeDifference = 1000 * requestPeriod * MAX_DATA_POINTS;
cloudWatchClient = AmazonCloudWatchClientBuilder.standard().withRegion( GlobalAWSProperties.getRegion() ).build();
lastDatapointDateMap = new HashMap<>();
}
开发者ID:CodeArcsInc,项目名称:candlestack,代码行数:16,代码来源:CloudWatchAccessor.java
示例15: CloudWatch
import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; //导入依赖的package包/类
/**
* New CloudWatch with DefaultAWSCredentialsProviderChain (and DefaultAwsRegionProviderChain) configured either by :
* <ul>
* <li>Environment Variables -
* <code>AWS_ACCESS_KEY_ID</code> and <code>AWS_SECRET_ACCESS_KEY</code>
* (RECOMMENDED since they are recognized by all the AWS SDKs and CLI except for .NET),
* or <code>AWS_ACCESS_KEY</code> and <code>AWS_SECRET_KEY</code> (only recognized by Java SDK)
* </li>
* <li>Java System Properties - aws.accessKeyId and aws.secretKey</li>
* <li>Credential profiles file at the default location (~/.aws/credentials) shared by all AWS SDKs and the AWS CLI</li>
* <li>Credentials delivered through the Amazon EC2 container service if AWS_CONTAINER_CREDENTIALS_RELATIVE_URI" environment variable is set
* and security manager has permission to access the variable,</li>
* <li>Instance profile credentials delivered through the Amazon EC2 metadata service</li>
* </ul>
* (idem for AWS region)
*
* @param cloudWatchNamespace CloudWatch Namespace such as "MyCompany/MyAppDomain"
* (Namespace of Amazon EC2 is "AWS/EC2", but "AWS/*" is reserved for AWS products)
* @param prefix Prefix such as "javamelody."
* @param application Application such as /testapp
* @param hostName Hostname such as [email protected]
*/
CloudWatch(String cloudWatchNamespace, String prefix, String application, String hostName) {
this(AmazonCloudWatchClientBuilder.defaultClient(), cloudWatchNamespace, prefix,
application, hostName);
}
开发者ID:javamelody,项目名称:javamelody,代码行数:27,代码来源:CloudWatch.java
注:本文中的com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论