sidewatch 0.0.3 → 0.0.4
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/.gitignore +1 -1
- data/.travis.yml +4 -0
- data/CHANGES.md +5 -0
- data/README.md +34 -2
- data/Rakefile +4 -0
- data/lib/sidewatch/cloudwatch.rb +10 -11
- data/lib/sidewatch/version.rb +1 -1
- data/spec/cloudwatch_spec.rb +11 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53c84c0248846f6f5a57673e78d31223408f9699
|
4
|
+
data.tar.gz: 668241adc7830ef651272445ae8597767f01e80f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d8838dd0d012f9745702dbcac17bcbe6f21b70cedf75a4a85feddad9d595856eed089d45a851da9bb27080e52eae3e3cca019858b147574dbdbd48618c495eb
|
7
|
+
data.tar.gz: 561da07d5a8d69f0b047ffa485f3b941e92d196dc62103e238644d91387b6fd98700d808c5c24f9511146e9376f62e8842bf298c7f1cead8fc2e979edf70eb38
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/CHANGES.md
ADDED
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Sidewatch
|
2
2
|
|
3
|
+
[](https://rubygems.org/gems/sidewatch)
|
4
|
+
[](https://travis-ci.org/travelmob/sidewatch)
|
5
|
+
|
3
6
|
Sidewatch uploads Sidekiq metrics to AWS CloudWatch in regular intervals.
|
4
7
|
|
5
8
|
## Installation
|
@@ -20,11 +23,40 @@ Or install it yourself as:
|
|
20
23
|
|
21
24
|
To start sidewatch as a daemon process in the background run
|
22
25
|
|
23
|
-
ruby bin/sidewatch start
|
26
|
+
ruby bin/sidewatch start [--config <path to config file>]
|
24
27
|
|
25
28
|
To run sidewatch in the foreground, e.g. for testing, run
|
26
29
|
|
27
|
-
ruby bin/sidewatch run
|
30
|
+
ruby bin/sidewatch run [--config <path to config file>]
|
31
|
+
|
32
|
+
## Configuration
|
33
|
+
|
34
|
+
### Using ENV variables
|
35
|
+
|
36
|
+
Sidewatch will use the same environment variables as Sidekiq to determine the Redis server to connect to, i.e. either `REDIS_PROVIDER` or `REDIS_URL`. Please refer to the [Sidekiq wiki](https://github.com/mperham/sidekiq/wiki/Using-Redis#using-an-env-variable) for more information.
|
37
|
+
|
38
|
+
Sidewatch uses the AWS SDK v2 to connect to CloudWatch. The SDK expects AWS credentials to be provided in one of these locations:
|
39
|
+
|
40
|
+
* `ENV['AWS_ACCESS_KEY_ID']` and `ENV['AWS_SECRET_ACCESS_KEY']`
|
41
|
+
* The shared credentials ini file at `~/.aws/credentials`
|
42
|
+
* From an instance profile when running on EC2
|
43
|
+
|
44
|
+
Please refer to the [SDK's documentation](http://docs.aws.amazon.com/sdkforruby/api/index.html#Configuration) for more information.
|
45
|
+
|
46
|
+
### Using the config file
|
47
|
+
|
48
|
+
When starting Sidewatch, you can pass a config file using the `--config` parameter. The config file should be in YAML format and supports the following keys:
|
49
|
+
|
50
|
+
````yaml
|
51
|
+
logfile: "/var/log/sidewatch.log"
|
52
|
+
sidekiq:
|
53
|
+
namespace: "Sidekiq" # namespace used when uploading AWS CloudWatch metrics
|
54
|
+
redis:
|
55
|
+
url: "redis://localhost:6379/0"
|
56
|
+
namespace: "sidekiq" # Redis key namespace used by Sidekiq
|
57
|
+
cloudwatch:
|
58
|
+
region: "us-west-2"
|
59
|
+
````
|
28
60
|
|
29
61
|
## Contributing
|
30
62
|
|
data/Rakefile
CHANGED
data/lib/sidewatch/cloudwatch.rb
CHANGED
@@ -3,6 +3,8 @@ require "aws-sdk"
|
|
3
3
|
module Sidewatch
|
4
4
|
class Cloudwatch
|
5
5
|
|
6
|
+
MAX_BATCH_SIZE = 20
|
7
|
+
|
6
8
|
attr_accessor :client
|
7
9
|
|
8
10
|
def initialize(config = {})
|
@@ -14,13 +16,19 @@ module Sidewatch
|
|
14
16
|
|
15
17
|
def send(metrics)
|
16
18
|
metrics.group_by(&:namespace).each do |ns, ns_metrics|
|
17
|
-
|
18
|
-
|
19
|
+
ns_metrics.each_slice(max_batch_size) do |slice|
|
20
|
+
data = metric_data(ns, slice)
|
21
|
+
client.put_metric_data(data)
|
22
|
+
end
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
22
26
|
private
|
23
27
|
|
28
|
+
def max_batch_size
|
29
|
+
MAX_BATCH_SIZE
|
30
|
+
end
|
31
|
+
|
24
32
|
def metric_data(ns, metrics)
|
25
33
|
{
|
26
34
|
namespace: ns,
|
@@ -36,14 +44,5 @@ module Sidewatch
|
|
36
44
|
}
|
37
45
|
end
|
38
46
|
|
39
|
-
class MockClient
|
40
|
-
def initialize(config = {})
|
41
|
-
@out = config.fetch(:output){ $stdout }
|
42
|
-
end
|
43
|
-
def put_metric_data(data)
|
44
|
-
@out << data.to_s
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
47
|
end
|
49
48
|
end
|
data/lib/sidewatch/version.rb
CHANGED
data/spec/cloudwatch_spec.rb
CHANGED
@@ -47,6 +47,17 @@ module Sidewatch
|
|
47
47
|
expect(received).to contain_exactly(hash_including(namespace: "Clocks"), hash_including(namespace: "Events"))
|
48
48
|
end
|
49
49
|
|
50
|
+
it "sends metrics in batches of max. 20 entries" do
|
51
|
+
metrics = []
|
52
|
+
25.times do |i|
|
53
|
+
metrics << Metric.new(namespace: "Clocks", name: "Ticks", value: i, unit: "Count")
|
54
|
+
end
|
55
|
+
|
56
|
+
subject.send(metrics)
|
57
|
+
|
58
|
+
expect(client).to have_received(:put_metric_data).exactly(2).times
|
59
|
+
end
|
60
|
+
|
50
61
|
end
|
51
62
|
|
52
63
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidewatch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Hecking
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -117,6 +117,8 @@ extensions: []
|
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
119
|
- .gitignore
|
120
|
+
- .travis.yml
|
121
|
+
- CHANGES.md
|
120
122
|
- Gemfile
|
121
123
|
- LICENSE.txt
|
122
124
|
- README.md
|