private void createCreateSlotsWidgetsAndAlarms()

in DeliveryApi/cdk/src/main/java/com/ilmlf/delivery/api/FunctionDashboard.java [122:199]


  private void createCreateSlotsWidgetsAndAlarms(FunctionDashboardProps props) {
    Map<String, String> dimensions = Map.of(
        DIMENSION_FUNCTION_NAME, props.createSlotsApiMethodName,
        DIMENSION_SERVICE_NAME, props.createSlotsFunctionName,
        DIMENSION_LOG_GROUP, props.createSlotsFunctionName,
        DIMENSION_SERVICE_TYPE, SERVICE_TYPE_LAMBDA
    );

    createCommonWidgetsAndAlarms(props.createSlotsFunctionName, props.createSlotsApiMethodName, props.alarmTopic);

    Metric invalidSlotListMetric = new Metric(MetricProps.builder()
        .metricName("InvalidSlotList")
        .namespace(DELIVERY_NAMESPACE)
        .dimensionsMap(dimensions)
        .period(Duration.minutes(5))
        .statistic("SUM")
        .label("CreateSlots Received Invalid Slot List")
        .build());

    Metric failedToSaveSlotsMetric = new Metric(MetricProps.builder()
        .metricName("FailedToSaveSlots")
        .namespace(DELIVERY_NAMESPACE)
        .dimensionsMap(dimensions)
        .period(Duration.minutes(5))
        .statistic("SUM")
        .label("CreateSlots Failed to Save Slots")
        .build());

    Metric exceptionMetric = new Metric(MetricProps.builder()
        .metricName("CreateSlotsException")
        .namespace(DELIVERY_NAMESPACE)
        .dimensionsMap(dimensions)
        .period(Duration.minutes(5))
        .statistic("SUM")
        .label("CreateSlots Insert Exception")
        .build());

    Alarm failedToSaveSlotsAlarm = new Alarm(this, props.createSlotsApiMethodName + "FailedToSaveSlotsAlarm",
        AlarmProps.builder()
          .alarmName(props.createSlotsFunctionName + "-FailedToSaveSlotsAlarm")
          .metric(failedToSaveSlotsMetric)
          .evaluationPeriods(1)
          .threshold(1)
          .build());

    Alarm exceptionAlarm = new Alarm(this, props.createSlotsApiMethodName + "ExceptionAlarm", AlarmProps.builder()
        .alarmName(props.createSlotsFunctionName + "-ExceptionsAlarm")
        .metric(exceptionMetric)
        .evaluationPeriods(1)
        .threshold(1)
        .build());

    failedToSaveSlotsAlarm.addAlarmAction(new SnsAction(props.alarmTopic));
    exceptionAlarm.addAlarmAction(new SnsAction(props.alarmTopic));

    GraphWidget invalidSlotListWidget = new GraphWidget(GraphWidgetProps.builder()
        .height(STANDARD_WIDGET_HEIGHT)
        .width(HALF_DASHBOARD_WIDTH)
        .left(List.of(invalidSlotListMetric))
        .title(props.createSlotsApiMethodName + "-InvalidSlotList")
        .build());

    AlarmWidget failedToSaveSlotsWidget = new AlarmWidget(AlarmWidgetProps.builder()
        .height(STANDARD_WIDGET_HEIGHT)
        .width(HALF_DASHBOARD_WIDTH)
        .alarm(failedToSaveSlotsAlarm)
        .title(props.createSlotsApiMethodName + "-FailedToSaveSlots")
        .build());

    AlarmWidget exceptionWidget = new AlarmWidget(AlarmWidgetProps.builder()
        .height(STANDARD_WIDGET_HEIGHT)
        .width(HALF_DASHBOARD_WIDTH)
        .alarm(exceptionAlarm)
        .title(props.createSlotsApiMethodName + "-Exceptions")
        .build());

    this.addWidgets(failedToSaveSlotsWidget, exceptionWidget, invalidSlotListWidget);
  }