lstash 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTI2NWNjODBjNjBmNjEyOTE2OGMwMmEyMDdjYjFhZDAzYjU0ODZmYQ==
4
+ Y2YxYjRjNGYyMTA4MTdiNjQ5NjA2ZDU2MmE4Y2Y3MmZkNDRjYWMzYg==
5
5
  data.tar.gz: !binary |-
6
- NmFlZDNlYzU5OGJiYjk2MWU0MzZiNWJlZjM2MWQwZmNmMzUyNGQ0Mg==
6
+ Y2NhOTJlMmRjZmZlZmNkZGRhMDZkYmRhZWMwMzY5M2U4YTM0ZGE1YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTAyNTIwYzBmZGM1MjYwYzgxMjFhZjAwMjFlYzU0OTMwMjM3M2UwZDAyOGIy
10
- YTdmOWFiM2I2YzFjMjI2YmZiODczMzQ0OTA0ZTdjYzU4NDYwYzcwMjJkODQz
11
- N2NkZGIwZDU1MjA1NGQ4ODE2NzgyOTIxY2MyMWNjMmMyYzZkZjg=
9
+ MjA3MzA0OWQ3ZTVmOWU4YmE0NjdmNWQ4NjgzMTA0NTg4ZTcxNmJlZmI2YTA5
10
+ OGQ2Yzk5NTk1NjNhYzFmOTA3NDk0NmYyNjlmNzA4M2M2MzdiNzE4MmNiNDEz
11
+ MGZlNTg1Y2UxN2U5MzAxZmEyM2YxZmM1MDAwOTYwYzRjMWFiZDQ=
12
12
  data.tar.gz: !binary |-
13
- YWQ1ZDA1ZWFiODU4OGUzZWY2MWE2ZmQwNDBiOThlODNmNmQyYzQ3ODlkNzVh
14
- NzA4Njg0N2FhMTU5NGI3OGJlODc5YjlhNzg2MzcwZTFlMGFkNzQyOGZhOGQx
15
- NmVmNzZmNDAyOGU5YTBmN2IwMGZmMjFkMWYwNzQ2ZTlkODA5NjE=
13
+ YTQ5MmJiY2E4NjlkYzRlNTcyYWM0ZjA3NDQyNTc5MzNhNjhmMzVhM2MyOTZi
14
+ OGFjMzQ1Yjk1OTgzNDE1YmJhMzBmNDI1YmYxMDhjZmJlNmJkZjBlN2U2YTI5
15
+ ZGRlYWI0NjMwY2I0YjZlN2RlOWM3NDYxNTg5MjljZTlhNThiNDc=
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ *.log
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ### 0.1.4 / 2015-05-29
2
+
3
+ Enhancements
4
+
5
+ * Change default time steps from 1 hour to 120 seconds to aid in grepping from datasets with many events per minute.
6
+
7
+ ### 0.1.3 / 2015-05-28
8
+
9
+ Enhancements
10
+
11
+ * Remove troublesome development dependencies (autotest).
12
+
1
13
  ### 0.1.2 / 2015-01-02
2
14
 
3
15
  Enhancements
data/lib/lstash/client.rb CHANGED
@@ -14,6 +14,8 @@ module Lstash
14
14
  class ConnectionError < StandardError; end
15
15
 
16
16
  PER_PAGE = 5000.freeze # best time, lowest resource usage
17
+ DEFAULT_COUNT_STEP = 3600.freeze # 1 hour
18
+ DEFAULT_GREP_STEP = 120.freeze # 2 minutes
17
19
 
18
20
  def initialize(es_client, options = {})
19
21
  raise ConnectionError, "No elasticsearch client specified" if es_client.nil?
@@ -22,22 +24,22 @@ module Lstash
22
24
  @logger = options[:logger] || (options[:debug] ? debug_logger : NullLogger.new)
23
25
  end
24
26
 
25
- def count(query)
27
+ def count(query, step = DEFAULT_COUNT_STEP)
26
28
  @logger.debug "count from=#{query.from} to=#{query.to}"
27
29
 
28
30
  count = 0
29
- query.each_hour do |index, hour_query|
31
+ query.each_period(step) do |index, hour_query|
30
32
  count += count_messages(index, hour_query)
31
33
  end
32
34
  @logger.debug "total count=#{count}"
33
35
  count
34
36
  end
35
37
 
36
- def grep(query)
38
+ def grep(query, step = DEFAULT_GREP_STEP)
37
39
  @logger.debug "grep from=#{query.from} to=#{query.to}"
38
40
 
39
41
  count = 0
40
- query.each_hour do |index, hour_query|
42
+ query.each_period(step) do |index, hour_query|
41
43
  grep_messages(index, hour_query) do |message|
42
44
  count += 1
43
45
  yield message if block_given?
@@ -67,7 +69,7 @@ module Lstash
67
69
  while (messages.nil? || messages.count > 0) do
68
70
  result = Hashie::Mash.new @es_client.send(method, {
69
71
  index: index,
70
- scroll: '1m',
72
+ scroll: '5m',
71
73
  body: query.search(offset, PER_PAGE),
72
74
  }.merge(scroll_params))
73
75
 
data/lib/lstash/query.rb CHANGED
@@ -11,7 +11,6 @@ module Lstash
11
11
 
12
12
  LOGSTASH_PREFIX = 'logstash-'.freeze
13
13
  WILDCARD_QUERY = '*'.freeze
14
- HOUR_IN_SECONDS = 3600.freeze
15
14
 
16
15
  attr_accessor :from, :to
17
16
 
@@ -48,14 +47,14 @@ module Lstash
48
47
  }
49
48
  end
50
49
 
51
- def each_hour(&block)
52
- # iterate over the whole range in blocks of one hour
53
- time_iterate(@from.utc, @to.utc - 1, HOUR_IN_SECONDS) do |hour|
54
- yield index_name(hour.to_date),
50
+ def each_period(step, &block)
51
+ # iterate over the whole range in blocks of the specified period
52
+ time_iterate(@from.utc, @to.utc - 1, step) do |start_at|
53
+ yield index_name(start_at.to_date),
55
54
  Query.new(@query_string,
56
55
  anchor: @anchor,
57
- from: hour,
58
- to: hour + HOUR_IN_SECONDS)
56
+ from: start_at,
57
+ to: start_at + step)
59
58
  end
60
59
  end
61
60
 
@@ -1,3 +1,3 @@
1
1
  module Lstash
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -50,7 +50,7 @@ describe Lstash::Client do
50
50
 
51
51
  allow(es_client).to receive(:clear_scroll)
52
52
 
53
- expect(subject.grep(query)).to eq 28
53
+ expect(subject.grep(query, 3600)).to eq 28
54
54
  end
55
55
  end
56
56
 
@@ -91,12 +91,12 @@ describe Lstash::Query do
91
91
  its('to') { should eq Time.parse('2014-08-03 15:54:33.000000000 +0200') }
92
92
  end
93
93
 
94
- context "each_hour" do
94
+ context "each_period" do
95
95
  let(:options) { { from: 'firstday', anchor: 'yesterday', to: 'today' } }
96
96
  it "should iterate over range by hour" do
97
97
  indices = []
98
98
  queries = []
99
- subject.each_hour do |index, query|
99
+ subject.each_period(3600) do |index, query|
100
100
  indices << index
101
101
  queries << query
102
102
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lstash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Klaas Jan Wierenga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-28 00:00:00.000000000 Z
11
+ date: 2015-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler