log2json 0.1.8 → 0.1.9
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/README +13 -10
- data/bin/track-tails +6 -1
- data/log2json-loggers.gemspec +9 -0
- data/log2json.gemspec +1 -1
- metadata +102 -136
data/README
CHANGED
@@ -28,17 +28,17 @@ work, but are not tested. The input protocol expected by Log2json is very
|
|
28
28
|
simple and documented in the source code.
|
29
29
|
|
30
30
|
** The `tail-log` script uses a patched version of `tail` from the GNU coreutils
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
package. A binary of the `tail` utility compiled for Ubuntu 12.04 LTS is
|
32
|
+
included with the Log2json gem. If the binary doesn't work for your
|
33
|
+
distribution, then you'll need to get GNU coreutils-8.13, apply the patch(it
|
34
|
+
can be found in the src/ directory of the installed gem), and then replace
|
35
|
+
the bin/tail binary in the directory of the installed gem with your version
|
36
|
+
of the binary. **
|
37
37
|
|
38
38
|
P.S. If you know of a way to configure and compile ONLY the tail program in
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
coreutils, please let me know! The reason I'm not building tail post gem
|
40
|
+
installation is that it takes too long to configure && make because that
|
41
|
+
actually builds every utilties in coreutils.
|
42
42
|
|
43
43
|
|
44
44
|
For shipping logs to Redis, there's the `lines2redis` script that can be used as
|
@@ -61,6 +61,9 @@ On the Redis server:
|
|
61
61
|
redis_queue=jsonlogs redis2es host.to.es.server
|
62
62
|
|
63
63
|
|
64
|
+
Resources that help writing log2json filters:
|
64
65
|
|
65
|
-
|
66
|
+
- look at log2json.rb source and example filters
|
67
|
+
- http://grokdebug.herokuapp.com/
|
68
|
+
- http://www.ruby-doc.org/stdlib-1.9.3/libdoc/date/rdoc/DateTime.html#method-i-strftime
|
66
69
|
|
data/bin/track-tails
CHANGED
@@ -41,7 +41,12 @@ while line = gets()
|
|
41
41
|
fstat = File.stat(fpath)
|
42
42
|
@fmap[fpath] = [fstat.ino, fstat.size, 0]
|
43
43
|
end
|
44
|
-
|
44
|
+
if line =~ /<==$/
|
45
|
+
STDOUT.write(line); STDOUT.flush()
|
46
|
+
# Note: we don't print those '==> ... <== [....]' header lines that
|
47
|
+
# got added by our patch to tail because they might not be followed
|
48
|
+
# by lines from the indicating files.(eg, when a new empty file appears)
|
49
|
+
end
|
45
50
|
next
|
46
51
|
end
|
47
52
|
STDOUT.write(line); STDOUT.flush()
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'log2json-loggers'
|
3
|
+
s.version = '0.1.5'
|
4
|
+
s.summary = "Custom loggers for Rails and Unicorn that log to another file in addition to what their default loggers do."
|
5
|
+
s.description = IO.read(File.join(File.dirname(__FILE__), 'README'))
|
6
|
+
s.authors = ['Jack Kuan']
|
7
|
+
s.email = 'jack.kuan@thescore.com'
|
8
|
+
s.files = ['lib/log2json/railslogger.rb']
|
9
|
+
end
|
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.9'
|
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,133 +1,105 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: log2json
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 8
|
9
|
-
version: 0.1.8
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.9
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Jack Kuan
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-10-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: jls-grok
|
22
|
-
|
23
|
-
|
24
|
-
requirements:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
25
19
|
- - ~>
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 0
|
29
|
-
- 10
|
30
|
-
- 10
|
20
|
+
- !ruby/object:Gem::Version
|
31
21
|
version: 0.10.10
|
32
22
|
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: redis
|
36
23
|
prerelease: false
|
37
|
-
|
38
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
39
27
|
- - ~>
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.10.10
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: redis
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
45
37
|
version: 3.0.2
|
46
38
|
type: :runtime
|
47
|
-
version_requirements: *id002
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: persistent_http
|
50
39
|
prerelease: false
|
51
|
-
|
52
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
53
43
|
- - ~>
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 3.0.2
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: persistent_http
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
59
53
|
version: 1.0.5
|
60
54
|
type: :runtime
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
`
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
`tail`
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
the output process in the pipe. For shipping logs from Redis to ElasticSearch,
|
108
|
-
Log2json provides a `redis2es` script.
|
109
|
-
|
110
|
-
Finally here's an example of Log2json in action:
|
111
|
-
|
112
|
-
From a client machine:
|
113
|
-
|
114
|
-
tail-log /var/log/{sys,mail}log /var/log/{kern,auth}.log | syslog2json |
|
115
|
-
queue=jsonlogs \
|
116
|
-
flush_size=20 \
|
117
|
-
flush_interval=30 \
|
118
|
-
lines2redis host.to.redis.server 6379 0 # use redis DB 0
|
119
|
-
|
120
|
-
|
121
|
-
On the Redis server:
|
122
|
-
|
123
|
-
redis_queue=jsonlogs redis2es host.to.es.server
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.5
|
62
|
+
description: ! "Log2json lets you read, filter and send logs as JSON objects via Unix
|
63
|
+
pipes.\nIt is inspired by Logstash, and is meant to be compatible with it at the
|
64
|
+
JSON\nevent/record level so that it can easily work with Kibana. \n\nReading logs
|
65
|
+
is done via a shell script(eg, `tail`) running in its own process.\nYou then configure(see
|
66
|
+
the `syslog2json` or the `nginxlog2json` script for\nexamples) and run your filters
|
67
|
+
in Ruby using the `Log2Json` module and its\ncontained helper classes.\n\n`Log2Json`
|
68
|
+
reads from stdin the logs(one log record per line), parses the log\nlines into JSON
|
69
|
+
records, and then serializes and writes the records to stdout,\nwhich then can be
|
70
|
+
piped to another process for processing or sending it to\nsomewhere else.\n\nCurrently,
|
71
|
+
Log2json ships with a `tail-log` script that can be run as the input\nprocess. It's
|
72
|
+
the same as using the Linux `tail` utility with the `-v -F`\noptions except that
|
73
|
+
it also tracks the positions(as the numbers of lines read\nfrom the beginning of
|
74
|
+
the files) in a few files in the file system so that if the\ninput process is interrupted,
|
75
|
+
it can continue reading from where it left off\nnext time if the files had been
|
76
|
+
followed. This feature is similar to the sincedb\nfeature in Logstash's file input.\n\nNote:
|
77
|
+
If you don't need the tracking feature(ie, you are fine with always\ntailling from
|
78
|
+
the end of file with `-v -F -n0`), then you can just use the `tail`\nutility that
|
79
|
+
comes with your Linux distribution.(Or more specifically, the\n`tail` from the GNU
|
80
|
+
coreutils). Other versions of the `tail` utility may also\nwork, but are not tested.
|
81
|
+
The input protocol expected by Log2json is very\nsimple and documented in the source
|
82
|
+
code.\n\n** The `tail-log` script uses a patched version of `tail` from the GNU
|
83
|
+
coreutils\npackage. A binary of the `tail` utility compiled for Ubuntu 12.04 LTS
|
84
|
+
is\nincluded with the Log2json gem. If the binary doesn't work for your\ndistribution,
|
85
|
+
then you'll need to get GNU coreutils-8.13, apply the patch(it\ncan be found in
|
86
|
+
the src/ directory of the installed gem), and then replace\nthe bin/tail binary
|
87
|
+
in the directory of the installed gem with your version\nof the binary. ** \n\nP.S.
|
88
|
+
If you know of a way to configure and compile ONLY the tail program in\ncoreutils,
|
89
|
+
please let me know! The reason I'm not building tail post gem\ninstallation is that
|
90
|
+
it takes too long to configure && make because that\nactually builds every utilties
|
91
|
+
in coreutils.\n\n\nFor shipping logs to Redis, there's the `lines2redis` script
|
92
|
+
that can be used as\nthe output process in the pipe. For shipping logs from Redis
|
93
|
+
to ElasticSearch,\nLog2json provides a `redis2es` script.\n\nFinally here's an example
|
94
|
+
of Log2json in action:\n\nFrom a client machine:\n\n tail-log /var/log/{sys,mail}log
|
95
|
+
/var/log/{kern,auth}.log | syslog2json |\n queue=jsonlogs \\\n flush_size=20
|
96
|
+
\\\n flush_interval=30 \\\n lines2redis host.to.redis.server 6379
|
97
|
+
0 # use redis DB 0\n\n\nOn the Redis server:\n\n redis_queue=jsonlogs redis2es
|
98
|
+
host.to.es.server\n\n\nResources that help writing log2json filters:\n\n - look
|
99
|
+
at log2json.rb source and example filters\n - http://grokdebug.herokuapp.com/\n
|
100
|
+
\ - http://www.ruby-doc.org/stdlib-1.9.3/libdoc/date/rdoc/DateTime.html#method-i-strftime\n\n"
|
129
101
|
email: jack.kuan@thescore.com
|
130
|
-
executables:
|
102
|
+
executables:
|
131
103
|
- tail-log
|
132
104
|
- track-tails
|
133
105
|
- syslog2json
|
@@ -135,10 +107,8 @@ executables:
|
|
135
107
|
- lines2redis
|
136
108
|
- redis2es
|
137
109
|
extensions: []
|
138
|
-
|
139
110
|
extra_rdoc_files: []
|
140
|
-
|
141
|
-
files:
|
111
|
+
files:
|
142
112
|
- Gemfile
|
143
113
|
- Gemfile.lock
|
144
114
|
- README
|
@@ -155,38 +125,34 @@ files:
|
|
155
125
|
- lib/log2json/filters/nginx_access.rb
|
156
126
|
- lib/log2json/filters/syslog.rb
|
157
127
|
- lib/log2json/railslogger.rb
|
128
|
+
- log2json-loggers.gemspec
|
158
129
|
- log2json.gemspec
|
159
130
|
- src/coreutils-8.13_tail.patch
|
160
131
|
- src/tail.c
|
161
|
-
has_rdoc: true
|
162
132
|
homepage:
|
163
133
|
licenses: []
|
164
|
-
|
165
134
|
post_install_message:
|
166
135
|
rdoc_options: []
|
167
|
-
|
168
|
-
require_paths:
|
136
|
+
require_paths:
|
169
137
|
- lib
|
170
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
requirements:
|
179
|
-
- -
|
180
|
-
- !ruby/object:Gem::Version
|
181
|
-
|
182
|
-
- 0
|
183
|
-
version: "0"
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ! '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
184
150
|
requirements: []
|
185
|
-
|
186
151
|
rubyforge_project:
|
187
|
-
rubygems_version: 1.
|
152
|
+
rubygems_version: 1.8.23
|
188
153
|
signing_key:
|
189
154
|
specification_version: 3
|
190
|
-
summary: Read, filter and ship logs. ie, poor man's roll-your-own, light-weight logstash
|
155
|
+
summary: Read, filter and ship logs. ie, poor man's roll-your-own, light-weight logstash
|
156
|
+
replacement.
|
191
157
|
test_files: []
|
192
|
-
|
158
|
+
has_rdoc:
|