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 +8 -8
- data/.gitignore +1 -0
- data/CHANGELOG.md +12 -0
- data/lib/lstash/client.rb +7 -5
- data/lib/lstash/query.rb +6 -7
- data/lib/lstash/version.rb +1 -1
- data/spec/lstash/client_spec.rb +1 -1
- data/spec/lstash/query_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Y2YxYjRjNGYyMTA4MTdiNjQ5NjA2ZDU2MmE4Y2Y3MmZkNDRjYWMzYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2NhOTJlMmRjZmZlZmNkZGRhMDZkYmRhZWMwMzY5M2U4YTM0ZGE1YQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjA3MzA0OWQ3ZTVmOWU4YmE0NjdmNWQ4NjgzMTA0NTg4ZTcxNmJlZmI2YTA5
|
10
|
+
OGQ2Yzk5NTk1NjNhYzFmOTA3NDk0NmYyNjlmNzA4M2M2MzdiNzE4MmNiNDEz
|
11
|
+
MGZlNTg1Y2UxN2U5MzAxZmEyM2YxZmM1MDAwOTYwYzRjMWFiZDQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTQ5MmJiY2E4NjlkYzRlNTcyYWM0ZjA3NDQyNTc5MzNhNjhmMzVhM2MyOTZi
|
14
|
+
OGFjMzQ1Yjk1OTgzNDE1YmJhMzBmNDI1YmYxMDhjZmJlNmJkZjBlN2U2YTI5
|
15
|
+
ZGRlYWI0NjMwY2I0YjZlN2RlOWM3NDYxNTg5MjljZTlhNThiNDc=
|
data/.gitignore
CHANGED
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.
|
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.
|
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: '
|
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
|
52
|
-
# iterate over the whole range in blocks of
|
53
|
-
time_iterate(@from.utc, @to.utc - 1,
|
54
|
-
yield index_name(
|
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:
|
58
|
-
to:
|
56
|
+
from: start_at,
|
57
|
+
to: start_at + step)
|
59
58
|
end
|
60
59
|
end
|
61
60
|
|
data/lib/lstash/version.rb
CHANGED
data/spec/lstash/client_spec.rb
CHANGED
data/spec/lstash/query_spec.rb
CHANGED
@@ -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 "
|
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.
|
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.
|
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-
|
11
|
+
date: 2015-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|