Created
July 13, 2012 01:04
-
-
Save veered/3102107 to your computer and use it in GitHub Desktop.
New structured data parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def process_structured(event) | |
line = event.fields["tail"].first | |
properties, message = line.split("] ", 2) | |
properties.slice!(0) | |
properties.split("][").each do |group| | |
items = group.split | |
name = items.slice!(0).split("@", 2).first | |
items.each do |kv| | |
key, value = kv.split('="', 2) | |
event.fields["sd_#{name}_#{key || "nokey"}"] = value.chomp! || "novalue" | |
end | |
end | |
event.fields["message"] = message || "nomsg" | |
event.fields.delete("tail") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment