mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(cloudwatch): store and return ExtendedStatistic on metric alarms (#9132)
This commit is contained in:
1 parent
94c0504bca
commit
2985a3b224
9 files changed
+287
No files matched your search
@@ -282,6 +282,7 @@ public class AlarmEvaluator {
|
||||
&& alarm.getMetrics().isEmpty()
|
||||
&& alarm.getNamespace() != null && !alarm.getNamespace().isBlank()
|
||||
&& alarm.getMetricName() != null && !alarm.getMetricName().isBlank()
|
||||
&& alarm.getStatistic() != null && !alarm.getStatistic().isBlank()
|
||||
&& alarm.getPeriod() != null && alarm.getPeriod() > 0
|
||||
&& alarm.getEvaluationPeriods() > 0
|
||||
&& alarm.getComparisonOperator() != null;
|
||||
|
||||
+4
@@ -335,6 +335,7 @@ public class CloudWatchMetricsJsonHandler {
|
||||
alarm.setMetricName(request.path("MetricName").asText(null));
|
||||
alarm.setNamespace(request.path("Namespace").asText(null));
|
||||
alarm.setStatistic(request.path("Statistic").asText(null));
|
||||
alarm.setExtendedStatistic(request.path("ExtendedStatistic").asText(null));
|
||||
JsonNode metrics = request.path("Metrics");
|
||||
if (metrics.isArray()) {
|
||||
for (JsonNode query : metrics) {
|
||||
@@ -449,6 +450,9 @@ public class CloudWatchMetricsJsonHandler {
|
||||
if (a.getStatistic() != null) {
|
||||
node.put("Statistic", a.getStatistic());
|
||||
}
|
||||
if (a.getExtendedStatistic() != null) {
|
||||
node.put("ExtendedStatistic", a.getExtendedStatistic());
|
||||
}
|
||||
ArrayNode dimensions = node.putArray("Dimensions");
|
||||
a.getDimensions().forEach(d -> {
|
||||
ObjectNode dimNode = dimensions.addObject();
|
||||
|
||||
+2
@@ -827,6 +827,7 @@ public class CloudWatchMetricsQueryHandler {
|
||||
a.setMetricName(params.getFirst("MetricName"));
|
||||
a.setNamespace(params.getFirst("Namespace"));
|
||||
a.setStatistic(params.getFirst("Statistic"));
|
||||
a.setExtendedStatistic(params.getFirst("ExtendedStatistic"));
|
||||
a.setMetrics(parseAlarmMetricQueries(params));
|
||||
a.setPeriod(a.getMetrics().isEmpty() ? parseIntParam(params, "Period", 60) : null);
|
||||
a.setUnit(params.getFirst("Unit"));
|
||||
@@ -924,6 +925,7 @@ public class CloudWatchMetricsQueryHandler {
|
||||
.elem("MetricName", a.getMetricName())
|
||||
.elem("Namespace", a.getNamespace())
|
||||
.elem("Statistic", a.getStatistic())
|
||||
.elem("ExtendedStatistic", a.getExtendedStatistic())
|
||||
.elem("Period", a.getPeriod() == null ? null : a.getPeriod().toString())
|
||||
.elem("Unit", a.getUnit());
|
||||
}
|
||||
|
||||
@@ -436,6 +436,12 @@ public class CloudWatchMetricsService {
|
||||
rejectEvaluationInterval(alarm.getAlarmName(), evaluationInterval,
|
||||
alarm.getMetricName() != null || !alarm.getMetrics().isEmpty());
|
||||
}
|
||||
if (alarm.getStatistic() != null && !alarm.getStatistic().isBlank()
|
||||
&& alarm.getExtendedStatistic() != null && !alarm.getExtendedStatistic().isBlank()) {
|
||||
throw new AwsException("ValidationError",
|
||||
"PutMetricAlarm request can not be made with both Statistic and ExtendedStatistic parameters. "
|
||||
+ "Only one of them should be present", 400);
|
||||
}
|
||||
boolean created = alarmStore.get(region + "::" + alarm.getAlarmName()).isEmpty();
|
||||
putAlarm(alarm, region);
|
||||
if (created) {
|
||||
|
||||
@@ -15,6 +15,7 @@ public class MetricAlarm extends Alarm {
|
||||
private String metricName;
|
||||
private String namespace;
|
||||
private String statistic;
|
||||
private String extendedStatistic;
|
||||
private List<Dimension> dimensions = new ArrayList<>();
|
||||
/** Single-metric period; absent for alarms whose periods are defined in Metrics. */
|
||||
private Integer period;
|
||||
@@ -43,6 +44,9 @@ public class MetricAlarm extends Alarm {
|
||||
public String getStatistic() { return statistic; }
|
||||
public void setStatistic(String statistic) { this.statistic = statistic; }
|
||||
|
||||
public String getExtendedStatistic() { return extendedStatistic; }
|
||||
public void setExtendedStatistic(String extendedStatistic) { this.extendedStatistic = extendedStatistic; }
|
||||
|
||||
public List<Dimension> getDimensions() { return dimensions; }
|
||||
public void setDimensions(List<Dimension> dimensions) { this.dimensions = dimensions; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user