fluent-plugin-esslowquery 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9eddfff2ba328373e82890f795079dd0bdb1e153
4
- data.tar.gz: e932413c6b989d99ba0c4a572b5ab59809968831
3
+ metadata.gz: c95c49ad0eda635329ee955882bf5a61d0d78616
4
+ data.tar.gz: e4ecd7cc218367315341925e41e25d12d37121e0
5
5
  SHA512:
6
- metadata.gz: caef9092c3f652a94ecb6745270af1166c69aaae9e6f8cf9ef611783e08db6bd7d91191fcad5c12638ab2c12f2f5f29d80720547c71fda4b8d48319095ae00d8
7
- data.tar.gz: 197cd681f216fb607aff63a32cda452874165850615c896f5b1aa947f03c059615cd12875e195ae763a621d29dc0017b428956c2fe70c7563e4b0f1d0cdfc3a9
6
+ metadata.gz: 26608ff0fef20868f43d039020df3d4101209832b0a5b9b7efa2b6e2d460458388c6d2bdc364e190e32ff7808bc668c772400dc4238c02c9d13a91ee1795c935
7
+ data.tar.gz: 9d922d61f8a44896debd55050b4d77f5541e81bfc8e5bde146300b626beca6d306899d1513f3fd9c09a4f5b0610d00c5b2612e7737ae9eb2860af47eab3483dc
data/AUTHORS ADDED
@@ -0,0 +1,6 @@
1
+ # This file lists all individuals having contributed content to the repository.
2
+ # For how it is generated, see `script/generate-authors.sh`.
3
+
4
+ iaintshine <bodziomista@gmail.com>
5
+ Joe Doss <jdoss@kennasecurity.com>
6
+ Mirosław Nagaś <mgolden@smoczus.pl>
@@ -0,0 +1,7 @@
1
+ ## CHANGELOG
2
+
3
+ ### V1.1.0 (2016-02-16)
4
+
5
+ **Features and Improvements**
6
+
7
+ * Slow indexing parser [#2](https://github.com/iaintshine/fluent-plugin-esslowquery/pull/2)
data/README.md CHANGED
@@ -26,12 +26,13 @@ Edit `/etc/td-agent/td-agent.conf` file.
26
26
  path /var/log/elasticsearch/elasticsearch-{cluster-name}_index_indexing_slowlog.log
27
27
  tag elasticsearch.{cluster-name}.indexing_slowlog_query
28
28
  pos_file /var/run/td-agent/elasticsearch-indexing-slow.pos
29
- format es_slow_query
29
+ format es_slow_indexing
30
30
  </source>
31
31
  ```
32
32
 
33
33
  ##Expected record format
34
34
 
35
+ ### Slow Query
35
36
  ```json
36
37
  {
37
38
  "extra_source": "{\"from\":0,\"size\":0}",
@@ -49,3 +50,20 @@ Edit `/etc/td-agent/td-agent.conf` file.
49
50
  "types": "document"
50
51
  }
51
52
  ```
53
+ ### Slow Indexing
54
+
55
+ ```json
56
+ {
57
+ "severity": "INFO ",
58
+ "source": "index.indexing.slowlog.index",
59
+ "node": "{cluster-name}-{node-id}",
60
+ "index": "comments",
61
+ "shard": 4,
62
+ "took": "891.4ms",
63
+ "took_millis": 891,
64
+ "type": "document",
65
+ "indexing_id": 120543866,
66
+ "routing": 2012927,
67
+ "source_body": "{}"
68
+ }
69
+ ```
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.authors = ["Boguslaw Mista"]
3
3
  gem.email = ["bodziomista@gmail.com"]
4
- gem.description = "Fluent parser plugin for Elasticsearch slow query log file."
5
- gem.summary = "Fluent parser plugin for Elasticsearch slow query log file."
4
+ gem.description = "Fluent parser plugin for Elasticsearch slow query and slow indexing log files."
5
+ gem.summary = "Fluent parser plugin for Elasticsearch slow query and slow indexing log files."
6
6
  gem.homepage = "https://github.com/iaintshine/fluent-plugin-esslowquery"
7
7
  gem.license = "MIT"
8
8
 
@@ -11,6 +11,6 @@ Gem::Specification.new do |gem|
11
11
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
12
12
  gem.name = "fluent-plugin-esslowquery"
13
13
  gem.require_paths = ["lib"]
14
- gem.version = "1.0.2"
14
+ gem.version = "1.1.0"
15
15
  gem.add_dependency "fluentd", [">= 0.12.0", "< 2"]
16
16
  end
@@ -0,0 +1,61 @@
1
+ module Fluent
2
+ class TextParser
3
+ class ElasticsearchSlowIndexingLogParser < Parser
4
+ REGEXP = /^\[(?<time>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3})\]\[(?<severity>[a-zA-Z]+\s*)\]\[(?<source>\S+)\] \[(?<node>\S+)\] \[(?<index>\w+)\]\[(?<shard>\d+)\] took\[(?<took>.+)\], took_millis\[(?<took_millis>\d+)\], type\[(?<type>.+)\], id\[(?<indexing_id>.*)\], routing\[(?<routing>.*)\], source\[(?<source_body>.*)\]/
5
+ TIME_FORMAT = "%Y-%m-%d %H:%M:%S,%N"
6
+
7
+ Plugin.register_parser("es_slow_indexing", self)
8
+
9
+ def initialize
10
+ super
11
+ @time_parser = TextParser::TimeParser.new(TIME_FORMAT)
12
+ @mutex = Mutex.new
13
+ end
14
+
15
+ def patterns
16
+ {'format' => REGEXP, 'time_format' => TIME_FORMAT}
17
+ end
18
+
19
+ def parse(text)
20
+ m = REGEXP.match(text)
21
+ unless m
22
+ if block_given?
23
+ yield nil, nil
24
+ return
25
+ else
26
+ return nil, nil
27
+ end
28
+ end
29
+
30
+ shard = m['shard'].to_i
31
+ took_millis = m['took_millis'].to_i
32
+ indexing_id= m['indexing_id'].to_i
33
+ routing = m['routing'].to_i
34
+
35
+ time = m['time']
36
+ time = @mutex.synchronize { @time_parser.parse(time) }
37
+
38
+ record = {
39
+ 'severity' => m['severity'],
40
+ 'source' => m['source'],
41
+ 'node' => m['node'],
42
+ 'index' => m['index'],
43
+ 'shard' => shard,
44
+ 'took' => m['took'],
45
+ 'took_millis' => took_millis,
46
+ 'type' => m['type'],
47
+ 'indexing_id' => indexing_id,
48
+ 'routing' => routing,
49
+ 'source_body' => m['source_body']
50
+ }
51
+ record["time"] = m['time'] if @keep_time_key
52
+
53
+ if block_given?
54
+ yield time, record
55
+ else
56
+ return time, record
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -1,5 +1,5 @@
1
1
  module Fluent
2
- class ElasticsearchSlowLogParser < Parser
2
+ class ElasticsearchSlowQueryLogParser < Parser
3
3
  REGEXP = /^\[(?<time>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3})\]\[(?<severity>[a-zA-Z]+\s*)\]\[(?<source>\S+)\] \[(?<node>\S+)\] \[(?<index>\w+)\]\[(?<shard>\d+)\] took\[(?<took>.+)\], took_millis\[(?<took_millis>\d+)\], types\[(?<types>.*)\], stats\[(?<stats>.*)\], search_type\[(?<search_type>.*)\], total_shards\[(?<total_shards>\d+)\], source\[(?<source_body>.*)\], extra_source\[(?<extra_source>.*)\]/
4
4
  TIME_FORMAT = "%Y-%m-%d %H:%M:%S,%N"
5
5
 
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ {
5
+ cat <<-'EOH'
6
+ # This file lists all individuals having contributed content to the repository.
7
+ # For how it is generated, see `script/generate-authors.sh`.
8
+ EOH
9
+ echo
10
+ git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf
11
+ } > AUTHORS
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-esslowquery
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boguslaw Mista
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-10 00:00:00.000000000 Z
11
+ date: 2016-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -30,7 +30,8 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '2'
33
- description: Fluent parser plugin for Elasticsearch slow query log file.
33
+ description: Fluent parser plugin for Elasticsearch slow query and slow indexing log
34
+ files.
34
35
  email:
35
36
  - bodziomista@gmail.com
36
37
  executables: []
@@ -38,11 +39,15 @@ extensions: []
38
39
  extra_rdoc_files: []
39
40
  files:
40
41
  - ".gitignore"
42
+ - AUTHORS
43
+ - CHANGELOG.md
41
44
  - Gemfile
42
45
  - README.md
43
46
  - Rakefile
44
47
  - fluent-plugin-esslowquery.gemspec
48
+ - lib/fluent/plugin/parser_es_slow_indexing.rb
45
49
  - lib/fluent/plugin/parser_es_slow_query.rb
50
+ - scripts/generate-authors.sh
46
51
  homepage: https://github.com/iaintshine/fluent-plugin-esslowquery
47
52
  licenses:
48
53
  - MIT
@@ -66,5 +71,5 @@ rubyforge_project:
66
71
  rubygems_version: 2.2.2
67
72
  signing_key:
68
73
  specification_version: 4
69
- summary: Fluent parser plugin for Elasticsearch slow query log file.
74
+ summary: Fluent parser plugin for Elasticsearch slow query and slow indexing log files.
70
75
  test_files: []