Skip to content

Commit

Permalink
Merge pull request #16 from anjo/master
Browse files Browse the repository at this point in the history
Allowing fields to appear anywhere in the output via --meta=...,fields,...
  • Loading branch information
jedi4ever committed May 29, 2013
2 parents 4fb8d32 + d26299c commit 707e2df
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/logstash-cli/command/grep.rb
Expand Up @@ -100,12 +100,22 @@ def _grep(pattern,options)

search.results.sort {|a,b| a[:@timestamp] <=> b[:@timestamp] }.each do |res|

had_fields = false
metafields.each do |metafield|
result << res["@#{metafield}".to_sym]
if metafield == 'fields' then
fields.each do |field|
result << res[:@fields][field.to_sym]
end
had_fields = true
else
result << res["@#{metafield}".to_sym]
end
end

fields.each do |field|
result << res[:@fields][field.to_sym]
if !had_fields then
fields.each do |field|
result << res[:@fields][field.to_sym]
end
end

puts _format(result, options)
Expand Down

0 comments on commit 707e2df

Please sign in to comment.