log2json 0.1.22 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/redis2es +14 -5
- data/log2json.gemspec +1 -1
- metadata +2 -2
data/bin/redis2es
CHANGED
@@ -52,6 +52,10 @@ if FLUSH_TIMEOUT < 2 or FLUSH_TIMEOUT % 2 != 0
|
|
52
52
|
exit 1
|
53
53
|
end
|
54
54
|
|
55
|
+
# If the distance(in seconds) between a log record's timestamp and now is
|
56
|
+
# great than this value then the record will be dropped.
|
57
|
+
const(:DROP_OFF_TIME, 3600*24*7) # default is 1 week away from now.
|
58
|
+
|
55
59
|
# path to the redo log file that stores the log records that this process
|
56
60
|
# failed to send to ES.
|
57
61
|
const(:REDO_LOG, File.join(Dir.getwd, "redo.log"))
|
@@ -151,10 +155,12 @@ def handle_redo_log
|
|
151
155
|
FileUtils.rm(REDO_LOG)
|
152
156
|
end
|
153
157
|
|
158
|
+
|
154
159
|
# Determines the name of the index in ElasticSearch from the given log record's timestamp.
|
155
160
|
def es_index(tstamp)
|
156
161
|
begin
|
157
162
|
t = DateTime.parse(tstamp)
|
163
|
+
return nil if (Time.now - t.to_time).abs > DROP_OFF_TIME
|
158
164
|
rescue ArgumentError
|
159
165
|
LOG.warn("Failed parsing timestamp: #{tstamp}")
|
160
166
|
t = DateTime.now
|
@@ -174,11 +180,14 @@ def enqueue(logstr)
|
|
174
180
|
type, tstamp = log["@type"], log["@timestamp"]
|
175
181
|
end
|
176
182
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
183
|
+
index_name = es_index(tstamp)
|
184
|
+
if not index_name.nil?
|
185
|
+
# add header for each entry according to http://www.elasticsearch.org/guide/reference/api/bulk/
|
186
|
+
@queue << (
|
187
|
+
{"index" => {"_index" => index_name, "_type" => type}}.to_json << "\n" <<
|
188
|
+
logstr << "\n"
|
189
|
+
)
|
190
|
+
end
|
182
191
|
end
|
183
192
|
|
184
193
|
def load_redis_script
|
data/log2json.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'log2json'
|
3
|
-
s.version = '0.1.
|
3
|
+
s.version = '0.1.23'
|
4
4
|
s.summary = "Read, filter and ship logs. ie, poor man's roll-your-own, light-weight logstash replacement."
|
5
5
|
s.description = IO.read(File.join(File.dirname(__FILE__), 'README'))
|
6
6
|
s.authors = ['Jack Kuan']
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: log2json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.23
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-03-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jls-grok
|