use of com.amazonaws.services.cloudwatch.AmazonCloudWatch in project aws-doc-sdk-examples by awsdocs.
the class PutMetricData method main.
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);
}
use of com.amazonaws.services.cloudwatch.AmazonCloudWatch in project aws-doc-sdk-examples by awsdocs.
the class DisableAlarmActions method main.
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);
}
use of com.amazonaws.services.cloudwatch.AmazonCloudWatch in project chassis by Kixeye.
the class CloudWatchReporterTest method testPublishFilteredMetrics_metricStatFiltered.
/**
* A metric is not fully filtered, but some stats within the metric are
*/
@Test
public void testPublishFilteredMetrics_metricStatFiltered() throws InterruptedException {
MetricRegistry metricRegistry = new MetricRegistry();
metricRegistry.meter("UnitTestMeter1").mark();
metricRegistry.meter("UnitTestMeter2").mark();
final AmazonCloudWatch amazonCloudWatch = Mockito.mock(AmazonCloudWatch.class);
reporter = new MetricsCloudWatchReporter(APP_NAME, APP_VERSION, APP_ENVIRONMENT, "utm1=UnitTestMeter1,utm2=UnitTestMeter2:1m:5m:15m", 2, TimeUnit.SECONDS, metricRegistry, createCloudWatchFactory(amazonCloudWatch));
reporter.start();
//give the reporter a chance to publish
Thread.sleep(3000);
PutMetricDataRequestMatcher matcher = new PutMetricDataRequestMatcher(new MetricDatumValidator("utm1.1m", APP_ENVIRONMENT, 0d), new MetricDatumValidator("utm1.5m", APP_ENVIRONMENT, 0d), new MetricDatumValidator("utm1.15m", APP_ENVIRONMENT, 0d), new MetricDatumValidator("utm1.mean", APP_ENVIRONMENT, null), new MetricDatumValidator("utm2.1m", APP_ENVIRONMENT, 0d), new MetricDatumValidator("utm2.5m", APP_ENVIRONMENT, 0d), new MetricDatumValidator("utm2.15m", APP_ENVIRONMENT, 0d));
Mockito.verify(amazonCloudWatch, Mockito.times(1)).putMetricData(Mockito.argThat(matcher));
}
use of com.amazonaws.services.cloudwatch.AmazonCloudWatch in project aws-doc-sdk-examples by awsdocs.
the class DeleteAlarm method main.
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);
}
use of com.amazonaws.services.cloudwatch.AmazonCloudWatch in project aws-doc-sdk-examples by awsdocs.
the class DescribeAlarms method main.
public static void main(String[] args) {
final AmazonCloudWatch cw = AmazonCloudWatchClientBuilder.defaultClient();
boolean done = false;
while (!done) {
DescribeAlarmsRequest request = new DescribeAlarmsRequest();
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;
}
}
}
Aggregations