From 6bb58fc226782a48520a9d4971c89bd30a9a1e14 Mon Sep 17 00:00:00 2001 From: thdls55 Date: Thu, 16 Feb 2017 15:06:40 +0700 Subject: [PATCH 1/2] Add convenience fields. --- lib/logstash/filters/handsetdetection.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/logstash/filters/handsetdetection.rb b/lib/logstash/filters/handsetdetection.rb index 62dff13..b833f9b 100644 --- a/lib/logstash/filters/handsetdetection.rb +++ b/lib/logstash/filters/handsetdetection.rb @@ -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 @@ -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 From 1d338ea17fb3df5715a88d40d4f14e758d274bec Mon Sep 17 00:00:00 2001 From: thdls55 Date: Thu, 16 Feb 2017 15:13:08 +0700 Subject: [PATCH 2/2] Release version 4.1.7. --- logstash-filter-handsetdetection.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logstash-filter-handsetdetection.gemspec b/logstash-filter-handsetdetection.gemspec index 15bbda6..a94a47a 100644 --- a/logstash-filter-handsetdetection.gemspec +++ b/logstash-filter-handsetdetection.gemspec @@ -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"