tailf2kafka 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0511b332f01cad011509e5312d35a44406996394
4
- data.tar.gz: 1ca828eed00c80a7896b3cf384292e577d8832f5
3
+ metadata.gz: c4c3bad1a4caca5027bba89946e2a38de39bb6b7
4
+ data.tar.gz: 07b8a91f46d3592384200bc07418cfc0c514615f
5
5
  SHA512:
6
- metadata.gz: bbe8203735d60e6483a5aef2f0a3f6c0473828753fa5d4649313b56a147b96e63fa300bec9f6a5900995c6c56578b69e4db6af88d572c1e946fbb8a687508f56
7
- data.tar.gz: 1e9c1d14ad055d267a005208a5a2a59bd9a5786984bda8b323aff08b6703a75c596761ce688c9ec1552d8fd3a15dc6e5b78e1090ab7e9dd740890b937ab85997
6
+ metadata.gz: 62bba4611e56095855356bfd0e76c2173004f1948dcab31495701b94c29849b60df7a88a940b60334172f09f03b79606a8ee40a1b89518c9dc82e723c7334dae
7
+ data.tar.gz: 34232db94d928667aded3b4cd6ac544f8a487993087938b74f626806bd0a6e14f9bf3ff2c982242fc2f55955181e50530d16eb387a07924a454812aff6e20640
data/README.md CHANGED
@@ -5,13 +5,17 @@ Watch and tail files in dirs with specified filename time based patterns and pus
5
5
 
6
6
  ## Installation
7
7
 
8
+ Install libsnappy dev libs if you want to take advantage of compression
9
+
10
+ apt-get install libsnappy-dev
11
+
8
12
  Add this line to your application's Gemfile:
9
13
 
10
14
  gem 'tailf2kafka'
11
15
 
12
16
  And then execute:
13
17
 
14
- $ bundle
18
+ $ bundle install
15
19
 
16
20
  Or install it yourself as:
17
21
 
@@ -31,6 +35,7 @@ Or install it yourself as:
31
35
  files:
32
36
  - topic: haproxy
33
37
  prefix: /var/log/haproxy/haproxy
38
+ suffix: ''
34
39
  time_pattern: ".%Y-%m-%d.%H"
35
40
  position_file: "/var/lib/haproxy/tail2kafka.offsets"
36
41
  flush_interval: 1
@@ -40,6 +45,32 @@ Or install it yourself as:
40
45
  kafka:
41
46
  brokers: ["broker1:9092", "broker2:9092", "broker3:9092"]
42
47
  producer_type: sync
48
+ produce: true
49
+
50
+ * kafka.brokers - Array of kafka brokers to connect to
51
+ * kafka.producer_type - type of producer sync or async
52
+ * kafka.produce - if false will not conect to kafka and will not produce any messages to it
53
+ * tailf.position_file - file where to save tailed files offsets which were pushed to kafka
54
+ * tailf.flush_interval - how often in seconds to save the offsets to a file
55
+ * tailf.max_batch_lines - max number of lines to batch in each send request
56
+ * tailf.from_beggining - in case of a new file added to tailing , if to start tailing from beggining or end of the file
57
+ * tailf.delete_old_tailed_files - if to delete files once their time_pattern does not match the current time window and if they have been fully produced to kafka
58
+ * tailf.files - array of file configs for tail, each tailed file configs consists of:
59
+ * topic - which kafka topic to produce the messages to
60
+ * prefix - the files prefix to watch for
61
+ * time_pattern - ruby time pattern of files to tail
62
+ * suffix - optional suffix of files to watch for
63
+ so the tool will watch for files that match - prefix + time_pattern + suffix
64
+
65
+ ## Features/Facts
66
+
67
+ * The config is validated by [schash](https://github.com/ryotarai/schash) gem
68
+ * Tailed files are watched for changes by [rb-notify](https://github.com/nex3/rb-inotify) gem
69
+ * Dirnames of all files prefixes are watched for new files creation or files moved to the dir and are automaticaly
70
+ added to tailing.
71
+ * As well dirnames are watched for deletion or files being moved out of directory, and they are removed from the list of files watched for changing.
72
+ * Based time_pattern, files are periodicaly autodeleted , thus avoiding need for log rotation tools.
73
+ * Files are matched by converting time_pattern to a regexp
43
74
 
44
75
  ## Contributing
45
76
 
data/bin/tailf2kafka CHANGED
@@ -168,7 +168,7 @@ end
168
168
  dir = File.dirname(tailf_file[:prefix])
169
169
  if File.exists?(dir) and File.directory?(dir)
170
170
  @dirs[dir] ||= []
171
- @dirs[dir] << { :prefix => File.basename(tailf_file[:prefix]), :pattern => tailf_file[:time_pattern], :suffix => "#{tailf_file[:suffix]}" }
171
+ @dirs[dir] << { :prefix => File.basename(tailf_file[:prefix]), :pattern => tailf_file[:time_pattern], :suffix => "#{tailf_file[:suffix]}", :topic => tailf_file[:topic]}
172
172
  Dir.glob("#{tailf_file[:prefix]}*#{tailf_file[:suffix]}").each do |path|
173
173
  if path.match(Regexp.new(time_pattern_to_regexp(tailf_file[:time_pattern])))
174
174
  unless File.directory?(path)
@@ -207,12 +207,12 @@ Thread.new { loop { @timers.wait } }
207
207
  @create_notifier.watch(dir, :create, :moved_to) do |event|
208
208
  @mutex.synchronize do
209
209
  path = "#{dir}/#{event.name}"
210
- matches = @dirs[dir].select{|h| event.name.match(Regexp.new(h[:prefix] + time_pattern_to_regexp(h[:pattern]) + h[:suffix]))}.empty?
211
- unless matches.empty?
210
+ match = @dirs[dir].detect{|h| event.name.match(Regexp.new(h[:prefix] + time_pattern_to_regexp(h[:pattern]) + h[:suffix]))}
211
+ if match
212
212
  unless File.directory?(path)
213
213
  unless @threads.has_key?(path)
214
214
  puts "File #{event.name} was created in / moved into watched dir #{dir}"
215
- @files[path] = { :pattern => match.first[:pattern], :topic => File.basename(@dirs[dir].detect{|prefix| path.start_with?(prefix)}), :inode => File.stat(path).ino, :offset => 0 }
215
+ @files[path] = { :pattern => match[:pattern], :topic => match[:topic], :inode => File.stat(path).ino, :offset => 0 }
216
216
  @threads[path] = Thread.new { tailf(path) }
217
217
  end
218
218
  end
@@ -1,3 +1,3 @@
1
1
  module Tailf2Kafka
2
- VERSION ||= '0.1.0'
2
+ VERSION ||= '0.1.1'
3
3
  end
data/tailf2kafka.gemspec CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.has_rdoc = false
17
17
 
18
18
  s.add_dependency('poseidon')
19
+ s.add_dependency('snappy')
19
20
  s.add_dependency('hash_symbolizer')
20
21
  s.add_dependency('schash')
21
22
  s.add_dependency('rb-inotify')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tailf2kafka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Piavlo
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: snappy
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: hash_symbolizer
29
43
  requirement: !ruby/object:Gem::Requirement