本文整理汇总了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;
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
}
}
示例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;
}
}
}
示例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);
}
示例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();
}
示例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;
}
示例11: CloudwatchClient
import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; //导入依赖的package包/类
public CloudwatchClient(HasCloudwatchConfig cloudwatchConfig) {
amazonCloudWatch = AmazonCloudWatchClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(cloudwatchConfig))
.withRegion(cloudwatchConfig.getRegion())
.build();
}
示例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);
}
示例13: CloudWatch
import com.amazonaws.services.cloudwatch.AmazonCloudWatchClientBuilder; //导入依赖的package包/类
public CloudWatch(AWSCredentialsProvider credentials, Regions region) {
cloudWatch = AmazonCloudWatchClientBuilder.standard().withRegion(region).withCredentials(credentials).build();
}
示例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<>();
}
示例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);
}