fluent-plugin-mysqlslowquery 0.0.1 → 0.0.2
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/Gemfile +3 -0
- data/README.md +6 -9
- data/fluent-plugin-mysqlslowquery.gemspec +3 -1
- data/lib/fluent/plugin/in_mysql_slow_query.rb +42 -25
- metadata +30 -6
data/Gemfile
ADDED
data/README.md
CHANGED
@@ -2,21 +2,18 @@
|
|
2
2
|
|
3
3
|
Fluent input plugin for MySQL slow query log file.
|
4
4
|
|
5
|
-
##
|
6
|
-
|
7
|
-
Puts in_mysql_slow_query.rb to plugin directory.
|
5
|
+
##Installation
|
8
6
|
|
9
7
|
```shell
|
10
|
-
%
|
8
|
+
% gem install fluent-plugin-mysqlslowquery
|
11
9
|
```
|
12
10
|
|
13
|
-
|
11
|
+
##How to use
|
14
12
|
|
15
|
-
|
16
|
-
% edit fluent.conf
|
17
|
-
```
|
13
|
+
Edit conf file.
|
18
14
|
|
19
|
-
```
|
15
|
+
```conf
|
16
|
+
#/etc/fluentd/fluent.conf
|
20
17
|
<source>
|
21
18
|
type mysql_slow_query
|
22
19
|
path /path/to/mysqld-slow.log
|
@@ -13,7 +13,9 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
14
|
gem.name = "fluent-plugin-mysqlslowquery"
|
15
15
|
gem.require_paths = ["lib"]
|
16
|
-
gem.version = "0.0.
|
16
|
+
gem.version = "0.0.2"
|
17
17
|
gem.add_development_dependency "fluentd"
|
18
|
+
gem.add_development_dependency "myslog"
|
18
19
|
gem.add_runtime_dependency "fluentd"
|
20
|
+
gem.add_runtime_dependency "myslog"
|
19
21
|
end
|
@@ -1,33 +1,50 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
#
|
2
|
+
# in_mysql_slow_query
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
require "myslog"
|
17
|
+
|
18
|
+
module Fluent
|
19
|
+
|
20
|
+
class MySQLSlowQueryInput < TailInput
|
21
|
+
Plugin.register_input('mysql_slow_query', self)
|
3
22
|
|
4
23
|
def configure_parser(conf)
|
5
|
-
@
|
6
|
-
@_record = {}
|
24
|
+
@parser = MySlog.new
|
7
25
|
end
|
8
26
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
@_record["rows_examined"] = sl[8].to_i
|
27
|
+
def receive_lines(lines)
|
28
|
+
es = MultiEventStream.new
|
29
|
+
@parser.divide(lines).each do |record|
|
30
|
+
begin
|
31
|
+
record = @parser.parse_record(record)
|
32
|
+
if time = record.delete(:date)
|
33
|
+
time = time.to_i
|
34
|
+
else
|
35
|
+
time = Time.now.to_i
|
36
|
+
end
|
37
|
+
es.add(time, record)
|
38
|
+
rescue
|
39
|
+
$log.warn record, :error=>$!.to_s
|
40
|
+
$log.debug_backtrace
|
24
41
|
end
|
25
|
-
elsif not line.upcase.start_with?('USE') and not line.upcase.start_with?('SET')
|
26
|
-
@_record["sql"] = line
|
27
|
-
n_record = @_record.clone
|
28
|
-
@_record = {}
|
29
|
-
return @_time, n_record
|
30
42
|
end
|
31
|
-
|
43
|
+
|
44
|
+
unless es.empty?
|
45
|
+
Engine.emit_stream(@tag, es)
|
46
|
+
end
|
32
47
|
end
|
33
48
|
end
|
49
|
+
|
50
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-mysqlslowquery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-07 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
16
|
-
requirement: &
|
16
|
+
requirement: &70358293308920 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,32 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70358293308920
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: myslog
|
27
|
+
requirement: &70358293308140 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70358293308140
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
37
|
name: fluentd
|
27
|
-
requirement: &
|
38
|
+
requirement: &70358293307240 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70358293307240
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: myslog
|
49
|
+
requirement: &70358293306100 !ruby/object:Gem::Requirement
|
28
50
|
none: false
|
29
51
|
requirements:
|
30
52
|
- - ! '>='
|
@@ -32,7 +54,7 @@ dependencies:
|
|
32
54
|
version: '0'
|
33
55
|
type: :runtime
|
34
56
|
prerelease: false
|
35
|
-
version_requirements: *
|
57
|
+
version_requirements: *70358293306100
|
36
58
|
description: Fluent input plugin for MySQL slow query log file.
|
37
59
|
email:
|
38
60
|
- taka84u9@gmail.com
|
@@ -41,6 +63,7 @@ extensions: []
|
|
41
63
|
extra_rdoc_files: []
|
42
64
|
files:
|
43
65
|
- .gitignore
|
66
|
+
- Gemfile
|
44
67
|
- README.md
|
45
68
|
- Rakefile
|
46
69
|
- fluent-plugin-mysqlslowquery.gemspec
|
@@ -70,3 +93,4 @@ signing_key:
|
|
70
93
|
specification_version: 3
|
71
94
|
summary: Fluent input plugin for MySQL slow query log file.
|
72
95
|
test_files: []
|
96
|
+
has_rdoc:
|