as-combined-metrics 1.0.1 → 1.0.2
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/combinedMetrics-sample.yml +2 -1
- data/lib/as-combined-metrics.rb +1 -1
- data/lib/as-combined-metrics/aws.rb +1 -1
- data/lib/as-combined-metrics/cloudformation.rb +3 -2
- data/lib/as-combined-metrics/cloudwatch.rb +8 -4
- data/lib/as-combined-metrics/config.rb +1 -3
- data/lib/as-combined-metrics/poller.rb +20 -19
- data/lib/as-combined-metrics/stats.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 860f7bd0212371eb68b2b88c4848fbce9abb6b74
|
4
|
+
data.tar.gz: e3b13e84240628a148855adbfb3db42e71113015
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e60393b591a44e014bcae4516aa3c3f79de1c6e60d1369153fbef7eb7ed63a5be4505acf2a785979e27fff1790ac6831d5d4e5f77b586a2d0d4a46881bba9029
|
7
|
+
data.tar.gz: eb2e60d5c85f5d1ad9a5fbc627ed62e8acdee918437252e6943dc26064d891dbc50589df3c78e70b9fcf0285ee21e223afc38a079093ff06a74db61d751fc53f
|
data/combinedMetrics-sample.yml
CHANGED
data/lib/as-combined-metrics.rb
CHANGED
@@ -35,7 +35,7 @@ module AsCombinedMetrics::Cli::Aws
|
|
35
35
|
logger.info { set_color "STACK_NAME was found in the config file #{@config[:cloudformation][:stack_name]}", :cyan }
|
36
36
|
@stack_name = @config[:cloudformation][:stack_name]
|
37
37
|
else
|
38
|
-
logger.fatal { set_color "verify_stack_name_env Env variable STACK_NAME
|
38
|
+
logger.fatal { set_color "verify_stack_name_env Can't find Env variable STACK_NAME or a setting (stack_name: STACK_NAME_X) in the config file , exiting now...", :red }
|
39
39
|
exit 1
|
40
40
|
end
|
41
41
|
end
|
@@ -16,7 +16,8 @@ module AsCombinedMetrics::Cli::CloudFormation
|
|
16
16
|
|
17
17
|
if !stack_info.nil?
|
18
18
|
@autoscale_group_name = stack_info.stack_resource_detail.physical_resource_id
|
19
|
-
@config[
|
19
|
+
@config[:autoscale_group_name] ||= []
|
20
|
+
@config[:autoscale_group_name] << @autoscale_group_name
|
20
21
|
File.open(options[:config_file], "w") { |f| f.write(@config.to_yaml) }
|
21
22
|
logger.info { set_color "AutoScale Group Name: #{@autoscale_group_name}", :cyan }
|
22
23
|
end
|
@@ -27,7 +28,7 @@ module AsCombinedMetrics::Cli::CloudFormation
|
|
27
28
|
end
|
28
29
|
|
29
30
|
if @print_log
|
30
|
-
logger.error { set_color "Unable to find the resource - #{e}", :yellow }
|
31
|
+
logger.error { set_color "Unable to find the resource - #{e}, maybe wrong region or wrong AWS account?", :yellow }
|
31
32
|
logger.info { "Will retry every 5 seconds up to maximum of #{options[:timeout]} seconds" }
|
32
33
|
end
|
33
34
|
|
@@ -42,7 +42,7 @@ module AsCombinedMetrics::Cli::CloudWatch
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
def publish_metric(mode, combined_metric_value)
|
45
|
+
def publish_metric(mode, asg, combined_metric_value)
|
46
46
|
logger.progname = "#{Module.nesting.first.to_s} #{__method__}"
|
47
47
|
|
48
48
|
cw_options = {
|
@@ -51,7 +51,7 @@ module AsCombinedMetrics::Cli::CloudWatch
|
|
51
51
|
metric_name: combined_metrics_name(mode),
|
52
52
|
dimensions: [{
|
53
53
|
name: 'AutoScalingGroupName',
|
54
|
-
value:
|
54
|
+
value: asg
|
55
55
|
}],
|
56
56
|
value: combined_metric_value,
|
57
57
|
unit: 'None'
|
@@ -60,8 +60,12 @@ module AsCombinedMetrics::Cli::CloudWatch
|
|
60
60
|
logger.info { set_color "Options to be sent to cloudwatch: #{cw_options}", :white }
|
61
61
|
|
62
62
|
begin
|
63
|
-
|
64
|
-
|
63
|
+
if options[:dryrun]
|
64
|
+
logger.info { set_color "DryRun! Not Publishing Combined Metrics to CloudWatch...", :white }
|
65
|
+
else
|
66
|
+
logger.info { set_color "Publishing Combined Metrics to CloudWatch...", :white }
|
67
|
+
@cw.put_metric_data(cw_options)
|
68
|
+
end
|
65
69
|
rescue Exception => e
|
66
70
|
logger.error { set_color "An error occured #{e}, SDK will retry up to 3 times", :red }
|
67
71
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'digest/sha1'
|
2
|
-
|
3
2
|
class ConfigError < StandardError
|
4
3
|
end
|
5
4
|
|
@@ -49,9 +48,8 @@ module AsCombinedMetrics::Cli::Config
|
|
49
48
|
|
50
49
|
def process
|
51
50
|
logger.progname = "#{Module.nesting.first.to_s} #{__method__}"
|
52
|
-
|
53
51
|
if @config.has_key?(:autoscale_group_name)
|
54
|
-
|
52
|
+
@config[:autoscale_group_name].each {|g| validate_as_group(g)}
|
55
53
|
elsif @config[:cloudformation][:enabled]
|
56
54
|
verify_stack_name
|
57
55
|
|
@@ -13,31 +13,32 @@ module AsCombinedMetrics::Cli::Poller
|
|
13
13
|
|
14
14
|
loop do
|
15
15
|
modes.each do |mode|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
@config[:autoscale_group_name].each do |autoscale_group|
|
17
|
+
logger.info "Polling metrics for #{autoscale_group} AutoScale Group on #{mode}"
|
18
|
+
@config[mode].each do |metric|
|
19
|
+
logger.debug "Getting stats for #{autoscale_group} AutoScale Group on metric #{metric}"
|
20
|
+
@combined_metrics[metric[:metric_name]] ||= {}
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
if metric.has_key?(:aggregate_as_group)
|
23
|
+
logger.debug "Aggregating autoscale group metrics"
|
24
|
+
@combined_metrics[metric[:metric_name]][:measure] = aggregate_instances_per_as_group(metric)
|
25
|
+
else
|
26
|
+
metric[:dimensions] = [{ name: "AutoScalingGroupName", value: autoscale_group}]
|
27
|
+
@combined_metrics[metric[:metric_name]][:measure] = fetch_metric(metric) unless @combined_metrics[metric[:metric_name]].has_key?(:measure)
|
28
|
+
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
@combined_metrics[metric[:metric_name]][:threshold] = metric[:threshold]
|
31
|
+
@combined_metrics[metric[:metric_name]][:comparison_operator] = metric[:comparison_operator]
|
32
|
+
end
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
logger.info { set_color "Combined metrics attributes for #{autoscale_group} AutoScale Group on #{mode}: #{@combined_metrics}", :cyan }
|
35
|
+
combined_metric_value = check_combined_metrics(mode)
|
36
36
|
|
37
|
-
|
37
|
+
logger.info { set_color "Combined metrics value for #{autoscale_group} AutoScale Group: #{combined_metric_value} => [0 = Do Not #{mode}, 1 = OK To #{mode}]", :yellow, :bold }
|
38
38
|
|
39
|
-
|
39
|
+
publish_metric(mode, autoscale_group, combined_metric_value)
|
40
40
|
end
|
41
|
+
end
|
41
42
|
|
42
43
|
if options[:once]
|
43
44
|
logger.info { set_color "Ran Once - Exiting now..." }
|
@@ -31,7 +31,7 @@ module AsCombinedMetrics::Cli::Stats
|
|
31
31
|
exit
|
32
32
|
end
|
33
33
|
|
34
|
-
logger.info { set_color "Combined results of #{results_array} for #{mode} is: #{combined_metric_value}", :
|
34
|
+
logger.info { set_color "Combined results of #{results_array} for #{mode} is: #{combined_metric_value}", :magenta }
|
35
35
|
|
36
36
|
return combined_metric_value
|
37
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: as-combined-metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ami Mahloof
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|