fluent-plugin-mongo-slow-query 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fluent/plugin/in_mongo_slow_query.rb +14 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1d1c2fa9da92102d0517324f87482aa9f552d30
|
4
|
+
data.tar.gz: a6fbdb01ba0d0fa8f597f32fab8038e0d8388a2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
#
|
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>{.+})) .* (?<
|
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
|
-
|
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
|
-
#
|
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
|
-
|
73
|
-
|
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.
|
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-
|
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
|