fluent-plugin-mongo-slow-query 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1aa827020993c3b9d101768f7cfd245287516ff1
4
- data.tar.gz: c0345c46f856136c08952af620bc1fad0fbddaf3
3
+ metadata.gz: b1d1c2fa9da92102d0517324f87482aa9f552d30
4
+ data.tar.gz: a6fbdb01ba0d0fa8f597f32fab8038e0d8388a2a
5
5
  SHA512:
6
- metadata.gz: 37f7f5c04f34e6e93ddfb287d2092a9c6cb9f63350583c60e7153cd9b569175239140534e076448531bd3ef0e7c763b7820b9595a6447746c092ee061ea52a73
7
- data.tar.gz: a7495ba4f6ce4a0a21672847164482b191360f0f97538962b68d2361220f2f221a4c0ea71a06ebfbbec404151a0aee182a765115a231e2bce599bfbf7ade2962
6
+ metadata.gz: 33359191371e974322482d504d22949834197b89ec128d0e60ba58b152a7210ea32db47d25c9eb6b35cc515b6eea2b3854d5847bd409f8cb1702843a17df9e05
7
+ data.tar.gz: be387dc660ed8b9241294df6474386ab1ffce4de81ca73ec0f12d409f5c4137736f5f58066944a222aff5c205879462546482542096f8a4f0a865856582272c2
@@ -3,7 +3,7 @@ require 'json'
3
3
  module Fluent
4
4
  class MongoDBSlowQueryInput < TailInput
5
5
  # First, register the plugin. NAME is the name of this plugin
6
- # # and identifies the plugin in the configuration file.
6
+ # and identifies the plugin in the configuration file.
7
7
  Plugin.register_input('mongo_slow_query', self)
8
8
 
9
9
  # This method is called before starting.
@@ -11,7 +11,8 @@ module Fluent
11
11
  # If the configuration is invalid, raise Fluent::ConfigError.
12
12
  def configure(conf)
13
13
  unless conf.has_key?("format")
14
- conf["format"] = '/(?<time>[^ ]+ [^ ]+ [^ ]+ [^ ]+) \[\w+\] (?<op>[^ ]+) (?<ns>[^ ]+) (query: (?<query>{.+}) update: (?<update>{.*}))|(query: (?<query>{.+})) .* (?<cost>\d+)ms/'
14
+ #conf["format"] = '/(?<time>[^ ]+ [^ ]+ [^ ]+ [^ ]+) \[\w+\] (?<op>[^ ]+) (?<ns>[^ ]+) ((query: (?<query>{.+}) update: (?<update>{.*}))|(query: (?<query>{.+}))) .* (?<ms>\d+)ms/'
15
+ conf["format"] = '/(?<time>[^ ]+ [^ ]+ [^ ]+ [^ ]+) \[\w+\] (?<op>[^ ]+) (?<ns>[^ ]+) ((query: (?<query>{.+}) update: {.*})|(query: (?<query>{.+}))) .* (?<ms>\d+)ms/'
15
16
  $log.warn "load default format: ", conf["format"]
16
17
  end
17
18
 
@@ -33,9 +34,9 @@ module Fluent
33
34
  if record.has_key?("query")
34
35
  record["query"] = get_query_prototype(record["query"])
35
36
  end
36
- if record.has_key?("update")
37
- record["update"] = get_query_prototype(record["update"])
38
- end
37
+ #if record.has_key?("update")
38
+ # record["update"] = get_query_prototype(record["update"])
39
+ #end
39
40
  es.add(time, record)
40
41
  end
41
42
  rescue
@@ -53,7 +54,7 @@ module Fluent
53
54
  end
54
55
  end
55
56
 
56
- # exrtact query prototype recursively
57
+ # extract query prototype recursively
57
58
  def extract_query_prototype(query_json_obj, parent='')
58
59
  ns_array = []
59
60
  query_json_obj.each do |key, val|
@@ -69,8 +70,13 @@ module Fluent
69
70
 
70
71
  # get query prototype
71
72
  def get_query_prototype(query)
72
- prototype = extract_query_prototype(JSON.parse(eval(query).to_json))
73
- return '{ ' + prototype.join(', ') + ' }'
73
+ begin
74
+ prototype = extract_query_prototype(JSON.parse(eval(query).to_json))
75
+ return '{ ' + prototype.join(', ') + ' }'
76
+ rescue
77
+ $log.error $!.to_s
78
+ return query
79
+ end
74
80
  end
75
81
  end
76
82
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-mongo-slow-query
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - caosiyang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-26 00:00:00.000000000 Z
11
+ date: 2014-07-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: fluent plugin for mongo slow query
14
14
  email: csy3228@gmail.com