List of usage examples for com.amazonaws.services.cloudwatch AmazonCloudWatchClient AmazonCloudWatchClient
@Deprecated
public AmazonCloudWatchClient()
From source file:com.basistech.metrics.TryThisOut.java
License:Open Source License
public TryThisOut() { registry = new MetricRegistry(); gauge = new Gauge<Integer>() { @Override// www .j ava 2s .c o m public Integer getValue() { return gaugeValue; } }; registry.register("gauge", gauge); counter = new Counter(); registry.register("counter", counter); histogram = new Histogram(new SlidingTimeWindowReservoir(10, TimeUnit.SECONDS)); registry.register("histogram", histogram); meter = new Meter(); registry.register("meter", meter); timer = new Timer(); registry.register("timer", timer); String instanceId = EC2MetadataUtils.getInstanceId(); // try out the default constructor. AmazonCloudWatchClient client = new AmazonCloudWatchClient(); reporter = new CloudWatchReporter.Builder(registry, client).dimension("instanceId", instanceId) .namespace("some-namespace").build(); reporter.start(5, TimeUnit.SECONDS); executorService = Executors.newSingleThreadScheduledExecutor(); executorService.scheduleAtFixedRate(new Runnable() { private int counterVal; private Random random = new Random(); @Override public void run() { gaugeValue = counterVal++; counter.inc(); Timer.Context context = timer.time(); meter.mark(); histogram.update((int) (random.nextGaussian() * 10)); context.stop(); } }, 0, 1, TimeUnit.SECONDS); }
From source file:com.github.lpezet.antiope.metrics.aws.MetricsUploaderThread.java
License:Open Source License
MetricsUploaderThread(Config pConfig, BlockingQueue<MetricDatum> pQueue) { this(pConfig, pQueue, pConfig.getCloudWatchConfig().getCredentialsProvider() == null ? new AmazonCloudWatchClient() : new AmazonCloudWatchClient(pConfig.getCloudWatchConfig().getCredentialsProvider())); }
From source file:org.web.online.cloudwatch.tomcat.valve.ElapsedTimeAggregator.java
License:Apache License
/** * Construct the instance querying EC2 meta data to get the InstanceId * and querying the tags of this instance to get the * AutoScalingGroupName (tag key == "aws:autoscaling:groupName"). * /*from w w w . j av a 2 s. c o m*/ * Additionally sets up the Cloud Watch metric with the given namespace, * a metric name of "ElapsedTime" and dimensions * of InstanceId and AutoScalingGroupName. * * @param namespace namespace value to use to push data to CloudWatch * @throws IllegalStateException if instance/ASG details not able to be * retrieved */ public ElapsedTimeAggregator(String namespace) { this(namespace, Regions.getCurrentRegion(), EC2MetadataUtils.getInstanceId(), null, new AmazonEC2Client(), new AmazonCloudWatchClient()); }