in DeliveryApi/cdk/src/main/java/com/ilmlf/delivery/api/FunctionDashboard.java [49:120]
private void createGetSlotsWidgetsAndAlarms(FunctionDashboardProps props) {
// The "FunctionName" dimension is a custom dimension added by the Lambdas to differentiate between functions, and
// corresponds to the props._ApiMethodName.
// It is not the same as props._FunctionName, which is a token that identifies the function within Cloudformation
Map<String, String> dimensions = Map.of(
DIMENSION_FUNCTION_NAME, props.getSlotsApiMethodName,
DIMENSION_SERVICE_NAME, props.getSlotsFunctionName,
DIMENSION_LOG_GROUP, props.getSlotsFunctionName,
DIMENSION_SERVICE_TYPE, SERVICE_TYPE_LAMBDA
);
createCommonWidgetsAndAlarms(props.getSlotsFunctionName, props.getSlotsApiMethodName, props.alarmTopic);
Metric noSlotsFoundMetric = new Metric(MetricProps.builder()
.metricName("NoSlotsFound")
.namespace(DELIVERY_NAMESPACE)
.dimensionsMap(dimensions)
.period(Duration.minutes(5))
.statistic("SUM")
.label("GetSlots When Farm Has No Slots")
.build());
Metric slotsReturnedMetric = new Metric(MetricProps.builder()
.metricName("SlotsReturned")
.namespace(DELIVERY_NAMESPACE)
.dimensionsMap(dimensions)
.period(Duration.minutes(5))
.statistic("SUM")
.label("GetSlots Number of Slots Returned")
.build());
Metric sqlExceptionMetric = new Metric(MetricProps.builder()
.metricName("SqlException")
.namespace(DELIVERY_NAMESPACE)
.dimensionsMap(dimensions)
.period(Duration.minutes(5))
.statistic("SUM")
.label("GetSlots SqlException")
.build());
Alarm sqlExceptionAlarm = new Alarm(this, props.getSlotsApiMethodName + "SqlExceptionAlarm", AlarmProps.builder()
.alarmName(props.getSlotsFunctionName + "-SqlExceptionAlarm")
.metric(sqlExceptionMetric)
.evaluationPeriods(1)
.threshold(1)
.build());
sqlExceptionAlarm.addAlarmAction(new SnsAction(props.alarmTopic));
GraphWidget noSlotsFoundWidget = new GraphWidget(GraphWidgetProps.builder()
.height(STANDARD_WIDGET_HEIGHT)
.width(HALF_DASHBOARD_WIDTH)
.left(List.of(noSlotsFoundMetric))
.title(props.getSlotsApiMethodName + "-NoSlotsFound")
.build());
GraphWidget slotsReturnedWidget = new GraphWidget(GraphWidgetProps.builder()
.height(STANDARD_WIDGET_HEIGHT)
.width(HALF_DASHBOARD_WIDTH)
.left(List.of(slotsReturnedMetric))
.title(props.getSlotsApiMethodName + "-SlotsReturned")
.build());
AlarmWidget sqlExceptionWidget = new AlarmWidget(AlarmWidgetProps.builder()
.height(STANDARD_WIDGET_HEIGHT)
.width(FULL_DASHBOARD_WIDTH)
.alarm(sqlExceptionAlarm)
.title(props.getSlotsApiMethodName + "-SqlExceptions")
.build());
this.addWidgets(noSlotsFoundWidget, slotsReturnedWidget, sqlExceptionWidget);
}