Class: RoutesAlerts::Count

Inherits:
Base
  • Object
show all
Defined in:
lib/routes_alerts/metrics/count.rb

Instance Attribute Summary

Attributes inherited from Base

#config, #route_info

Instance Method Summary collapse

Methods inherited from Base

#actions, #create!, #initialize, #log_group_name, #namespace, #prefix, #route_name

Constructor Details

This class inherits a constructor from RoutesAlerts::Base

Instance Method Details

#alarm_paramsObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/routes_alerts/metrics/count.rb', line 25

def alarm_params
  {
    alarm_name: "#{prefix}Alarm-#{RoutesAlerts::Metrics::COUNT_METRIC_NAME}-#{route_name}",
    actions_enabled: !!actions&.any?,
    ok_actions: actions,
    alarm_actions: actions,
    metric_name: "#{RoutesAlerts::Metrics::COUNT_METRIC_NAME}-#{route_name}",
    namespace: namespace,
    statistic: "Sum",
    dimensions: [],
    period: route_info.alarm_period,
    unit: "Count",
    evaluation_periods: route_info.number_of_datapoints,
    datapoints_to_alarm: route_info.number_of_datapoints,
    threshold: route_info.min_count,
    comparison_operator: "LessThanOrEqualToThreshold",
    treat_missing_data: "notBreaching",
  }
end

#filter_patternObject



4
5
6
# File 'lib/routes_alerts/metrics/count.rb', line 4

def filter_pattern
  "{ $.path = \"#{route_info.path}\" && $.method = \"#{route_info.method}\" }"
end

#metric_paramsObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/routes_alerts/metrics/count.rb', line 8

def metric_params
  {
    log_group_name: log_group_name,
    filter_name: "#{RoutesAlerts::Metrics::COUNT_METRIC_NAME}-#{route_name}",
    filter_pattern: filter_pattern,
    metric_transformations: [
      {
        metric_name: "#{RoutesAlerts::Metrics::COUNT_METRIC_NAME}-#{route_name}",
        metric_namespace: namespace,
        metric_value: "1",
        default_value: 0,
        unit: "Count",
      },
    ]
  }
end