cloudwatch-metrics 0.1.11 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dce097d501539877de89d8451ef1c4f3fe2a96cbaebee60a06292b733696e30d
4
- data.tar.gz: c65b336e84a4ed3c6c185b582e1e3488e2e95edfd01dab02f7a7d68c3e084e04
3
+ metadata.gz: f81642066454cacb68f5e5d76f7cee30aae9cb09d9db2dd9a1026a102c974f3f
4
+ data.tar.gz: 33ad13c41b6caa0fb8da1a538ca11cc2a11a688f012daee58ba39eeb82e6c441
5
5
  SHA512:
6
- metadata.gz: 5decfcc8b1023d215c7771e3548888f6c3c5cddca8f23eee819d258b811ec3b1cca4c30114da6a9cf02312b1bcc1b6034477509539e40b41c83c7e47069c2bef
7
- data.tar.gz: 386f21b0c4efe665d3b01963c9ffc236b9e9c4a22bd33d2f0f651b25076cac4bfde3ce9e985791074b28ee97c0296ee69fd6472a9c5c9e32243a82ea87edcc88
6
+ metadata.gz: d676d266e1d6bb2f9468b2fd6b9bf3b348cec4a59bcea379201b68762487849de78fdab7acdde876a0b7df1aa57440938e8657bb0f3d0870cf64a983d4c7263d
7
+ data.tar.gz: 56e203e9bdad56fe89626309ec86ee2bfcae8879a262471034b9ebaad0c4e6093f5d7b96767108d91468a28dbee7db4db0f6bd7e4202eb26adaebd96ccf736d0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cloudwatch-metrics (0.1.7)
4
+ cloudwatch-metrics (0.1.11)
5
5
  aws-sdk-cloudwatch (~> 1.73)
6
6
  rake (~> 13.0)
7
7
  rspec (~> 3.0)
data/README.md CHANGED
@@ -57,6 +57,17 @@ Both reporting methods accept optional parameters, which are detailed below, alo
57
57
  * `dimensions`: An array of name/value pairs that form part of the identity of a metric. Dimensions allow you to group and filter data points within a particular metric. Default is `nil`.
58
58
  * `timestamp`: The time associated with the data point. The timestamp can be up to two weeks in the past and up to two hours into the future. Default is the current time.
59
59
 
60
+ ### AWS Credentials
61
+
62
+ See [HOWTO Assume AWS role](https://docs.google.com/document/d/1NCXtlhddpJCttBPs2V4mv3J59V0C3ShTzaoSidBAVTU/edit#heading=h.kr4pxvf3gqqt) for info about setting up AWS credential locally. You can read more about AWS SDK configuration in the [AWS docs](https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/setup-config.html).
63
+
64
+ The short version: Create a file `~/.aws/config` and add your access keys there:
65
+ ```
66
+ [default]
67
+ aws_access_key_id = $AWS_ACCESS_KEY_ID
68
+ aws_secret_access_key = $AWS_SECRET_ACCESS_KEY
69
+ ```
70
+
60
71
  ## Cloudwatch Concepts
61
72
 
62
73
  Refer to the [Cloudwatch Documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html) for a general overview of custom metrics in CloudWatch.
@@ -2,7 +2,7 @@
2
2
 
3
3
  module CloudwatchMetrics
4
4
  class Configuration
5
- attr_accessor :namespace
5
+ attr_accessor :namespace, :region
6
6
  attr_writer :no_cw_alias
7
7
 
8
8
  def no_cw_alias
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CloudwatchMetrics
4
- VERSION = "0.1.11"
4
+ VERSION = '0.1.13'
5
5
  end
@@ -15,10 +15,6 @@ module CloudwatchMetrics
15
15
  yield(configuration)
16
16
  end
17
17
 
18
- def hi
19
- puts "Hello, #{configuration.namespace}"
20
- end
21
-
22
18
  def record(
23
19
  metric_name:, value:, unit: nil, namespace: configuration.namespace, dimensions: [], timestamp: nil
24
20
  )
@@ -48,8 +44,12 @@ module CloudwatchMetrics
48
44
 
49
45
  private
50
46
 
47
+ def cloudwatch_client
48
+ @cloudwatch_client ||= Aws::CloudWatch::Client.new(region: configuration.region)
49
+ end
50
+
51
51
  def put_data(namespace:, metric_data:)
52
- resp = @cloudwatch_client.put_metric_data({
52
+ resp = cloudwatch_client.put_metric_data({
53
53
  namespace: namespace,
54
54
  metric_data: metric_data
55
55
  })
@@ -6,7 +6,7 @@ module CloudwatchMetrics
6
6
  source_root File.expand_path('templates', __dir__)
7
7
 
8
8
  def copy_initializer_file
9
- copy_file "cloudwatch_metrics.rb", "config/initializers/cloudwatch_metrics.rb"
9
+ copy_file 'cloudwatch_metrics.rb', 'config/initializers/cloudwatch_metrics.rb'
10
10
  end
11
11
  end
12
12
  end
@@ -11,4 +11,9 @@ CloudwatchMetrics.configure do |config|
11
11
  # `CW` alias. This is useful if you have a constant named `CW` that
12
12
  # conflicts with the alias. Default is `false`.
13
13
  # config.no_cw_alias = true
14
+
15
+ # This is an optional configuration to set the region that
16
+ # the metrics will be published to. This is useful if you want to publish
17
+ # to a region other than the default region for your AWS credentials.
18
+ # config.region = 'us-east-1'
14
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudwatch-metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Puckett