logstash-filter-elasticsearchslowlog 0.3.0 → 0.4.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
  SHA256:
3
- metadata.gz: 1a75bee6585b872194e44d0f2b4984bed09bea36f05ce3851f582ad52489ebc0
4
- data.tar.gz: 07b275d4633390e364d8951a6fcc32f8280606ab000a421579d032d572be4bf4
3
+ metadata.gz: acabadb6181cf54d1a56ff1b889849eafd4e65d997eeff07e816b500e8933d6f
4
+ data.tar.gz: d88ad920cc826e1ef019827f65ec0b98885f321a30193b5b9265b5a2a7500d26
5
5
  SHA512:
6
- metadata.gz: b2455527cd1ee323c524e92d20aca6c8ec0e1d36919dabfbf9831a62803b2221c1c9ba58742f8411b35356625acc11ec0dad7af892c038d443133d136d4a6b0a
7
- data.tar.gz: efc08ec3d032925871c8f14a40a7ef02d5bd35a56b948eff18cc0589d99f0301b5a7606d7d7c3dd29ed4f4e5bde2226033b8e1865db0bb52beec59b9880e4225
6
+ metadata.gz: fd4d0abe0e5229176d2167d582607fe21250587111d9e9dffb306dfe48074c481f0e55b13de0cb0d483b0be61936aa9cea50305b221b7774fce7801c477eddf7
7
+ data.tar.gz: f5308a7cd27495d55d938b76f637d6d9436a0201643026ddf197572171bd7a075bf6fe74fb1a17e9077cef7be502f8a6aa7354c67953cd35dedb260610aac0be
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- # Elasticsearch Slowlog Logstash Plugin [![Build
2
- Status](https://travis-ci.org/ananthakumaran/logstash-filter-elasticsearchslowlog.svg?branch=master)](http://travis-ci.org/ananthakumaran/logstash-filter-elasticsearchslowlog)
1
+ # Elasticsearch Slowlog Logstash Plugin [![Build Status](https://travis-ci.org/ananthakumaran/logstash-filter-elasticsearchslowlog.svg?branch=master)](http://travis-ci.org/ananthakumaran/logstash-filter-elasticsearchslowlog)
3
2
 
4
3
  ## Installation
5
4
 
@@ -27,7 +27,7 @@ class LogStash::Filters::Elasticsearchslowlog < LogStash::Filters::Base
27
27
  SLOWLOG_REGEX = /^\s*\[(?<local_timestamp>[^,]+),\d+\]\s*\[(?<level>.+?)\s*\]\s*\[index.search.slowlog.(?:query|fetch)\]\s*\[(?<node>.+?)\]\s*\[(?<index>.+?)\]\s*\[(?<shard>.+?)\]\s*(?<key_values>.+)$/.freeze
28
28
 
29
29
  def filter(event)
30
- message = event.get(@source)
30
+ message = event[@source]
31
31
  if message
32
32
  if matches = message.match(SLOWLOG_REGEX)
33
33
  captures = Hash[matches.names.zip(matches.captures)]
@@ -37,7 +37,7 @@ class LogStash::Filters::Elasticsearchslowlog < LogStash::Filters::Base
37
37
  if ['shard'].include?(key)
38
38
  value = value.to_i
39
39
  end
40
- event.set(key, value)
40
+ event[key] = value
41
41
  end
42
42
  if captures['key_values']
43
43
  key_values = parse_key_values(captures['key_values'])
@@ -45,7 +45,7 @@ class LogStash::Filters::Elasticsearchslowlog < LogStash::Filters::Base
45
45
  if ['took_millis', 'total_shards'].include?(key)
46
46
  value = value.to_i
47
47
  end
48
- event.set(key, value)
48
+ event[key] = value
49
49
  end
50
50
 
51
51
  source = key_values['source']
@@ -54,8 +54,8 @@ class LogStash::Filters::Elasticsearchslowlog < LogStash::Filters::Base
54
54
  if normalized
55
55
  normalized = JSON.dump(normalized)
56
56
  source_id = Digest::MD5.hexdigest(normalized)[0..8]
57
- event.set('source_normalized', normalized)
58
- event.set('source_id', source_id)
57
+ event['source_normalized'] = normalized
58
+ event['source_id'] = source_id.force_encoding("utf-8")
59
59
  end
60
60
  end
61
61
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'logstash-filter-elasticsearchslowlog'
5
- s.version = '0.3.0'
5
+ s.version = '0.4.0'
6
6
  s.licenses = ['Apache-2.0']
7
7
  s.summary = 'elasticsearch slowlog parser'
8
8
  s.description = 'elasticsearch slowlog parser'
@@ -21,6 +21,6 @@ Gem::Specification.new do |s|
21
21
 
22
22
  # Gem dependencies
23
23
  s.add_runtime_dependency "deepsort", "0.4.0"
24
- s.add_runtime_dependency "logstash-core-plugin-api", "~> 1"
24
+ s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.20", "<= 2.99"
25
25
  s.add_development_dependency 'logstash-devutils'
26
26
  end
@@ -14,20 +14,20 @@ describe LogStash::Filters::Elasticsearchslowlog do
14
14
 
15
15
  describe "filter" do
16
16
  sample("message" => "some text") do
17
- expect(subject.get('message')).to eq('some text')
17
+ expect(subject['message']).to eq('some text')
18
18
  end
19
19
 
20
20
  sample("message" => '[2019-05-07T15:27:34,422][TRACE ][index.search.slowlog.query] [elasticsearch-data7.mid.veritrans.co.id] [transactionsv3_2018-12][2] took[350.9ms], took_millis[350], types[transaction], stats[], search_type[QUERY_THEN_FETCH], total_shards[111], source[{"from":0,"size":20,"query":{"bool":{"filter":[{"terms":{"transaction.merchant_id":["abcd"],"boost":1.0}}],"disable_coord":false,"adjust_pure_negative":true,"boost":1.0}},"sort":[{"transaction.transaction_time":{"order":"desc"}}]}],') do
21
- expect(subject.get('local_timestamp')).to eq('2019-05-07T15:27:34')
22
- expect(subject.get('level')).to eq('TRACE')
23
- expect(subject.get('node')).to eq('elasticsearch-data7.mid.veritrans.co.id')
24
- expect(subject.get('index')).to eq('transactionsv3_2018-12')
25
- expect(subject.get('shard')).to eq(2)
26
- expect(subject.get('took_millis')).to eq(350)
27
- expect(subject.get('types')).to eq('transaction')
28
- expect(subject.get('search_type')).to eq('QUERY_THEN_FETCH')
29
- expect(subject.get('total_shards')).to eq(111)
30
- expect(subject.get('source')).to eq('{"from":0,"size":20,"query":{"bool":{"filter":[{"terms":{"transaction.merchant_id":["abcd"],"boost":1.0}}],"disable_coord":false,"adjust_pure_negative":true,"boost":1.0}},"sort":[{"transaction.transaction_time":{"order":"desc"}}]}')
21
+ expect(subject['local_timestamp']).to eq('2019-05-07T15:27:34')
22
+ expect(subject['level']).to eq('TRACE')
23
+ expect(subject['node']).to eq('elasticsearch-data7.mid.veritrans.co.id')
24
+ expect(subject['index']).to eq('transactionsv3_2018-12')
25
+ expect(subject['shard']).to eq(2)
26
+ expect(subject['took_millis']).to eq(350)
27
+ expect(subject['types']).to eq('transaction')
28
+ expect(subject['search_type']).to eq('QUERY_THEN_FETCH')
29
+ expect(subject['total_shards']).to eq(111)
30
+ expect(subject['source']).to eq('{"from":0,"size":20,"query":{"bool":{"filter":[{"terms":{"transaction.merchant_id":["abcd"],"boost":1.0}}],"disable_coord":false,"adjust_pure_negative":true,"boost":1.0}},"sort":[{"transaction.transaction_time":{"order":"desc"}}]}')
31
31
  expect(subject).to include('source_id')
32
32
  end
33
33
  end
@@ -49,10 +49,10 @@ describe LogStash::Filters::Elasticsearchslowlog do
49
49
  expect(subject).to include('total_shards')
50
50
  expect(subject).to include('source')
51
51
  expect(subject).to include('source_id')
52
- unless subject.get('source_normalized') == source_normalized[i]
53
- puts subject.get('source_normalized')
52
+ unless subject['source_normalized'] == source_normalized[i]
53
+ puts subject['source_normalized']
54
54
  end
55
- expect(subject.get('source_normalized')).to eq(source_normalized[i])
55
+ expect(subject['source_normalized']).to eq(source_normalized[i])
56
56
  end
57
57
  end
58
58
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-elasticsearchslowlog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anantha Kumaran
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-08 00:00:00.000000000 Z
11
+ date: 2019-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -27,17 +27,23 @@ dependencies:
27
27
  - !ruby/object:Gem::Dependency
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
- - - "~>"
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '1.20'
33
+ - - "<="
31
34
  - !ruby/object:Gem::Version
32
- version: '1'
35
+ version: '2.99'
33
36
  name: logstash-core-plugin-api
34
37
  prerelease: false
35
38
  type: :runtime
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '1.20'
44
+ - - "<="
39
45
  - !ruby/object:Gem::Version
40
- version: '1'
46
+ version: '2.99'
41
47
  - !ruby/object:Gem::Dependency
42
48
  requirement: !ruby/object:Gem::Requirement
43
49
  requirements: