fluent-plugin-cloudwatch-transform 0.0.4 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd04f4ba0fff4e3fe7723aae95ac042e1e6d1947
4
- data.tar.gz: d7147b9d1f1de9c84b86ffe2fb596027e476ab59
3
+ metadata.gz: a025e5995d9b256900600da9feecbf60bbd67682
4
+ data.tar.gz: f193e656ccffe26f843e26d642151157c758b99a
5
5
  SHA512:
6
- metadata.gz: 12fe4bc88da9697f3a395cdf1ed5bc98f84fe3e09b356e7d9249bb6134c2babec85c83e958122b8bcb8f5dcc2f97c50ca6f70dbc73bbd235d750eb1aa397e8f8
7
- data.tar.gz: bb90d407337f5d4d861930b3c030d0ae873d4ae1469440fa21ea1defe89426853dd43faa1f33696e5748b2c12d2cffe6827147e86651ed8efdca7111f622bc51
6
+ metadata.gz: c283f6a9b5296a131ea618b42c6b88afe2ee168ea157d033141f57c9db1a2f3da95a56c1b3d188d43892b6d214aac7037efa58f1e215cc6497988af78b3d46dc
7
+ data.tar.gz: 5758b0ac68903a90700a9b19921df25346b843f46130e2fb39c7e2b6b9ea33fe3a5ad67b74728986e17f5ac933ace0bf063c2b9953014d6da7138f2c7669c3b7
data/README.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  fluent-plugin-cloudwatch-transform is an output plug-in for [Fluentd](http://fluentd.org)
4
4
 
5
+ It can transform the alerts from fluent-plugin-cloudwatch to key-value pairs as "event_name" and "value",
6
+ also add more information from the tag you added in fluent-plugin-cloudwatch.
7
+
8
+ It also used "highwatermark" gem to store status timestamp to state file or redis cache
9
+
5
10
  ## Installation
6
11
 
7
12
  These instructions assume you already have fluentd installed.
@@ -31,18 +36,21 @@ Or install it yourself as:
31
36
 
32
37
  $ gem build fluent-plugin-cloudwatch-transform.gemspec
33
38
 
34
- $ sudo gem install ./fluent-plugin-cloudwatch-transform-0.0.3.gem
39
+ $ sudo gem install ./fluent-plugin-cloudwatch-transform-0.0.5.gem
35
40
 
36
41
 
37
42
  ## Usage
38
43
 
39
44
  ### fluent configure
40
45
  require fluent-plugin-cloudwatch for input.
46
+ require highwatermark to store timestamp to file or redis
41
47
  Add the following into your fluentd config.
42
48
 
43
49
  <source>
44
50
  type cloudwatch
45
- tag #tag with application name, like: alert.cloudwatch.raw.Form & Printing Services (FPS)
51
+ tag #tag with prefix alert.cloudwatch.raw
52
+ # followed with region and availability zone, application name, wiki url in sequence
53
+ # for example: alert.cloudwatch.raw.region1-AZ1.Form & Printing Services (FPS)."http://runbook.wiki.com"
46
54
  aws_key_id #your id
47
55
  aws_sec_key #your key
48
56
  cw_endpoint #your endpoint
@@ -56,12 +64,26 @@ Add the following into your fluentd config.
56
64
  <match alert.cloudwatch.raw.**>
57
65
  type cloudwatch_transform
58
66
  tag alert.cloudwatch.out
67
+ state_type file #could be <redis/file/memory>
68
+ state_file /path/to/state/file/or/redis/conf # the file path for store state or the redis configure
69
+
59
70
  </match>
60
71
 
61
72
  <match alert.cloudwatch.out>
62
73
  type stdout
63
74
  </match>
64
75
 
76
+
77
+ Example of redis.conf (if set state_type = 'redis'):
78
+
79
+ ```
80
+ # redis configure
81
+ host: 127.0.0.1
82
+ port: 6379
83
+
84
+ ```
85
+
86
+
65
87
  ### input example
66
88
  {
67
89
  "HealthyHostCount": 6
@@ -78,7 +100,9 @@ Add the following into your fluentd config.
78
100
  },
79
101
  "receive_time_input": "1426189324",
80
102
  "application_name": "Form & Printing Services (FPS)",
81
- "intermediary_source": "cloudwatch",
103
+ "intermediary_source": "region1-AZ1",
104
+ "runbook": "http://runbook.wiki.com"
105
+ "event_type" : "alert.cloudwatch"
82
106
  "tag": "alert.cloudwatch.out"
83
107
  }
84
108
 
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = "fluent-plugin-cloudwatch-transform"
6
- gem.version = "0.0.4"
6
+ gem.version = "0.0.5"
7
7
  gem.date = '2015-03-26'
8
8
  gem.authors = ["Ling Zhang"]
9
9
  gem.email = ["zhangling.ice@gmail.com"]
@@ -22,4 +22,5 @@ Gem::Specification.new do |gem|
22
22
  gem.add_development_dependency 'bundler', '~> 1.3'
23
23
  gem.add_development_dependency 'rake', '~> 0.9', '>= 0.9.2'
24
24
  gem.add_development_dependency 'rspec', '~> 2.11', '>= 2.11.0'
25
+ gem.add_runtime_dependency "highwatermark", '~> 0.1'
25
26
  end
@@ -6,15 +6,24 @@ module Fluent
6
6
 
7
7
  #config_param :tag, :string, default:'alert.cloudwatch.out'
8
8
  config_param :tag, :string
9
+ config_param :state_type, :string, :default => nil
10
+ config_param :state_file, :string, :default => nil
9
11
 
10
12
  # This method is called before starting.
11
13
  def configure(conf)
12
14
  super
13
15
  end
14
16
 
17
+ def initialize
18
+ require 'highwatermark'
19
+ super
20
+ end # def initialize
21
+
15
22
  # This method is called when starting.
16
23
  def start
17
24
  super
25
+ @highwatermark = Highwatermark::HighWaterMark.new(@state_file, @state_type)
26
+
18
27
  end
19
28
 
20
29
  # This method is called when shutting down.
@@ -55,6 +64,15 @@ module Fluent
55
64
  newhash["runbook"] = runbook_url
56
65
  newhash["event_type"] = "alert.cloudwatch"
57
66
 
67
+ if @highwatermark.last_records(@tag)
68
+ last_hwm = @highwatermark.last_records(@tag)
69
+ $log.info "got hwm form state file: #{last_hwm.to_i}"
70
+ else
71
+ $log.info "no hwm yet"
72
+ end
73
+
74
+ @highwatermark.update_records(timestamp.to_s,@tag)
75
+
58
76
  #log the transformed message and emit it
59
77
  $log.info "Tranformed message #{newhash}"
60
78
  Fluent::Engine.emit @tag, time.to_i, newhash
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-cloudwatch-transform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ling Zhang
@@ -84,6 +84,20 @@ dependencies:
84
84
  - - '>='
85
85
  - !ruby/object:Gem::Version
86
86
  version: 2.11.0
87
+ - !ruby/object:Gem::Dependency
88
+ name: highwatermark
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '0.1'
94
+ type: :runtime
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ~>
99
+ - !ruby/object:Gem::Version
100
+ version: '0.1'
87
101
  description: FLuentd plugin for transform cloudwatch alerts
88
102
  email:
89
103
  - zhangling.ice@gmail.com