- purge old stuff

This commit is contained in:
Jordan Sissel 2010-10-17 10:32:13 +00:00
parent 9f3114c883
commit 141a4c64ed
2 changed files with 0 additions and 129 deletions

View file

@ -1,44 +0,0 @@
#!/usr/bin/ruby
require 'rubygems'
require 'erb'
require 'json'
require 'lib/log'
require 'lib/util'
module LogStash
class Log
class JsonLog < LogStash::Log
def initialize(config_params)
config = config_params.clone
config[:encoding] = "json"
required_keys = REQUIRED_KEYS + [:line_format]
optional_keys = OPTIONAL_KEYS + []
check_hash_keys(config, required_keys, optional_keys)
@line_format = config.delete(:line_format)
super(config)
end
def parse_entry(raw_entry)
begin
res = LogStash::Util::collapse(JSON.parse(raw_entry))
rescue JSON::ParserError
raise LogParseError.new("Invalid JSON: #{$!}: #{raw_entry}")
end
res["@LINE"] = template(@line_format, res)
fix_date(res)
return res
end
private
def template(fmt, entry)
erb = ERB.new(fmt)
return erb.result(binding)
end # def template
end # class JsonLog
end
end # module LogStash::Log

View file

@ -1,85 +0,0 @@
#!/usr/bin/ruby
require 'rubygems'
require 'find'
require 'json'
require 'lib/log'
require 'Grok'
module LogStash
class Log
class TextLog < LogStash::Log
def initialize(config_params)
config = config_params.clone
config[:encoding] = "text"
required_keys = REQUIRED_KEYS + [:grok_patterns]
optional_keys = OPTIONAL_KEYS + []
check_hash_keys(config, required_keys, optional_keys)
if not config[:grok_patterns].is_a?(Array)
throw LogException.new(":grok_patterns must be an array")
end
@grok_patterns = config.delete(:grok_patterns)
super(config)
if not File.exists?(@pattern_dir)
throw StandardError.new("#{@pattern_dir} does not exist")
end
if File.symlink?(@pattern_dir)
@pattern_dir = File.readlink(@pattern_dir)
end
pattern_files = []
Find.find("#{@pattern_dir}") do |file|
# ignore directories
next if File.directory?(file)
# ignore dotfiles
next if file.include?("/.")
pattern_files << file
end
# initialize groks for each pattern
@groks = []
@grok_patterns.each do |pattern|
grok = Grok.new
pattern_files.each { |f| grok.add_patterns_from_file(f) }
#puts "Compiling #{pattern} / #{grok}"
grok.compile(pattern)
#puts grok.expanded_pattern
@groks << grok
end
end # def initialize
def parse_entry(raw_entry)
match = nil
@groks.each do |grok|
match = grok.match(raw_entry)
break if match
end
return nil unless match
res = Hash.new { |h,k| h[k] = Array.new }
# We're parsing GROK captures, and there are two kinds of outputs:
# QUOTEDSTRING:bar - matched pattern QUOTEDSTRING, var named bar, keep
# DATA - matched pattern DATA, but no variable name, so we ditch it
match.each_capture do |key, value|
next if value == nil or value == ""
if key =~ /^.+:(.+)$/
res[$1] = value
else
res[key] = value
end
end
# add meta @LINE to represent the original input
res["@LINE"] = raw_entry
return fix_date(res)
end # def parse_entry
end # class TextLog
end # class Log
end # module LogStash