fluent-plugin-rds-log 0.1.3 → 0.1.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.
- data/README.md +14 -8
- data/fluent-plugin-rds-log.gemspec +1 -1
- data/fluent.conf.sample +16 -0
- data/lib/fluent/plugin/in_rds_log.rb +28 -14
- metadata +18 -9
- checksums.yaml +0 -7
data/README.md
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
# Amazon RDS (for MySQL) input plugin
|
|
1
|
+
# Amazon RDS (for MySQL) input plugin for [Fluentd](http://fluentd.org)
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
|
-
|
|
4
|
+
- Amazon Web Services RDS(MySQL) general_log and slow_log input plugin.
|
|
5
5
|
|
|
6
6
|
##Installation
|
|
7
7
|
|
|
8
8
|
$ fluent-gem install fluent-plugin-rds-log
|
|
9
|
+
*Maybe, you also need the following packages*
|
|
10
|
+
- MySQL-shared
|
|
11
|
+
- MySQL-shared-compat
|
|
12
|
+
- MySQL-devel
|
|
9
13
|
|
|
10
14
|
## RDS Setting
|
|
11
15
|
|
|
@@ -23,12 +27,13 @@
|
|
|
23
27
|
<source>
|
|
24
28
|
type rds_log
|
|
25
29
|
log_type <slow_log | general_log>
|
|
26
|
-
host
|
|
27
|
-
username
|
|
28
|
-
password
|
|
29
|
-
refresh_interval
|
|
30
|
-
auto_reconnect
|
|
31
|
-
tag
|
|
30
|
+
host <RDS Hostname1>,<RDS Hostname2>,<RDS Hostname3>.. # multiple database servers(comma separated)
|
|
31
|
+
username <RDS Username>
|
|
32
|
+
password <RDS Password>
|
|
33
|
+
refresh_interval <number>
|
|
34
|
+
auto_reconnect <true|false>
|
|
35
|
+
tag <tag-name>
|
|
36
|
+
add_host false # add database hostname in record
|
|
32
37
|
</source>
|
|
33
38
|
```
|
|
34
39
|
|
|
@@ -44,6 +49,7 @@
|
|
|
44
49
|
refresh_interval 30
|
|
45
50
|
auto_reconnect true
|
|
46
51
|
tag rds-general-log
|
|
52
|
+
add_host false # add database hostname in record
|
|
47
53
|
</source>
|
|
48
54
|
|
|
49
55
|
<match rds-general-log>
|
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |gem|
|
|
6
6
|
gem.name = "fluent-plugin-rds-log"
|
|
7
|
-
gem.version = "0.1.
|
|
7
|
+
gem.version = "0.1.4"
|
|
8
8
|
gem.authors = ["shinsaka"]
|
|
9
9
|
gem.email = ["shinx1265@gmail.com"]
|
|
10
10
|
gem.description = "Amazon RDS slow_log and general_log input plugin for Fluent event collector"
|
data/fluent.conf.sample
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<source>
|
|
2
|
+
type rds_log
|
|
3
|
+
log_type general_log
|
|
4
|
+
host endpoint.abcdefghijkl.ap-northeast-1.rds.amazonaws.com
|
|
5
|
+
username testuser
|
|
6
|
+
password testuser
|
|
7
|
+
refresh_interval 30
|
|
8
|
+
auto_reconnect true
|
|
9
|
+
tag rds-general-log
|
|
10
|
+
add_host true
|
|
11
|
+
</source>
|
|
12
|
+
|
|
13
|
+
<match rds-general-log>
|
|
14
|
+
type file
|
|
15
|
+
path /tmp/rds-general-log
|
|
16
|
+
</match>
|
|
@@ -9,6 +9,7 @@ class Fluent::Rds_LogInput < Fluent::Input
|
|
|
9
9
|
config_param :log_type, :string, :default => nil
|
|
10
10
|
config_param :refresh_interval, :integer, :default => 30
|
|
11
11
|
config_param :auto_reconnect, :bool, :default => true
|
|
12
|
+
config_param :add_host, :bool, :default => false
|
|
12
13
|
|
|
13
14
|
def initialize
|
|
14
15
|
super
|
|
@@ -34,43 +35,56 @@ class Fluent::Rds_LogInput < Fluent::Input
|
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
private
|
|
37
|
-
def
|
|
38
|
+
def connect_all
|
|
39
|
+
@clients = {}
|
|
40
|
+
@host.split(',').each do |host|
|
|
41
|
+
@clients[host] = connect(host)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def connect(host)
|
|
38
46
|
begin
|
|
39
|
-
$log.info "fluent-plugin-rds-log: connecting RDS"
|
|
40
|
-
|
|
41
|
-
:host =>
|
|
47
|
+
$log.info "fluent-plugin-rds-log: connecting RDS [#{host}]"
|
|
48
|
+
client = Mysql2::Client.new({
|
|
49
|
+
:host => host,
|
|
42
50
|
:port => @port,
|
|
43
51
|
:username => @username,
|
|
44
52
|
:password => @password,
|
|
45
53
|
:reconnect => @auto_reconnect,
|
|
46
54
|
:database => 'mysql'
|
|
47
55
|
})
|
|
48
|
-
$log.info "fluent-plugin-rds-log: connected RDS"
|
|
56
|
+
$log.info "fluent-plugin-rds-log: connected RDS [#{host}]"
|
|
57
|
+
return client
|
|
49
58
|
rescue
|
|
50
|
-
$log.error "fluent-plugin-rds-log: cannot connect RDS"
|
|
59
|
+
$log.error "fluent-plugin-rds-log: cannot connect RDS [#{host}]"
|
|
51
60
|
end
|
|
52
61
|
end
|
|
62
|
+
|
|
53
63
|
def watch
|
|
54
|
-
|
|
64
|
+
connect_all
|
|
55
65
|
while true
|
|
56
66
|
sleep @refresh_interval
|
|
57
|
-
|
|
67
|
+
@host.split(',').each do |host|
|
|
68
|
+
output(host)
|
|
69
|
+
end
|
|
58
70
|
end
|
|
59
71
|
end
|
|
60
72
|
|
|
61
|
-
def output
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
def output(host)
|
|
74
|
+
client = @clients[host]
|
|
75
|
+
if client.nil?
|
|
76
|
+
client = connect(host)
|
|
77
|
+
if client.nil?
|
|
65
78
|
return
|
|
66
79
|
end
|
|
67
80
|
end
|
|
68
81
|
|
|
69
|
-
|
|
82
|
+
client.query("CALL mysql.rds_rotate_#{@log_type}")
|
|
70
83
|
|
|
71
|
-
output_log_data =
|
|
84
|
+
output_log_data = client.query("SELECT * FROM mysql.#{@log_type}_backup", :cast => false)
|
|
72
85
|
output_log_data.each do |row|
|
|
73
86
|
row.delete_if{|key,value| value == ''}
|
|
87
|
+
row['host'] = host if @add_host
|
|
74
88
|
Fluent::Engine.emit(tag, Fluent::Engine.now, row)
|
|
75
89
|
end
|
|
76
90
|
end
|
metadata
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-plugin-rds-log
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
|
+
prerelease:
|
|
5
6
|
platform: ruby
|
|
6
7
|
authors:
|
|
7
8
|
- shinsaka
|
|
8
9
|
autorequire:
|
|
9
10
|
bindir: bin
|
|
10
11
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
+
date: 2015-05-11 00:00:00.000000000 Z
|
|
12
13
|
dependencies:
|
|
13
14
|
- !ruby/object:Gem::Dependency
|
|
14
15
|
name: fluentd
|
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
16
18
|
requirements:
|
|
17
19
|
- - ~>
|
|
18
20
|
- !ruby/object:Gem::Version
|
|
@@ -20,6 +22,7 @@ dependencies:
|
|
|
20
22
|
type: :runtime
|
|
21
23
|
prerelease: false
|
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
23
26
|
requirements:
|
|
24
27
|
- - ~>
|
|
25
28
|
- !ruby/object:Gem::Version
|
|
@@ -27,6 +30,7 @@ dependencies:
|
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
|
28
31
|
name: mysql2
|
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
30
34
|
requirements:
|
|
31
35
|
- - ~>
|
|
32
36
|
- !ruby/object:Gem::Version
|
|
@@ -34,6 +38,7 @@ dependencies:
|
|
|
34
38
|
type: :runtime
|
|
35
39
|
prerelease: false
|
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
37
42
|
requirements:
|
|
38
43
|
- - ~>
|
|
39
44
|
- !ruby/object:Gem::Version
|
|
@@ -41,15 +46,17 @@ dependencies:
|
|
|
41
46
|
- !ruby/object:Gem::Dependency
|
|
42
47
|
name: rake
|
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
none: false
|
|
44
50
|
requirements:
|
|
45
|
-
- - '>='
|
|
51
|
+
- - ! '>='
|
|
46
52
|
- !ruby/object:Gem::Version
|
|
47
53
|
version: 10.0.4
|
|
48
54
|
type: :development
|
|
49
55
|
prerelease: false
|
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
none: false
|
|
51
58
|
requirements:
|
|
52
|
-
- - '>='
|
|
59
|
+
- - ! '>='
|
|
53
60
|
- !ruby/object:Gem::Version
|
|
54
61
|
version: 10.0.4
|
|
55
62
|
description: Amazon RDS slow_log and general_log input plugin for Fluent event collector
|
|
@@ -67,31 +74,33 @@ files:
|
|
|
67
74
|
- README.md
|
|
68
75
|
- Rakefile
|
|
69
76
|
- fluent-plugin-rds-log.gemspec
|
|
77
|
+
- fluent.conf.sample
|
|
70
78
|
- lib/fluent/plugin/in_rds_log.rb
|
|
71
79
|
- test/helper.rb
|
|
72
80
|
- test/plugin/test_in_rds_slowlog.rb
|
|
73
81
|
homepage: https://github.com/shinsaka/fluent-plugin-rds-log
|
|
74
82
|
licenses: []
|
|
75
|
-
metadata: {}
|
|
76
83
|
post_install_message:
|
|
77
84
|
rdoc_options: []
|
|
78
85
|
require_paths:
|
|
79
86
|
- lib
|
|
80
87
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
|
+
none: false
|
|
81
89
|
requirements:
|
|
82
|
-
- - '>='
|
|
90
|
+
- - ! '>='
|
|
83
91
|
- !ruby/object:Gem::Version
|
|
84
92
|
version: '0'
|
|
85
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
|
+
none: false
|
|
86
95
|
requirements:
|
|
87
|
-
- - '>='
|
|
96
|
+
- - ! '>='
|
|
88
97
|
- !ruby/object:Gem::Version
|
|
89
98
|
version: '0'
|
|
90
99
|
requirements: []
|
|
91
100
|
rubyforge_project:
|
|
92
|
-
rubygems_version:
|
|
101
|
+
rubygems_version: 1.8.23
|
|
93
102
|
signing_key:
|
|
94
|
-
specification_version:
|
|
103
|
+
specification_version: 3
|
|
95
104
|
summary: Amazon RDS slow_log and general_log input plugin for Fluent event collector
|
|
96
105
|
test_files:
|
|
97
106
|
- test/helper.rb
|
checksums.yaml
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
SHA1:
|
|
3
|
-
metadata.gz: e09e5f921b755de90de08e2ec681fa267890c87d
|
|
4
|
-
data.tar.gz: 7092cd06d100b40f961a7df30f28dae565658a7c
|
|
5
|
-
SHA512:
|
|
6
|
-
metadata.gz: bcc594b7aa25171c88e3eb99d3cd52b4a57ee2bad1bb8c71ca23bec3ad560ca98af35d035d200895743d195c3d0deae1804885fbdfadb2c346e7cb35c8fcab90
|
|
7
|
-
data.tar.gz: e1df1249f8398e9585e5e895fd7ef20f4b1dfb70fca9caab9757c676030629b9e52f19df6b0a223e031d33cf994a40a66f787f6c698d37effcfef2abec07f518
|