fluent-plugin-cloudwatch-transform 0.0.6 → 0.0.7
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d617c260e7c26f81912db6b173ce73bffb4fbc29
|
4
|
+
data.tar.gz: b5b9d11c388678d5ba3bbabaf426810622913edf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76088e67c7ac772999a7b07d653295f5ded2cc1544b8da1a073da10d1d4c614fefac3a8676d0f7fc4ffdfb8e63a60805f2a0ea6d79191781c533bfeac0283498
|
7
|
+
data.tar.gz: 8dff90e28003fdaba5c0d65e0a79583af6c176e799b6f8812909acdaa2442a693e28a186868c1d24068ef1d3a1f159cdddd2bf4d9333c922b7fd3efe0a1e88f0
|
@@ -3,8 +3,8 @@ $:.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.
|
7
|
-
gem.date = '2015-04-
|
6
|
+
gem.version = "0.0.7"
|
7
|
+
gem.date = '2015-04-23'
|
8
8
|
gem.authors = ["Ling Zhang"]
|
9
9
|
gem.email = ["zhangling.ice@gmail.com"]
|
10
10
|
gem.summary = %q{Fluentd output plugin for transform cloudwatch alerts }
|
@@ -8,10 +8,23 @@ module Fluent
|
|
8
8
|
config_param :state_type, :string, :default => nil
|
9
9
|
config_param :state_file, :string, :default => nil
|
10
10
|
config_param :state_tag, :string, :default => nil
|
11
|
+
config_param :name_for_origin_key, :string, :default => nil
|
12
|
+
config_param :name_for_origin_value, :string, :default => nil
|
13
|
+
|
14
|
+
#also need add config for info_name and postion_in_tag (start from 0) within <tag_infos> </tag_infos> block
|
11
15
|
|
12
16
|
# This method is called before starting.
|
13
17
|
def configure(conf)
|
14
18
|
super
|
19
|
+
# Read configuration for tag_infos and create a hash
|
20
|
+
@tag_infos = Hash.new
|
21
|
+
conf.elements.select { |element| element.name == 'tag_infos' }.each { |element|
|
22
|
+
element.each_pair { |info_name, position_in_tag|
|
23
|
+
@tag_infos[info_name] = position_in_tag.to_i
|
24
|
+
$log.info "Added tag_infos: #{info_name}=>#{@tag_infos[info_name]}"
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
15
28
|
end
|
16
29
|
|
17
30
|
def initialize
|
@@ -39,30 +52,31 @@ module Fluent
|
|
39
52
|
#
|
40
53
|
# NOTE! This method is called by Fluentd's main thread so you should not write slow routine here. It causes Fluentd's performance degression.
|
41
54
|
def emit(tag, es, chain)
|
42
|
-
#tag_parts = tag.split('.')
|
43
55
|
tag_parts = tag.scan( /([^".]+)|"([^"]+)"/ ).flatten.compact
|
44
|
-
# the
|
45
|
-
#
|
46
|
-
|
47
|
-
application_name = tag_parts[4]
|
48
|
-
runbook_url = tag_parts[5]
|
56
|
+
# split the tags with .
|
57
|
+
# ingnore the . within ""
|
58
|
+
|
49
59
|
chain.next
|
50
60
|
es.each {|time,record|
|
51
61
|
|
52
62
|
newhash = Hash.new
|
53
63
|
# though there is just one key-value pair in cloudwatch alert record, we use a loop to add context for it.
|
54
64
|
record.each_pair do |singlekey, singlevalue|
|
55
|
-
newhash[
|
56
|
-
newhash[
|
65
|
+
newhash[@name_for_origin_key] = singlekey
|
66
|
+
newhash[@name_for_origin_value] = singlevalue.to_s
|
57
67
|
newhash["raw"] ={singlekey => singlevalue}
|
58
68
|
end
|
59
69
|
# add more information for the cloudwatch alert
|
70
|
+
# fixed info
|
60
71
|
timestamp = Engine.now # Should be receive_time_input
|
61
72
|
newhash["receive_time_input"]=timestamp.to_s
|
62
|
-
newhash["
|
63
|
-
|
64
|
-
|
65
|
-
|
73
|
+
newhash["event_type"] = @out_tag
|
74
|
+
|
75
|
+
@tag_infos.each do |info_name, position_in_tag|
|
76
|
+
newhash[info_name] = tag_parts[position_in_tag]
|
77
|
+
end
|
78
|
+
|
79
|
+
|
66
80
|
|
67
81
|
if @highwatermark.last_records(@state_tag)
|
68
82
|
last_hwm = @highwatermark.last_records(@state_tag)
|
@@ -1,12 +1,23 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class CloudWatchTransOutputTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
5
|
Fluent::Test.setup
|
6
6
|
end
|
7
7
|
|
8
8
|
CONFIG = %[
|
9
|
-
tag alert.cloudwatch.raw.FPS
|
9
|
+
tag alert.cloudwatch.raw.region1-AZ1.Form & Printing Services (FPS)."http://testurl.com"
|
10
|
+
out_tag alert.processed.cloudwatch
|
11
|
+
state_type file
|
12
|
+
state_file cloudwatch.yaml
|
13
|
+
state_tag cloudwatch
|
14
|
+
name_for_origin_key event_name
|
15
|
+
name_for_origin_value value
|
16
|
+
<tag_infos>
|
17
|
+
region_and_AZ 3
|
18
|
+
application_name 4
|
19
|
+
runbook_url 5
|
20
|
+
</tag_infos>
|
10
21
|
]
|
11
22
|
|
12
23
|
def create_driver(conf=CONFIG)
|
@@ -15,6 +26,6 @@ class SnmpTrapInputTest < Test::Unit::TestCase
|
|
15
26
|
|
16
27
|
def test_configure
|
17
28
|
d = create_driver
|
18
|
-
assert_equal 'alert.cloudwatch
|
29
|
+
assert_equal 'alert.processed.cloudwatch', d.instance.out_tag
|
19
30
|
end
|
20
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ling Zhang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|