logstash-filter-device_detection 1.0.0-java → 1.0.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +88 -88
- data/lib/logstash/filters/device_detection.rb +100 -100
- data/logstash-filter-device_detection.gemspec +2 -1
- data/spec/filters/device_detection_spec.rb +68 -68
- data/vendor/51Degrees-LiteV3.2.dat +0 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04f4334964df71a2db520111dabec661499b789a
|
4
|
+
data.tar.gz: 6c934b2775f5f323e89ffe5f28e15a1fa7a93aa8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a967372a4cd38383385b7f1a8fac8b03451e543293a750b7e75a9e8502755cb3d60ea2806be6e126b9612102439107b09fc552aacea9ae5c8834d9f327f090b
|
7
|
+
data.tar.gz: de6f71c8970a06a3b177694a2cb863bad493c0d0a2d8d39224cc3e4134e9b8999f667d39884f2109146cc2234866a018f56536100a1df0767ef6033f39223e0c
|
data/README.md
CHANGED
@@ -1,88 +1,88 @@
|
|
1
|
-
# Logstash Plugin
|
2
|
-
|
3
|
-
[![Build Status](https://travis-ci.org/lalex/logstash-filter-device_detection.svg?branch=master)](https://travis-ci.org/lalex/logstash-filter-device_detection)
|
4
|
-
|
5
|
-
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
6
|
-
|
7
|
-
It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
|
8
|
-
|
9
|
-
## Documentation
|
10
|
-
|
11
|
-
Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
|
12
|
-
|
13
|
-
- For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
|
14
|
-
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
|
15
|
-
|
16
|
-
## Need Help?
|
17
|
-
|
18
|
-
Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
|
19
|
-
|
20
|
-
## Developing
|
21
|
-
|
22
|
-
### 1. Plugin Developement and Testing
|
23
|
-
|
24
|
-
#### Code
|
25
|
-
- To get started, you'll need JRuby with the Bundler gem installed.
|
26
|
-
|
27
|
-
- Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
|
28
|
-
|
29
|
-
- Install dependencies
|
30
|
-
```sh
|
31
|
-
bundle install
|
32
|
-
```
|
33
|
-
|
34
|
-
#### Test
|
35
|
-
|
36
|
-
- Update your dependencies
|
37
|
-
|
38
|
-
```sh
|
39
|
-
bundle install
|
40
|
-
```
|
41
|
-
|
42
|
-
- Run tests
|
43
|
-
|
44
|
-
```sh
|
45
|
-
bundle exec rspec
|
46
|
-
```
|
47
|
-
|
48
|
-
### 2. Running your unpublished Plugin in Logstash
|
49
|
-
|
50
|
-
#### 2.1 Run in a local Logstash clone
|
51
|
-
|
52
|
-
- Edit Logstash `Gemfile` and add the local plugin path, for example:
|
53
|
-
```ruby
|
54
|
-
gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
55
|
-
```
|
56
|
-
- Install plugin
|
57
|
-
```sh
|
58
|
-
bin/logstash-plugin install --no-verify
|
59
|
-
```
|
60
|
-
- Run Logstash with your plugin
|
61
|
-
```sh
|
62
|
-
bin/logstash -e 'filter {awesome {}}'
|
63
|
-
```
|
64
|
-
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
|
65
|
-
|
66
|
-
#### 2.2 Run in an installed Logstash
|
67
|
-
|
68
|
-
You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
|
69
|
-
|
70
|
-
- Build your plugin gem
|
71
|
-
```sh
|
72
|
-
gem build logstash-filter-awesome.gemspec
|
73
|
-
```
|
74
|
-
- Install the plugin from the Logstash home
|
75
|
-
```sh
|
76
|
-
bin/logstash-plugin install /your/local/plugin/logstash-filter-awesome.gem
|
77
|
-
```
|
78
|
-
- Start Logstash and proceed to test the plugin
|
79
|
-
|
80
|
-
## Contributing
|
81
|
-
|
82
|
-
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
|
83
|
-
|
84
|
-
Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
|
85
|
-
|
86
|
-
It is more important to the community that you are able to contribute.
|
87
|
-
|
88
|
-
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
1
|
+
# Logstash Plugin
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/lalex/logstash-filter-device_detection.svg?branch=master)](https://travis-ci.org/lalex/logstash-filter-device_detection)
|
4
|
+
|
5
|
+
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
6
|
+
|
7
|
+
It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
|
8
|
+
|
9
|
+
## Documentation
|
10
|
+
|
11
|
+
Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
|
12
|
+
|
13
|
+
- For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
|
14
|
+
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
|
15
|
+
|
16
|
+
## Need Help?
|
17
|
+
|
18
|
+
Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
|
19
|
+
|
20
|
+
## Developing
|
21
|
+
|
22
|
+
### 1. Plugin Developement and Testing
|
23
|
+
|
24
|
+
#### Code
|
25
|
+
- To get started, you'll need JRuby with the Bundler gem installed.
|
26
|
+
|
27
|
+
- Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
|
28
|
+
|
29
|
+
- Install dependencies
|
30
|
+
```sh
|
31
|
+
bundle install
|
32
|
+
```
|
33
|
+
|
34
|
+
#### Test
|
35
|
+
|
36
|
+
- Update your dependencies
|
37
|
+
|
38
|
+
```sh
|
39
|
+
bundle install
|
40
|
+
```
|
41
|
+
|
42
|
+
- Run tests
|
43
|
+
|
44
|
+
```sh
|
45
|
+
bundle exec rspec
|
46
|
+
```
|
47
|
+
|
48
|
+
### 2. Running your unpublished Plugin in Logstash
|
49
|
+
|
50
|
+
#### 2.1 Run in a local Logstash clone
|
51
|
+
|
52
|
+
- Edit Logstash `Gemfile` and add the local plugin path, for example:
|
53
|
+
```ruby
|
54
|
+
gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
55
|
+
```
|
56
|
+
- Install plugin
|
57
|
+
```sh
|
58
|
+
bin/logstash-plugin install --no-verify
|
59
|
+
```
|
60
|
+
- Run Logstash with your plugin
|
61
|
+
```sh
|
62
|
+
bin/logstash -e 'filter {awesome {}}'
|
63
|
+
```
|
64
|
+
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
|
65
|
+
|
66
|
+
#### 2.2 Run in an installed Logstash
|
67
|
+
|
68
|
+
You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
|
69
|
+
|
70
|
+
- Build your plugin gem
|
71
|
+
```sh
|
72
|
+
gem build logstash-filter-awesome.gemspec
|
73
|
+
```
|
74
|
+
- Install the plugin from the Logstash home
|
75
|
+
```sh
|
76
|
+
bin/logstash-plugin install /your/local/plugin/logstash-filter-awesome.gem
|
77
|
+
```
|
78
|
+
- Start Logstash and proceed to test the plugin
|
79
|
+
|
80
|
+
## Contributing
|
81
|
+
|
82
|
+
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
|
83
|
+
|
84
|
+
Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
|
85
|
+
|
86
|
+
It is more important to the community that you are able to contribute.
|
87
|
+
|
88
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
@@ -1,100 +1,100 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require "logstash/filters/base"
|
3
|
-
require "logstash/namespace"
|
4
|
-
|
5
|
-
require "logstash-filter-device_detection_jars.rb"
|
6
|
-
|
7
|
-
# [NOTE]
|
8
|
-
# --
|
9
|
-
# This product includes Device Detection data created by 51Degrees, available from
|
10
|
-
# https://51degrees.com/. This database is licensed under
|
11
|
-
# http://www.mozilla.org/MPL/2.0/[Mozilla Public License 2].
|
12
|
-
# --
|
13
|
-
|
14
|
-
class LogStash::Filters::DeviceDetection < LogStash::Filters::Base
|
15
|
-
|
16
|
-
config_name "device_detection"
|
17
|
-
|
18
|
-
# The field containing the User-Agent header string.
|
19
|
-
config :source, :validate => :string, :default => 'user_agent'
|
20
|
-
|
21
|
-
# Specify the field into which Logstash should store the device data.
|
22
|
-
config :target, :validate => :string, :default => 'device_match'
|
23
|
-
|
24
|
-
# Path to 51Degrees Device Detection data file. Only BinaryV32 format is supported now.
|
25
|
-
#
|
26
|
-
# If not specified, this will default to the 51Degrees Device Detection database
|
27
|
-
# that ships with Logstash.
|
28
|
-
config :datafile, :validate => :path
|
29
|
-
|
30
|
-
# Cache size for Device Detection library.
|
31
|
-
#
|
32
|
-
# This MUST be set to a value > 0.
|
33
|
-
config :cache_size, :validate => :number, :default => 1000
|
34
|
-
|
35
|
-
# An array of device properties to be included in the event.
|
36
|
-
#
|
37
|
-
# For the full property dictionary refer to
|
38
|
-
# https://51degrees.com/resources/property-dictionary
|
39
|
-
config :properties, :validate => :array
|
40
|
-
|
41
|
-
public
|
42
|
-
def register
|
43
|
-
|
44
|
-
if @datafile.nil?
|
45
|
-
@datafile = ::Dir.glob(::File.expand_path("../../../vendor/", ::File.dirname(__FILE__))+"/51Degrees-LiteV3.2.dat").first
|
46
|
-
|
47
|
-
if @datafile.nil? || !::File.exists?(@datafile)
|
48
|
-
raise "You must specify 'datafile => ...' in your device_detection filter (currently is set to '#{@datafile}')"
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
if @properties.nil? || @properties.empty?
|
53
|
-
raise "An array of device properties must not be empty."
|
54
|
-
end
|
55
|
-
|
56
|
-
begin
|
57
|
-
dataset = Java::FiftyoneMobileDetectionFactories::StreamFactory.create(@datafile, false)
|
58
|
-
@provider = Java::FiftyoneMobileDetection::Provider.new(dataset, @cache_size)
|
59
|
-
rescue StandardError => e
|
60
|
-
@logger.error("Error while initializing device detection provider object", :exception => e)
|
61
|
-
return
|
62
|
-
end
|
63
|
-
|
64
|
-
end # def register
|
65
|
-
|
66
|
-
public
|
67
|
-
def filter(event)
|
68
|
-
begin
|
69
|
-
|
70
|
-
begin
|
71
|
-
match = @provider.match(event.get(@source))
|
72
|
-
rescue StandardError => e
|
73
|
-
@logger.error("Error while parsing user agent data", :exception => e, :field => @source, :event => event)
|
74
|
-
return
|
75
|
-
end
|
76
|
-
|
77
|
-
return unless match
|
78
|
-
|
79
|
-
apply_match(match, event)
|
80
|
-
|
81
|
-
#event.set(@target, match.getValues("IsMobile").toString())
|
82
|
-
|
83
|
-
rescue Exception=>e
|
84
|
-
@logger.error("Failed to detect device", :exception => e, :field => @source)
|
85
|
-
end
|
86
|
-
|
87
|
-
# filter_matched should go in the last line of our successful code
|
88
|
-
filter_matched(event)
|
89
|
-
end # def filter
|
90
|
-
|
91
|
-
def apply_match(match, event)
|
92
|
-
@properties.each do |property|
|
93
|
-
field = "[#{@target}][#{property}]"
|
94
|
-
value = match.getValues(property)
|
95
|
-
event.set(field, value.toString()) if value
|
96
|
-
end
|
97
|
-
true
|
98
|
-
end
|
99
|
-
|
100
|
-
end # class LogStash::Filters::Browser
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/filters/base"
|
3
|
+
require "logstash/namespace"
|
4
|
+
|
5
|
+
require "logstash-filter-device_detection_jars.rb"
|
6
|
+
|
7
|
+
# [NOTE]
|
8
|
+
# --
|
9
|
+
# This product includes Device Detection data created by 51Degrees, available from
|
10
|
+
# https://51degrees.com/. This database is licensed under
|
11
|
+
# http://www.mozilla.org/MPL/2.0/[Mozilla Public License 2].
|
12
|
+
# --
|
13
|
+
|
14
|
+
class LogStash::Filters::DeviceDetection < LogStash::Filters::Base
|
15
|
+
|
16
|
+
config_name "device_detection"
|
17
|
+
|
18
|
+
# The field containing the User-Agent header string.
|
19
|
+
config :source, :validate => :string, :default => 'user_agent'
|
20
|
+
|
21
|
+
# Specify the field into which Logstash should store the device data.
|
22
|
+
config :target, :validate => :string, :default => 'device_match'
|
23
|
+
|
24
|
+
# Path to 51Degrees Device Detection data file. Only BinaryV32 format is supported now.
|
25
|
+
#
|
26
|
+
# If not specified, this will default to the 51Degrees Device Detection database
|
27
|
+
# that ships with Logstash.
|
28
|
+
config :datafile, :validate => :path
|
29
|
+
|
30
|
+
# Cache size for Device Detection library.
|
31
|
+
#
|
32
|
+
# This MUST be set to a value > 0.
|
33
|
+
config :cache_size, :validate => :number, :default => 1000
|
34
|
+
|
35
|
+
# An array of device properties to be included in the event.
|
36
|
+
#
|
37
|
+
# For the full property dictionary refer to
|
38
|
+
# https://51degrees.com/resources/property-dictionary
|
39
|
+
config :properties, :validate => :array
|
40
|
+
|
41
|
+
public
|
42
|
+
def register
|
43
|
+
|
44
|
+
if @datafile.nil?
|
45
|
+
@datafile = ::Dir.glob(::File.expand_path("../../../vendor/", ::File.dirname(__FILE__))+"/51Degrees-LiteV3.2.dat").first
|
46
|
+
|
47
|
+
if @datafile.nil? || !::File.exists?(@datafile)
|
48
|
+
raise "You must specify 'datafile => ...' in your device_detection filter (currently is set to '#{@datafile}')"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
if @properties.nil? || @properties.empty?
|
53
|
+
raise "An array of device properties must not be empty."
|
54
|
+
end
|
55
|
+
|
56
|
+
begin
|
57
|
+
dataset = Java::FiftyoneMobileDetectionFactories::StreamFactory.create(@datafile, false)
|
58
|
+
@provider = Java::FiftyoneMobileDetection::Provider.new(dataset, @cache_size)
|
59
|
+
rescue StandardError => e
|
60
|
+
@logger.error("Error while initializing device detection provider object", :exception => e)
|
61
|
+
return
|
62
|
+
end
|
63
|
+
|
64
|
+
end # def register
|
65
|
+
|
66
|
+
public
|
67
|
+
def filter(event)
|
68
|
+
begin
|
69
|
+
|
70
|
+
begin
|
71
|
+
match = @provider.match(event.get(@source))
|
72
|
+
rescue StandardError => e
|
73
|
+
@logger.error("Error while parsing user agent data", :exception => e, :field => @source, :event => event)
|
74
|
+
return
|
75
|
+
end
|
76
|
+
|
77
|
+
return unless match
|
78
|
+
|
79
|
+
apply_match(match, event)
|
80
|
+
|
81
|
+
#event.set(@target, match.getValues("IsMobile").toString())
|
82
|
+
|
83
|
+
rescue Exception=>e
|
84
|
+
@logger.error("Failed to detect device", :exception => e, :field => @source)
|
85
|
+
end
|
86
|
+
|
87
|
+
# filter_matched should go in the last line of our successful code
|
88
|
+
filter_matched(event)
|
89
|
+
end # def filter
|
90
|
+
|
91
|
+
def apply_match(match, event)
|
92
|
+
@properties.each do |property|
|
93
|
+
field = "[#{@target}][#{property}]"
|
94
|
+
value = match.getValues(property)
|
95
|
+
event.set(field, value.toString()) if value
|
96
|
+
end
|
97
|
+
true
|
98
|
+
end
|
99
|
+
|
100
|
+
end # class LogStash::Filters::Browser
|
@@ -1,10 +1,11 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-filter-device_detection'
|
3
|
-
s.version = '1.0.
|
3
|
+
s.version = '1.0.1'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = 'Use 51Degrees Device Detection library to parse User-Agent string'
|
6
6
|
s.authors = ['lalex']
|
7
7
|
s.email = 'github@lalex.nsk.ru'
|
8
|
+
s.homepage = 'https://github.com/lalex/logstash-filter-device_detection'
|
8
9
|
s.platform = "java"
|
9
10
|
s.require_paths = ['lib']
|
10
11
|
|
@@ -1,68 +1,68 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require_relative '../spec_helper'
|
3
|
-
require "logstash/filters/device_detection"
|
4
|
-
|
5
|
-
DATAFILE = ::Dir.glob(::File.expand_path("../../vendor/", ::File.dirname(__FILE__))+"/51Degrees-LiteV3.2.dat").first
|
6
|
-
|
7
|
-
describe LogStash::Filters::DeviceDetection do
|
8
|
-
|
9
|
-
describe "properties is not set" do
|
10
|
-
let(:config) do <<-CONFIG
|
11
|
-
filter {
|
12
|
-
device_detection {
|
13
|
-
#datafile => "#{DATAFILE}"
|
14
|
-
source => "user_agent"
|
15
|
-
target => "device_detection"
|
16
|
-
}
|
17
|
-
}
|
18
|
-
CONFIG
|
19
|
-
end
|
20
|
-
|
21
|
-
sample("user_agent" => "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0") do
|
22
|
-
expect { subject }.to raise_error(RuntimeError)
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "empty properties" do
|
28
|
-
let(:config) do <<-CONFIG
|
29
|
-
filter {
|
30
|
-
device_detection {
|
31
|
-
#datafile => "#{DATAFILE}"
|
32
|
-
source => "user_agent"
|
33
|
-
target => "device_detection"
|
34
|
-
properties => []
|
35
|
-
}
|
36
|
-
}
|
37
|
-
CONFIG
|
38
|
-
end
|
39
|
-
|
40
|
-
sample("user_agent" => "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0") do
|
41
|
-
expect { subject }.to raise_error(RuntimeError)
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "defaults" do
|
47
|
-
let(:config) do <<-CONFIG
|
48
|
-
filter {
|
49
|
-
device_detection {
|
50
|
-
#datafile => "#{DATAFILE}"
|
51
|
-
source => "user_agent"
|
52
|
-
target => "device_detection"
|
53
|
-
properties => ["BrowserName","BrowserVersion","IsMobile"]
|
54
|
-
}
|
55
|
-
}
|
56
|
-
CONFIG
|
57
|
-
end
|
58
|
-
|
59
|
-
sample("user_agent" => "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0") do
|
60
|
-
expect(subject.get('[device_detection][BrowserName]')).to eq('Firefox')
|
61
|
-
expect(subject.get('[device_detection][BrowserVersion]')).to eq('41.0')
|
62
|
-
expect(subject.get('[device_detection][IsMobile]')).to eq('False')
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require_relative '../spec_helper'
|
3
|
+
require "logstash/filters/device_detection"
|
4
|
+
|
5
|
+
DATAFILE = ::Dir.glob(::File.expand_path("../../vendor/", ::File.dirname(__FILE__))+"/51Degrees-LiteV3.2.dat").first
|
6
|
+
|
7
|
+
describe LogStash::Filters::DeviceDetection do
|
8
|
+
|
9
|
+
describe "properties is not set" do
|
10
|
+
let(:config) do <<-CONFIG
|
11
|
+
filter {
|
12
|
+
device_detection {
|
13
|
+
#datafile => "#{DATAFILE}"
|
14
|
+
source => "user_agent"
|
15
|
+
target => "device_detection"
|
16
|
+
}
|
17
|
+
}
|
18
|
+
CONFIG
|
19
|
+
end
|
20
|
+
|
21
|
+
sample("user_agent" => "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0") do
|
22
|
+
expect { subject }.to raise_error(RuntimeError)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "empty properties" do
|
28
|
+
let(:config) do <<-CONFIG
|
29
|
+
filter {
|
30
|
+
device_detection {
|
31
|
+
#datafile => "#{DATAFILE}"
|
32
|
+
source => "user_agent"
|
33
|
+
target => "device_detection"
|
34
|
+
properties => []
|
35
|
+
}
|
36
|
+
}
|
37
|
+
CONFIG
|
38
|
+
end
|
39
|
+
|
40
|
+
sample("user_agent" => "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0") do
|
41
|
+
expect { subject }.to raise_error(RuntimeError)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "defaults" do
|
47
|
+
let(:config) do <<-CONFIG
|
48
|
+
filter {
|
49
|
+
device_detection {
|
50
|
+
#datafile => "#{DATAFILE}"
|
51
|
+
source => "user_agent"
|
52
|
+
target => "device_detection"
|
53
|
+
properties => ["BrowserName","BrowserVersion","IsMobile"]
|
54
|
+
}
|
55
|
+
}
|
56
|
+
CONFIG
|
57
|
+
end
|
58
|
+
|
59
|
+
sample("user_agent" => "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0") do
|
60
|
+
expect(subject.get('[device_detection][BrowserName]')).to eq('Firefox')
|
61
|
+
expect(subject.get('[device_detection][BrowserVersion]')).to eq('41.0')
|
62
|
+
expect(subject.get('[device_detection][IsMobile]')).to eq('False')
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
end
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-device_detection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- lalex
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05
|
11
|
+
date: 2017-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -77,7 +77,7 @@ files:
|
|
77
77
|
- vendor/jar-dependencies/runtime-jars/logback-classic-1.1.8.jar
|
78
78
|
- vendor/jar-dependencies/runtime-jars/logback-core-1.1.8.jar
|
79
79
|
- vendor/jar-dependencies/runtime-jars/slf4j-api-1.7.21.jar
|
80
|
-
homepage:
|
80
|
+
homepage: https://github.com/lalex/logstash-filter-device_detection
|
81
81
|
licenses:
|
82
82
|
- Apache License (2.0)
|
83
83
|
metadata:
|