cloudwatch-sender 0.2.0 → 0.3.0
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/.ruby-version +1 -1
- data/cloudwatch-sender.gemspec +1 -0
- data/configs/example.yaml +8 -2
- data/lib/cloudwatch/sender/base.rb +13 -18
- data/lib/cloudwatch/sender/cli.rb +6 -2
- data/lib/cloudwatch/sender/fetcher/base.rb +3 -6
- data/lib/cloudwatch/sender/fetcher/custom.rb +11 -4
- data/lib/cloudwatch/sender/fetcher/ec2.rb +9 -4
- data/lib/cloudwatch/sender/fetcher/sqs.rb +9 -4
- data/lib/cloudwatch/sender/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db3623e303865b8a0f9a3cc6de29d4bab86744ab
|
4
|
+
data.tar.gz: 71a77cee896132748aad7ed8cd5e1582a844c444
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 527103a349e4e7ac3a02beadb61749b79999e32e7fd12f12da539baeddb486d763f89a0646a8d2724b00fd15bb56a791882fca19ce0227af5b568b5412862f2d
|
7
|
+
data.tar.gz: 6e336af7696e74afc34260921d41425d0615aa9e5ff291e163349590f4ecc603acae69041e5ab00bd4d83ddefbc7dfca1576d9cec19985443c00b025634ff4d9
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.0
|
data/cloudwatch-sender.gemspec
CHANGED
data/configs/example.yaml
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
---
|
2
2
|
metric_prefix: "cloudwatch"
|
3
|
-
|
4
|
-
|
3
|
+
influx_options:
|
4
|
+
influx_host: "influxdb.domain.com"
|
5
|
+
influx_database: cloudwatch
|
6
|
+
influx_ssl: true
|
7
|
+
influx_verify_ssl: true
|
8
|
+
influx_ssl_ca_cert: "/path/to/certs"
|
9
|
+
influx_username: "username"
|
10
|
+
influx_password: "password"
|
5
11
|
|
6
12
|
metric_types:
|
7
13
|
## EC2 Metrics
|
@@ -1,27 +1,22 @@
|
|
1
|
-
require "json"
|
2
|
-
require "yaml"
|
3
|
-
|
4
1
|
module Cloudwatch
|
5
2
|
module Sender
|
6
3
|
class Base
|
7
|
-
|
8
|
-
@influx_server = server
|
9
|
-
@influx_port = port
|
10
|
-
end
|
4
|
+
attr_reader :influxdb, :metric_prefix
|
11
5
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
6
|
+
def initialize(options, metric_prefix)
|
7
|
+
@metric_prefix = metric_prefix
|
8
|
+
@influxdb = InfluxDB::Client.new "graphite",
|
9
|
+
:username => options["influx_username"],
|
10
|
+
:password => options["influx_password"],
|
11
|
+
:use_ssl => options["influx_ssl"] || false,
|
12
|
+
:verify_ssl => options["influx_verify_ssl"] || false,
|
13
|
+
:ssl_ca_cert => options["influx_ssl_ca_cert"] || false,
|
14
|
+
:host => options["influx_host"] || false
|
20
15
|
end
|
21
16
|
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
def write_data(data)
|
18
|
+
influxdb.write_point(metric_prefix, data)
|
19
|
+
end
|
25
20
|
end
|
26
21
|
end
|
27
22
|
end
|
@@ -1,5 +1,10 @@
|
|
1
1
|
require "thor"
|
2
|
+
require "json"
|
3
|
+
require "yaml"
|
2
4
|
require "logger"
|
5
|
+
require "openssl"
|
6
|
+
require "influxdb"
|
7
|
+
require "cloudwatch/sender/base"
|
3
8
|
require "cloudwatch/sender/ec2"
|
4
9
|
require "cloudwatch/sender/credentials"
|
5
10
|
require "cloudwatch/sender/metric_definition"
|
@@ -13,7 +18,7 @@ module Cloudwatch
|
|
13
18
|
class CLI < Thor
|
14
19
|
include Thor::Actions
|
15
20
|
|
16
|
-
class_option :provider, :desc => "AWS security provider", :required => false, :enum =>
|
21
|
+
class_option :provider, :desc => "AWS security provider", :required => false, :enum => %w(iam instance_profile)
|
17
22
|
class_option :access_key_id, :desc => "AWS access_key_id", :required => false
|
18
23
|
class_option :secret_access_key, :desc => "AWS secret_key_id", :required => false
|
19
24
|
class_option :region, :desc => "AWS region", :required => false
|
@@ -44,7 +49,6 @@ module Cloudwatch
|
|
44
49
|
end
|
45
50
|
end
|
46
51
|
|
47
|
-
|
48
52
|
no_commands do
|
49
53
|
def load_metrics(metrics_file)
|
50
54
|
YAML.load(File.open(metrics_file))
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require "cloudwatch/sender/base"
|
2
|
-
|
3
1
|
module Cloudwatch
|
4
2
|
module Sender
|
5
3
|
module Fetcher
|
@@ -28,8 +26,7 @@ module Cloudwatch
|
|
28
26
|
end
|
29
27
|
|
30
28
|
def fetcher(component_meta)
|
31
|
-
namespace.start_with?("AWS/") ? Object.const_get(class_namespace component_meta)
|
32
|
-
: Cloudwatch::Sender::Fetcher::Custom
|
29
|
+
namespace.start_with?("AWS/") ? Object.const_get(class_namespace component_meta) : Cloudwatch::Sender::Fetcher::Custom
|
33
30
|
end
|
34
31
|
|
35
32
|
def class_namespace(component_meta)
|
@@ -42,13 +39,13 @@ module Cloudwatch
|
|
42
39
|
|
43
40
|
def metric_type(component_meta, metric)
|
44
41
|
fetcher(component_meta).new(
|
45
|
-
cloudwatch, sender
|
42
|
+
cloudwatch, sender
|
46
43
|
).metrics(component_meta, metric)
|
47
44
|
end
|
48
45
|
|
49
46
|
def sender
|
50
47
|
Cloudwatch::Sender::Base.new(
|
51
|
-
components["
|
48
|
+
components["influx_options"], metric_prefix
|
52
49
|
)
|
53
50
|
end
|
54
51
|
end
|
@@ -2,12 +2,11 @@ module Cloudwatch
|
|
2
2
|
module Sender
|
3
3
|
module Fetcher
|
4
4
|
class Custom
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :cloudwatch, :sender, :database
|
6
6
|
|
7
|
-
def initialize(cloudwatch, sender
|
7
|
+
def initialize(cloudwatch, sender)
|
8
8
|
@cloudwatch = cloudwatch
|
9
9
|
@sender = sender
|
10
|
-
@metric_prefix = metric_prefix
|
11
10
|
end
|
12
11
|
|
13
12
|
START_TIME = 180
|
@@ -37,7 +36,15 @@ module Cloudwatch
|
|
37
36
|
|
38
37
|
def check_statistics(name, label, statistics, time, data)
|
39
38
|
statistics.each do |stat|
|
40
|
-
|
39
|
+
data = {
|
40
|
+
:tags => {
|
41
|
+
name.tr("^A-Za-z0-9", "") => label.downcase
|
42
|
+
},
|
43
|
+
:timestamp => time,
|
44
|
+
:values => { :value => data[stat.downcase] }
|
45
|
+
}
|
46
|
+
|
47
|
+
sender.write_data(data)
|
41
48
|
end
|
42
49
|
end
|
43
50
|
end
|
@@ -2,10 +2,9 @@ module Cloudwatch
|
|
2
2
|
module Sender
|
3
3
|
module Fetcher
|
4
4
|
class EC2
|
5
|
-
def initialize(cloudwatch, sender
|
5
|
+
def initialize(cloudwatch, sender)
|
6
6
|
@cloudwatch = cloudwatch
|
7
7
|
@sender = sender
|
8
|
-
@metric_prefix = metric_prefix
|
9
8
|
end
|
10
9
|
|
11
10
|
def metrics(component_meta, metric)
|
@@ -14,7 +13,7 @@ module Cloudwatch
|
|
14
13
|
|
15
14
|
private
|
16
15
|
|
17
|
-
attr_reader :
|
16
|
+
attr_reader :cloudwatch, :sender
|
18
17
|
|
19
18
|
START_TIME = 180
|
20
19
|
|
@@ -61,7 +60,13 @@ module Cloudwatch
|
|
61
60
|
|
62
61
|
def check_statistics(instanceid, name, label, statistics, time, data)
|
63
62
|
statistics.each do |stat|
|
64
|
-
|
63
|
+
data = {
|
64
|
+
:tags => { name.tr("^A-Za-z0-9", "") => label.downcase, "instance" => instanceid.tr("-", "") },
|
65
|
+
:timestamp => time,
|
66
|
+
:values => { :value => data[stat.downcase] }
|
67
|
+
}
|
68
|
+
|
69
|
+
sender.write_data(data)
|
65
70
|
end
|
66
71
|
end
|
67
72
|
end
|
@@ -2,12 +2,11 @@ module Cloudwatch
|
|
2
2
|
module Sender
|
3
3
|
module Fetcher
|
4
4
|
class SQS
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :cloudwatch, :sender
|
6
6
|
|
7
|
-
def initialize(cloudwatch, sender
|
7
|
+
def initialize(cloudwatch, sender)
|
8
8
|
@cloudwatch = cloudwatch
|
9
9
|
@sender = sender
|
10
|
-
@metric_prefix = metric_prefix
|
11
10
|
end
|
12
11
|
|
13
12
|
START_TIME = 1200
|
@@ -39,7 +38,13 @@ module Cloudwatch
|
|
39
38
|
|
40
39
|
def check_statistics(name, label, statistics, time, data, queue_name)
|
41
40
|
statistics.each do |stat|
|
42
|
-
|
41
|
+
data = {
|
42
|
+
:tags => { name => label.downcase, "queue_name" => queue_name },
|
43
|
+
:timestamp => time,
|
44
|
+
:values => { :value => data[stat.downcase] }
|
45
|
+
}
|
46
|
+
|
47
|
+
sender.write_data(data)
|
43
48
|
end
|
44
49
|
end
|
45
50
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudwatch-sender
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DaveBlooman
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-08-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -67,6 +67,20 @@ dependencies:
|
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: influxdb
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
70
84
|
description: Get metrics from Cloudwatch and send to Graphite/InfluxDB
|
71
85
|
email:
|
72
86
|
- david.blooman@gmail.com
|
@@ -116,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
130
|
version: '0'
|
117
131
|
requirements: []
|
118
132
|
rubyforge_project:
|
119
|
-
rubygems_version: 2.
|
133
|
+
rubygems_version: 2.4.5
|
120
134
|
signing_key:
|
121
135
|
specification_version: 4
|
122
136
|
summary: Cloudwatch Metrics Sender
|