use of com.amazonaws.services.cloudwatch.AmazonCloudWatch in project aws-doc-sdk-examples by awsdocs.
the class EnableAlarmActions method main.
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);
}
use of com.amazonaws.services.cloudwatch.AmazonCloudWatch in project aws-doc-sdk-examples by awsdocs.
the class ListMetrics method main.
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();
boolean done = false;
while (!done) {
ListMetricsRequest request = new ListMetricsRequest().withMetricName(name).withNamespace(namespace);
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;
}
}
}
Aggregations