fluent-plugin-mysql-query 0.1.1 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -22,18 +22,21 @@ gem install fluent-plugin-mysql-query
22
22
  `````
23
23
  <source>
24
24
  type mysql_query
25
- server localhost # Optional (default: localhost)
25
+ host localhost # Optional (default: localhost)
26
26
  port 3306 # Optional (default: 3306)
27
27
  username nagios # Optional (default: root)
28
28
  password passw0rd # Optional (default nopassword)
29
29
  interval 30s # Optional (default: 1m)
30
30
  tag input.mysql # Required
31
31
  query SHOW VARIABLES LIKE 'Thread_%' # Required
32
- # inserting hostname into record.
33
- record_hostname yes # Optional (yes/no)
34
- # multi row results to be nested or separated record.
35
- nest_result no # Optional (yes/no)
36
- nest_keyname data # Optional (default: result)
32
+ # record hostname into message.
33
+ record_hostname yes # Optional (default: no)
34
+ # multi row results into nested record or separated message.
35
+ nest_result yes # Optional (default: no)
36
+ nest_key data # Optional (default: result)
37
+ # record the number of lines of a query result
38
+ row_count yes # Optional (default: no)
39
+ row_count_key row_count # Optional (default: row_count)
37
40
  </source>
38
41
 
39
42
  <match input.mysql>
@@ -47,16 +50,22 @@ record_hostname: yes, nest_result: no
47
50
  input.mysql: {"hostname":"myhost.example.com","Variable_name":"thread_cache_size","Value":"16"}
48
51
  input.mysql: {"hostname":"myhost.example.com","Variable_name":"thread_stack","Value":"262144"}
49
52
  `````
50
- record_hostname: yes, nest_result: yes, nest_keyname: data
53
+ record_hostname: yes, nest_result: yes, nest_key: data
51
54
  `````
52
55
  input.mysql: {"hostname":"myhost.example.com","data":[{"Variable_name":"thread_cache_size","Value":"16"},{"Variable_name":"thread_stack","Value":"262144"}]}
53
56
  `````
57
+ record_hostname: yes, nest_result: yes, nest_key: data, row_count: yes, row_count_key: row_count
58
+ `````
59
+ input.mysql: {"hostname":"myhost.example.com","row_count":2,"data":[{"Variable_name":"thread_cache_size","Value":"16"},{"Variable_name":"thread_stack","Value":"262144"}]}
60
+ `````
54
61
 
55
62
  ### Example Query
56
63
  * SHOW VARIABLES LIKE 'Thread_%';
57
64
  * SELECT MAX(id) AS max_foo_id FROM foo_table;
58
65
  * SHOW FULL PROCESSLIST;
59
66
  * INSERT INTO log (data, created_at) VALUES((SELECT MAX(id) FROM foo_table), NOW());
67
+ * SHOW SLAVE STATUS;
68
+ * SHOW INNODB STATUS;
60
69
 
61
70
  ## TODO
62
71
  patches welcome!
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "fluent-plugin-mysql-query"
6
- s.version = "0.1.1"
6
+ s.version = "0.2.1"
7
7
  s.authors = ["Kentaro Yoshida"]
8
8
  s.email = ["y.ken.studio@gmail.com"]
9
9
  s.homepage = "https://github.com/y-ken/fluent-plugin-mysql-query"
@@ -18,6 +18,8 @@ module Fluent
18
18
  config_param :query, :string
19
19
  config_param :nest_result, :string, :default => nil
20
20
  config_param :nest_key, :string, :default => 'result'
21
+ config_param :row_count, :string, :default => nil
22
+ config_param :row_count_key, :string, :default => 'row_count'
21
23
  config_param :record_hostname, :string, :default => nil
22
24
 
23
25
  def configure(conf)
@@ -25,6 +27,7 @@ module Fluent
25
27
  @hostname = get_mysql_hostname
26
28
  @interval = Config.time_value(@interval)
27
29
  @nest_result = Config.bool_value(@nest_result) || false
30
+ @row_count = Config.bool_value(@row_count) || false
28
31
  @record_hostname = Config.bool_value(@record_hostname) || false
29
32
  $log.info "adding mysql_query job: [#{@query}] interval: #{@interval}sec"
30
33
  end
@@ -43,6 +46,7 @@ module Fluent
43
46
  record = Hash.new
44
47
  record.store('hostname', @hostname) if @record_hostname
45
48
  result = get_exec_result
49
+ record.store(@row_count_key, result.size) if @row_count
46
50
  if (@nest_result)
47
51
  record.store(@nest_key, result)
48
52
  Engine.emit(tag, Engine.now, record)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-mysql-query
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
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-10-13 00:00:00.000000000 Z
12
+ date: 2012-10-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
16
- requirement: &11556900 !ruby/object:Gem::Requirement
16
+ requirement: &10854720 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *11556900
24
+ version_requirements: *10854720
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: fluentd
27
- requirement: &11555420 !ruby/object:Gem::Requirement
27
+ requirement: &10846780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *11555420
35
+ version_requirements: *10846780
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: mysql2
38
- requirement: &11554560 !ruby/object:Gem::Requirement
38
+ requirement: &10846340 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *11554560
46
+ version_requirements: *10846340
47
47
  description:
48
48
  email:
49
49
  - y.ken.studio@gmail.com