routes_alerts 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/routes_alerts/configuration.rb +8 -2
- data/lib/routes_alerts/metrics/base.rb +9 -1
- data/lib/routes_alerts/metrics/count.rb +1 -1
- data/lib/routes_alerts/metrics/duration.rb +1 -1
- data/lib/routes_alerts/metrics/success_rate.rb +1 -1
- data/lib/routes_alerts/route_info.rb +3 -2
- metadata +15 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 92131a5f7b38af9fe9231c310f5ca90afd4a3ce743337482aa0cbfbbe115c4b6
|
|
4
|
+
data.tar.gz: 46e557e104ef4386e87bd9e8bdca4279ecd9b1cad899843f2eb09df1650f36ad
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c59c2d012a2c16e26de4fff874c737ddcf9d8e39a0d8b785885b9ae6c92c353a2429edc15a3fb56d8b388eb0de272365091cfc707f40d51eb15d63836b95c652
|
|
7
|
+
data.tar.gz: 25184b18c6f6351ebbd75eb7495d1252b493c85d02393384c00ecb7fee1cfb1c4f48c7aef8c19bb1c615e13165f7f33990655847f694a788fc1aeb6bbba12378
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'aws-sdk-cloudwatchlogs'
|
|
2
|
+
require 'aws-sdk-cloudwatch'
|
|
2
3
|
require_relative "./metrics.rb"
|
|
3
4
|
require_relative "./route_info.rb"
|
|
4
5
|
|
|
@@ -20,10 +21,13 @@ module RoutesAlerts
|
|
|
20
21
|
:default_log_group_name,
|
|
21
22
|
:default_namespace,
|
|
22
23
|
:cloudwatch_logs,
|
|
23
|
-
:
|
|
24
|
+
:cloudwatch,
|
|
25
|
+
:default_actions,
|
|
26
|
+
:prefix
|
|
24
27
|
|
|
25
28
|
def initialize
|
|
26
29
|
@cloudwatch_logs = Aws::CloudWatchLogs::Client.new(region: "us-west-2")
|
|
30
|
+
@cloudwatch = Aws::CloudWatch::Client.new(region: "us-west-2")
|
|
27
31
|
@default_alarm_period = DEFAULT_ALARM_PERIOD
|
|
28
32
|
@default_number_of_datapoints = DEFAULT_NUMBER_OF_DATAPOINTS
|
|
29
33
|
@default_max_duration = DEFAULT_MAX_DURATION
|
|
@@ -32,6 +36,7 @@ module RoutesAlerts
|
|
|
32
36
|
@default_metrics = RoutesAlerts::Metrics::DEFAULT_METRICS
|
|
33
37
|
@routes = []
|
|
34
38
|
@default_actions = []
|
|
39
|
+
@prefix = ""
|
|
35
40
|
end
|
|
36
41
|
|
|
37
42
|
def add_route(path:, method:, max_duration: nil, min_count: nil, success_rate: nil, alarm_period: nil, number_of_datapoints: nil, metrics: nil, namespace: nil, log_group_name: nil, actions: nil)
|
|
@@ -46,7 +51,8 @@ module RoutesAlerts
|
|
|
46
51
|
log_group_name: (log_group_name || default_log_group_name),
|
|
47
52
|
namespace: (namespace || default_namespace),
|
|
48
53
|
actions: (actions || default_actions),
|
|
49
|
-
metrics: (metrics || default_metrics)
|
|
54
|
+
metrics: (metrics || default_metrics),
|
|
55
|
+
prefix: prefix
|
|
50
56
|
)
|
|
51
57
|
self.routes << route_info
|
|
52
58
|
end
|
|
@@ -16,7 +16,7 @@ class RoutesAlerts::Base
|
|
|
16
16
|
|
|
17
17
|
def create!
|
|
18
18
|
config.cloudwatch_logs.put_metric_filter(metric_params)
|
|
19
|
-
config.
|
|
19
|
+
config.cloudwatch.put_metric_alarm(alarm_params)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def log_group_name
|
|
@@ -34,4 +34,12 @@ class RoutesAlerts::Base
|
|
|
34
34
|
def actions
|
|
35
35
|
route_info.actions.any? ? route_info.actions : nil
|
|
36
36
|
end
|
|
37
|
+
|
|
38
|
+
def prefix
|
|
39
|
+
if route_info.prefix.empty?
|
|
40
|
+
""
|
|
41
|
+
else
|
|
42
|
+
"#{route_info.prefix}-"
|
|
43
|
+
end
|
|
44
|
+
end
|
|
37
45
|
end
|
|
@@ -24,7 +24,7 @@ class RoutesAlerts::Count < RoutesAlerts::Base
|
|
|
24
24
|
|
|
25
25
|
def alarm_params
|
|
26
26
|
{
|
|
27
|
-
alarm_name: "Alarm-#{RoutesAlerts::Metrics::COUNT_METRIC_NAME}-#{route_name}",
|
|
27
|
+
alarm_name: "#{prefix}Alarm-#{RoutesAlerts::Metrics::COUNT_METRIC_NAME}-#{route_name}",
|
|
28
28
|
actions_enabled: !!actions&.any?,
|
|
29
29
|
ok_actions: actions,
|
|
30
30
|
alarm_actions: actions,
|
|
@@ -24,7 +24,7 @@ class RoutesAlerts::Duration < RoutesAlerts::Base
|
|
|
24
24
|
|
|
25
25
|
def alarm_params
|
|
26
26
|
{
|
|
27
|
-
alarm_name: "Alarm-#{RoutesAlerts::Metrics::DURATION_METRIC_NAME}-#{route_name}",
|
|
27
|
+
alarm_name: "#{prefix}Alarm-#{RoutesAlerts::Metrics::DURATION_METRIC_NAME}-#{route_name}",
|
|
28
28
|
actions_enabled: !!actions&.any?,
|
|
29
29
|
ok_actions: actions,
|
|
30
30
|
alarm_actions: actions,
|
|
@@ -24,7 +24,7 @@ class RoutesAlerts::SuccessRate < RoutesAlerts::Base
|
|
|
24
24
|
|
|
25
25
|
def alarm_params
|
|
26
26
|
{
|
|
27
|
-
alarm_name: "Alarm-#{RoutesAlerts::Metrics::SUCCESS_METRIC_NAME}-#{route_name}",
|
|
27
|
+
alarm_name: "#{prefix}Alarm-#{RoutesAlerts::Metrics::SUCCESS_METRIC_NAME}-#{route_name}",
|
|
28
28
|
actions_enabled: !!actions&.any?,
|
|
29
29
|
ok_actions: actions,
|
|
30
30
|
alarm_actions: actions,
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
class RoutesAlerts::RouteInfo
|
|
3
3
|
attr_reader :path, :method, :max_duration, :min_count, :success_rate,
|
|
4
4
|
:alarm_period, :number_of_datapoints, :metrics, :namespace,
|
|
5
|
-
:log_group_name, :actions
|
|
5
|
+
:log_group_name, :actions, :prefix
|
|
6
6
|
|
|
7
|
-
def initialize(path:, method:, max_duration:, min_count:, success_rate:, alarm_period:, number_of_datapoints:, metrics:, namespace:, log_group_name:, actions:)
|
|
7
|
+
def initialize(path:, method:, max_duration:, min_count:, success_rate:, alarm_period:, number_of_datapoints:, metrics:, namespace:, log_group_name:, actions:, prefix: "")
|
|
8
8
|
@path = path.to_s
|
|
9
9
|
@method = method.to_s.upcase
|
|
10
10
|
@max_duration = max_duration.to_f
|
|
@@ -16,5 +16,6 @@ class RoutesAlerts::RouteInfo
|
|
|
16
16
|
@namespace = namespace.to_s
|
|
17
17
|
@log_group_name = log_group_name.to_s
|
|
18
18
|
@actions = actions || []
|
|
19
|
+
@prefix = prefix.to_s
|
|
19
20
|
end
|
|
20
21
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: routes_alerts
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ''
|
|
@@ -23,6 +23,20 @@ dependencies:
|
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '1.32'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: aws-sdk-cloudwatch
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '1.32'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '1.32'
|
|
26
40
|
description: Allows you to create metrics (for reporting, dashboards) and alerts for
|
|
27
41
|
request time, count and response code based on your routes.
|
|
28
42
|
email: jarrett.baugh@gmail.com
|