fluent-plugin-mysqlslowquerylog-ippen-digital 0.0.3 → 0.0.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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "fluent-plugin-mysqlslowquerylog-ippen-digital"
5
- gem.version = "0.0.3"
5
+ gem.version = "0.0.4"
6
6
  gem.authors = ["Satoshi SUZUKI", "Gerhard Strauss"]
7
7
  gem.email = ["studio3104.com@gmail.com", "gerhard.strauss@ippen-digital.de"]
8
8
  gem.description = %q{Fluentd plugin to concat MySQL slowquerylog.}
@@ -41,6 +41,8 @@ class Fluent::MySQLSlowQueryLogOutput < Fluent::Output
41
41
 
42
42
  REGEX1 = /^#? User\@Host:\s+(\S+)\s+\@\s+(\S+).*/
43
43
  REGEX2 = /^# Query_time: ([0-9.]+)\s+Lock_time: ([0-9.]+)\s+Rows_sent: ([0-9.]+)\s+Rows_examined: ([0-9.]+).*/
44
+ REGEX3 = /^use\s+(\S+);/
45
+ REGEX4 = /^SET\s+timestamp=(\d+);/
44
46
  def parse_message(tag, time)
45
47
  record = {}
46
48
  date = nil
@@ -66,6 +68,20 @@ class Fluent::MySQLSlowQueryLogOutput < Fluent::Output
66
68
  record['lock_time'] = $2.to_f
67
69
  record['rows_sent'] = $3.to_i
68
70
  record['rows_examined'] = $4.to_i
71
+ message = @slowlogs[:"#{tag}"].shift
72
+
73
+ if message.start_with?('use ')
74
+ message =~ REGEX3
75
+ record['database'] = $1
76
+ message = @slowlogs[:"#{tag}"].shift
77
+ else
78
+ record['database'] = 'no_database_logged'
79
+ end
80
+
81
+ if message.start_with?('SET timestamp=')
82
+ message =~ REGEX4
83
+ record['set_timestamp'] = $1
84
+ end
69
85
 
70
86
  record['sql'] = @slowlogs[:"#{tag}"].map {|m| m.strip}.join(' ')
71
87
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-mysqlslowquerylog-ippen-digital
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-01-16 00:00:00.000000000 Z
13
+ date: 2018-01-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fluentd