logstash-input-xlsx 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e5c5d203eadace1ecb5881043378cdadd03cf314
4
+ data.tar.gz: 352b638ff208f38b44840740c50c65f23693727b
5
+ SHA512:
6
+ metadata.gz: f39952b17ce4c45ca23f94c1eb252117a89e9a57e12c2618745226090349d4e4f62a749976a66dd342ec51733489f618195117335cfc37199a7c2784018eca5e
7
+ data.tar.gz: c4725beaaa1850b80474d924a0b3a63c2391bb5d8d1516f85f46f29d01e514eee7919ef771b9bc16869b61c11eb5269e1e4530e081515bbf1ad3ee208291fc1b
@@ -0,0 +1,3 @@
1
+ Gemfile.lock
2
+ .ruby-version
3
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012-2014 Elasticsearch <http://www.elasticsearch.org>
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,7 @@
1
+ @files=[]
2
+
3
+ task :default do
4
+ system("rake -T")
5
+ end
6
+
7
+ require "logstash/devutils/rake"
@@ -0,0 +1,173 @@
1
+ require "logstash/inputs/base"
2
+ require "logstash/namespace"
3
+
4
+ require "pathname"
5
+ require "socket" # for Socket.gethostname
6
+
7
+ # Stream events from files.
8
+ #
9
+ # By default, each event is assumed to be one line. If you
10
+ # want to join lines, you'll want to use the multiline filter.
11
+ #
12
+ # Files are followed in a manner similar to "tail -0F". File rotation
13
+ # is detected and handled by this input.
14
+ class LogStash::Inputs::Xlsx < LogStash::Inputs::Base
15
+ config_name "xlsx"
16
+
17
+ default :codec, "excel"
18
+
19
+ # The path to the file to use as an input.
20
+ # You can use globs here, such as `/var/log/*.log`
21
+ # Paths must be absolute and cannot be relative.
22
+ config :path, :validate => :array, :required => true
23
+
24
+ # Exclusions (matched against the filename, not full path). Globs
25
+ # are valid here, too. For example, if you have
26
+ #
27
+ # path => "/var/log/*"
28
+ #
29
+ # you might want to exclude gzipped files:
30
+ #
31
+ # exclude => "*.gz"
32
+ config :exclude, :validate => :array
33
+
34
+ # How often we stat files to see if they have been modified. Increasing
35
+ # this interval will decrease the number of system calls we make, but
36
+ # increase the time to detect new log lines.
37
+ config :stat_interval, :validate => :number, :default => 1
38
+
39
+ # How often we expand globs to discover new files to watch.
40
+ config :discover_interval, :validate => :number, :default => 15
41
+
42
+ # Where to write the since database (keeps track of the current
43
+ # position of monitored log files). The default will write
44
+ # sincedb files to some path matching "$HOME/.sincedb*"
45
+ config :sincedb_path, :validate => :string
46
+
47
+ # How often to write a since database with the current position of
48
+ # monitored log files.
49
+ config :sincedb_write_interval, :validate => :number, :default => 15
50
+
51
+ # Choose where logstash starts initially reading files - at the beginning or
52
+ # at the end. The default behavior treats files like live streams and thus
53
+ # starts at the end. If you have old data you want to import, set this
54
+ # to 'beginning'
55
+ #
56
+ # This option only modifieds "first contact" situations where a file is new
57
+ # and not seen before. If a file has already been seen before, this option
58
+ # has no effect.
59
+ config :start_position, :validate => [ "beginning", "end"], :default => "beginning"
60
+
61
+ # Should the progressdb events be send to the pipeline
62
+ config :progressdb, :validate => :boolean, :default => false
63
+
64
+ # Should the processdb entry be deleted after file-deletion
65
+ config :progressdb_del, :validate => :boolean, :default => false
66
+
67
+ public
68
+ def register
69
+ require "addressable/uri"
70
+ require "filewatch/ext/xlsxtail"
71
+ require "digest/md5"
72
+ require "logstash/codecs/plain"
73
+
74
+ @logger.info("Registering file input", :path => @path)
75
+
76
+ @tail_config = {
77
+ :exclude => @exclude,
78
+ :stat_interval => @stat_interval,
79
+ :discover_interval => @discover_interval,
80
+ :sincedb_write_interval => @sincedb_write_interval,
81
+ :logger => @logger,
82
+ :progressdb => @progressdb,
83
+ :progressdb_del => @progressdb_del,
84
+ }
85
+
86
+ @codec_plain = LogStash::Codecs::Plain.new
87
+
88
+ @path.each do |path|
89
+ if Pathname.new(path).relative?
90
+ raise ArgumentError.new("File paths must be absolute, relative path specified: #{path}")
91
+ end
92
+ end
93
+
94
+ if @sincedb_path.nil?
95
+ if ENV["SINCEDB_DIR"].nil? && ENV["HOME"].nil?
96
+ @logger.error("No SINCE_DB or HOME environment variable set, I don't know where " \
97
+ "to keep track of the files I'm watching. Either set " \
98
+ "HOME or SINCEDB_DIR in your environment, or set sincedb_path in " \
99
+ "in your logstash config for the file input with " \
100
+ "path '#{@path.inspect}'")
101
+ raise # TODO(sissel): HOW DO I FAIL PROPERLY YO
102
+ end
103
+
104
+ #pick SINCEDB_DIR if available, otherwise use HOME
105
+ sincedb_dir = ENV["SINCEDB_DIR"] || ENV["HOME"]
106
+
107
+ # Join by ',' to make it easy for folks to know their own sincedb
108
+ # generated path (vs, say, inspecting the @path array)
109
+ @sincedb_path = File.join(sincedb_dir, ".sincedb_" + Digest::MD5.hexdigest(@path.join(",")))
110
+
111
+ # Migrate any old .sincedb to the new file (this is for version <=1.1.1 compatibility)
112
+ old_sincedb = File.join(sincedb_dir, ".sincedb")
113
+ if File.exists?(old_sincedb)
114
+ @logger.info("Renaming old ~/.sincedb to new one", :old => old_sincedb,
115
+ :new => @sincedb_path)
116
+ File.rename(old_sincedb, @sincedb_path)
117
+ end
118
+
119
+ @logger.info("No sincedb_path set, generating one based on the file path",
120
+ :sincedb_path => @sincedb_path, :path => @path)
121
+ end
122
+
123
+ @tail_config[:sincedb_path] = @sincedb_path
124
+
125
+ if @start_position == "beginning"
126
+ @tail_config[:start_new_files_at] = :beginning
127
+ end
128
+ end # def register
129
+
130
+ public
131
+ def run(queue)
132
+ @tail = FileWatch::Ext::XlsxTail.new(@tail_config)
133
+ @tail.logger = @logger
134
+ @path.each { |path| @tail.tail(path) }
135
+ hostname = Socket.gethostname
136
+
137
+ @tail.subscribe do |path, data, type|
138
+ @logger.debug("Received line", :path => path, :data => data, :type => type) if logger.debug?
139
+
140
+ if type == :log
141
+ @codec.decode(data) do |event|
142
+
143
+ decorate(event)
144
+ #event["tags"] ||= []
145
+ event["host"] = hostname
146
+ event["path"] = path
147
+
148
+ queue << event
149
+ end #decode
150
+ elsif type == :progressdb || type == :progressdb_del
151
+ @codec_plain.decode(data) do |event|
152
+
153
+ decorate(event)
154
+ event["host"] = hostname
155
+ event["path"] = path
156
+ event["type"] = "progressdb";
157
+
158
+ event.tag("del") if type == :progressdb_del
159
+
160
+ queue << event
161
+ end #decode
162
+ end
163
+
164
+ end # subscribe
165
+ finished
166
+ end # def run
167
+
168
+ public
169
+ def teardown
170
+ @tail.sincedb_write
171
+ @tail.quit
172
+ end # def teardown
173
+ end # class LogStash::Inputs::File
@@ -0,0 +1,31 @@
1
+ Gem::Specification.new do |s|
2
+
3
+ s.name = 'logstash-input-xlsx'
4
+ s.version = '0.1.0'
5
+ s.licenses = ['Apache License (2.0)']
6
+ s.summary = "Read events from xlsx-files."
7
+ s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
8
+ s.authors = ["Signify"]
9
+ s.email = 'dietmar@signifydata.com'
10
+ s.homepage = "http://www.signifydata.com"
11
+ s.require_paths = ["lib"]
12
+
13
+ # Files
14
+ s.files = `git ls-files`.split($\)
15
+
16
+ # Tests
17
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
+
19
+ # Special flag to let us know this is actually a logstash plugin
20
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
21
+
22
+ # Gem dependencies
23
+ s.add_runtime_dependency 'logstash-core', '>= 1.4.0', '< 2.0.0'
24
+
25
+ s.add_runtime_dependency 'logstash-codec-excel'
26
+
27
+ s.add_runtime_dependency "filewatch-ext-excel", ["~> 0.2.0"]
28
+
29
+ s.add_development_dependency 'logstash-devutils'
30
+ end
31
+
@@ -0,0 +1,5 @@
1
+ require "logstash/devutils/rspec/spec_helper"
2
+ require 'logstash/inputs/xlsx'
3
+
4
+ describe LogStash::Inputs::Xlsx do
5
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-input-xlsx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Signify
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - '>='
17
+ - !ruby/object:Gem::Version
18
+ version: 1.4.0
19
+ - - <
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.0
22
+ name: logstash-core
23
+ prerelease: false
24
+ type: :runtime
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.4.0
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ name: logstash-codec-excel
40
+ prerelease: false
41
+ type: :runtime
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ~>
51
+ - !ruby/object:Gem::Version
52
+ version: 0.2.0
53
+ name: filewatch-ext-excel
54
+ prerelease: false
55
+ type: :runtime
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ version: 0.2.0
61
+ - !ruby/object:Gem::Dependency
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ name: logstash-devutils
68
+ prerelease: false
69
+ type: :development
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
76
+ email: dietmar@signifydata.com
77
+ executables: []
78
+ extensions: []
79
+ extra_rdoc_files: []
80
+ files:
81
+ - .gitignore
82
+ - Gemfile
83
+ - LICENSE
84
+ - Rakefile
85
+ - lib/logstash/inputs/xlsx.rb
86
+ - logstash-input-xlsx.gemspec
87
+ - spec/inputs/xlsx_spec.rb
88
+ homepage: http://www.signifydata.com
89
+ licenses:
90
+ - Apache License (2.0)
91
+ metadata:
92
+ logstash_plugin: 'true'
93
+ logstash_group: input
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.1.9
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Read events from xlsx-files.
114
+ test_files:
115
+ - spec/inputs/xlsx_spec.rb