List of usage examples for com.amazonaws.services.cloudwatch AmazonCloudWatchClientBuilder standard
public static AmazonCloudWatchClientBuilder standard()
From source file:com.nextdoor.bender.monitoring.cw.CloudwatchReporterFactory.java
License:Apache License
@Override public void setConf(AbstractConfig config) { this.config = (CloudwatchReporterConfig) config; AmazonCloudWatchClientBuilder clientBuilder = AmazonCloudWatchClientBuilder.standard(); if (this.config.getRegion() != null) { clientBuilder.withRegion(this.config.getRegion()); }/*from w w w . j a va 2 s . c om*/ this.client = clientBuilder.build(); }
From source file:com.remediatetheflag.global.utils.AWSHelper.java
License:Apache License
public Double getClusterMemoryReservation(Region region) { AmazonCloudWatch client = AmazonCloudWatchClientBuilder.standard().withRegion(region.getName()) .withCredentials(new DefaultAWSCredentialsProviderChain()).build(); Dimension dimension = new Dimension(); dimension.setName("ClusterName"); dimension.setValue(RTFConfig.getExercisesCluster()); Date date = new Date(); Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from w w w. j av a 2 s . c o m*/ cal.add(Calendar.MINUTE, -5); GetMetricStatisticsRequest request = new GetMetricStatisticsRequest().withMetricName("MemoryReservation") .withDimensions(dimension).withPeriod(60).withStartTime(cal.getTime()).withEndTime(date) .withStatistics("Average").withNamespace("AWS/ECS"); try { logger.debug("Requesting memory reservation for region " + region.getName() + " cluster " + RTFConfig.getExercisesCluster()); GetMetricStatisticsResult response = client.getMetricStatistics(request); if (response.getDatapoints().isEmpty()) return 0.0; return response.getDatapoints().get(0).getAverage(); } catch (Exception e) { logger.error("Error getClusterContainerInstances for memory reservation in region " + region.getName() + " due to:\n" + e.getMessage()); return 0.0; } }
From source file:kinesisadaptersample.StreamsAdapterDemo.java
License:Open Source License
/** * @param args// w w w. j a v a 2 s . c om */ public static void main(String[] args) throws Exception { System.out.println("Starting demo..."); String srcTable = tablePrefix + "-src"; String destTable = tablePrefix + "-dest"; streamsCredentials = new ProfileCredentialsProvider(); dynamoDBCredentials = new ProfileCredentialsProvider(); recordProcessorFactory = new StreamsRecordProcessorFactory(destTable); adapterClient = new AmazonDynamoDBStreamsAdapterClient(streamsCredentials); adapterClient.setRegion(Region.getRegion(Regions.EU_WEST_1)); dynamoDBClient = AmazonDynamoDBClientBuilder.standard().withRegion(Regions.EU_WEST_1).build(); cloudWatchClient = AmazonCloudWatchClientBuilder.standard().withRegion(Regions.EU_WEST_1).build(); setUpTables(); workerConfig = new KinesisClientLibConfiguration("streams-adapter-demo", streamArn, streamsCredentials, "streams-demo-worker").withMaxRecords(1000).withIdleTimeBetweenReadsInMillis(500) .withInitialPositionInStream(InitialPositionInStream.TRIM_HORIZON); System.out.println("Creating worker for stream: " + streamArn); worker = new Worker(recordProcessorFactory, workerConfig, adapterClient, dynamoDBClient, cloudWatchClient); System.out.println("Starting worker..."); Thread t = new Thread(worker); t.start(); Thread.sleep(25000); worker.shutdown(); t.join(); if (StreamsAdapterDemoHelper.scanTable(dynamoDBClient, srcTable).getItems() .equals(StreamsAdapterDemoHelper.scanTable(dynamoDBClient, destTable).getItems())) { System.out.println("Scan result is equal."); } else { System.out.println("Tables are different!"); } System.out.println("Done."); cleanupAndExit(0); }
From source file:org.apache.beam.sdk.io.aws.dynamodb.BasicDynamoDBProvider.java
License:Apache License
@Override public AmazonCloudWatch getCloudWatchClient() { AmazonCloudWatchClientBuilder clientBuilder = AmazonCloudWatchClientBuilder.standard() .withCredentials(getCredentialsProvider()); if (serviceEndpoint == null) { clientBuilder.withRegion(region); } else {// w w w . j a va 2 s. c o m clientBuilder.withEndpointConfiguration( new AwsClientBuilder.EndpointConfiguration(serviceEndpoint, region.getName())); } return clientBuilder.build(); }
From source file:org.wildfly.camel.test.common.aws.CloudWatchUtils.java
License:Apache License
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; }