Skip to content
This repository has been archived by the owner on Nov 15, 2020. It is now read-only.

Commit

Permalink
Merge pull request #16 from thdls55/master
Browse files Browse the repository at this point in the history
Add convenience fields general_device_name, general_platform_name, general_browser_name and general_app_name.
  • Loading branch information
elricho authored Feb 16, 2017
2 parents e22edf2 + 1d338ea commit 269f03d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions lib/logstash/filters/handsetdetection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def filter(event)
event.set '[handset_detection][message]', r['message']
end
if r.key? 'hd_specs'
r['hd_specs'] = add_convenience_fields r['hd_specs']
if @filter.empty?
event.set '[handset_detection][specs]', r['hd_specs']
else
Expand All @@ -134,4 +135,24 @@ def filter(event)
end
filter_matched event
end

def add_convenience_fields(specs)
unless specs.key? 'general_device_name'
if specs.key? 'general_aliases' and specs['general_aliases'].is_a? Array and specs['general_aliases'].count > 0
specs['general_device_name'] = specs['general_aliases'][0].strip
else
specs['general_device_name'] = "#{specs.fetch('general_vendor', '')} #{specs.fetch('general_model', '')}".strip
end
end
unless specs.key? 'general_platform_name'
specs['general_platform_name'] = "#{specs.fetch('general_platform', '')} #{specs.fetch('general_platform_version', '')}".strip
end
unless specs.key? 'general_browser_name'
specs['general_browser_name'] = "#{specs.fetch('general_browser', '')} #{specs.fetch('general_browser_version', '')}".strip
end
unless specs.key? 'general_app_name'
specs['general_app_name'] = "#{specs.fetch('general_app', '')} #{specs.fetch('general_app_version', '')}".strip
end
specs
end
end
2 changes: 1 addition & 1 deletion logstash-filter-handsetdetection.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'logstash-filter-handsetdetection'
s.version = '4.1.6'
s.version = '4.1.7'
s.licenses = ['MIT']
s.summary = "Handset Detection filter plugin for Logstash"
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
Expand Down

0 comments on commit 269f03d

Please sign in to comment.