fluent-plugin-extract_query_params 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +16 -0
- data/fluent-plugin-extract_query_params.gemspec +1 -1
- data/lib/fluent/plugin/out_extract_query_params.rb +30 -0
- data/test/plugin/test_out_extract_query_params.rb +85 -1
- metadata +11 -17
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1396de021b24f6213a916e19163285ae71c510fa
|
4
|
+
data.tar.gz: 142ad5a3809f685a61a197cdf055af0a1aa295e9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 50f99f2bdd7ca5d0f83d197c0a8d7beb39c491f160b7dfde64a388023a51e9e971e2f2173db2b88d593b5c3e00d23f5dbeb3afd4c8156feeac110a995090d04f
|
7
|
+
data.tar.gz: f92c5e653b1311665e7ec04e39631a453cbc88bd55195f69e56bd559dcbfbfbb124b6f544a97b5af887a697649dd1c2d2e25ae408726d2fe3c5928b6ad02f770
|
data/README.md
CHANGED
@@ -64,6 +64,22 @@ If set, the key/value whose key is included `except` will NOT be added to the re
|
|
64
64
|
|
65
65
|
If set to `true`, the original `key` url will be discarded from the record. Defaults to `false` (preserve key).
|
66
66
|
|
67
|
+
### add_url_scheme
|
68
|
+
|
69
|
+
If set to `true`, scheme (use `url_scheme` key) will be added to the record. Defaults to `false`.
|
70
|
+
|
71
|
+
### add_url_host
|
72
|
+
|
73
|
+
If set to `true`, host (use `url_host` key) will be added to the record. Defaults to `false`.
|
74
|
+
|
75
|
+
### add_url_port
|
76
|
+
|
77
|
+
If set to `true`, port (use `url_port` key) will be added to the record. Defaults to `false`.
|
78
|
+
|
79
|
+
### add_url_path
|
80
|
+
|
81
|
+
If set to `true`, path (use `url_path` key) will be added to the record. Defaults to `false`.
|
82
|
+
|
67
83
|
## Installation
|
68
84
|
|
69
85
|
Add this line to your application's Gemfile:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = 'fluent-plugin-extract_query_params'
|
3
|
-
gem.version = '0.0.
|
3
|
+
gem.version = '0.0.8'
|
4
4
|
gem.authors = ['Kentaro Kuribayashi']
|
5
5
|
gem.email = ['kentarok@gmail.com']
|
6
6
|
gem.homepage = 'http://github.com/kentaro/fluent-plugin-extract_query_params'
|
@@ -13,6 +13,11 @@ module Fluent
|
|
13
13
|
config_param :add_field_prefix, :string, :default => nil
|
14
14
|
config_param :permit_blank_key, :bool, :default => false
|
15
15
|
|
16
|
+
config_param :add_url_scheme, :bool, :default => false
|
17
|
+
config_param :add_url_host, :bool, :default => false
|
18
|
+
config_param :add_url_port, :bool, :default => false
|
19
|
+
config_param :add_url_path, :bool, :default => false
|
20
|
+
|
16
21
|
def initialize
|
17
22
|
super
|
18
23
|
require 'webrick'
|
@@ -58,6 +63,31 @@ module Fluent
|
|
58
63
|
rescue URI::InvalidURIError => e
|
59
64
|
URI.parse(WEBrick::HTTPUtils.escape(record[key]))
|
60
65
|
end
|
66
|
+
|
67
|
+
if @add_url_scheme
|
68
|
+
url_scheme_key = 'url_scheme'
|
69
|
+
url_scheme_key = @add_field_prefix + url_scheme_key if @add_field_prefix
|
70
|
+
record[url_scheme_key] = url.scheme || ''
|
71
|
+
end
|
72
|
+
|
73
|
+
if @add_url_host
|
74
|
+
url_host_key = 'url_host'
|
75
|
+
url_host_key = @add_field_prefix + url_host_key if @add_field_prefix
|
76
|
+
record[url_host_key] = url.host || ''
|
77
|
+
end
|
78
|
+
|
79
|
+
if @add_url_port
|
80
|
+
url_port_key = 'url_port'
|
81
|
+
url_port_key = @add_field_prefix + url_port_key if @add_field_prefix
|
82
|
+
record[url_port_key] = url.port || ''
|
83
|
+
end
|
84
|
+
|
85
|
+
if @add_url_path
|
86
|
+
url_path_key = 'url_path'
|
87
|
+
url_path_key = @add_field_prefix + url_path_key if @add_field_prefix
|
88
|
+
record[url_path_key] = url.path || ''
|
89
|
+
end
|
90
|
+
|
61
91
|
unless url.query.nil?
|
62
92
|
url.query.split('&').each do |pair|
|
63
93
|
key, value = pair.split('=').map { |i| URI.unescape(i) }
|
@@ -3,7 +3,8 @@
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
5
|
class ExtractQueryParamsOutputTest < Test::Unit::TestCase
|
6
|
-
URL = 'http://example.com/?foo=bar&baz=qux&%E3%83%A2%E3%83%AA%E3%82%B9=%E3%81%99%E3%81%9F%E3%81%98%E3%81%8A'
|
6
|
+
URL = 'http://example.com:80/?foo=bar&baz=qux&%E3%83%A2%E3%83%AA%E3%82%B9=%E3%81%99%E3%81%9F%E3%81%98%E3%81%8A'
|
7
|
+
QUERY_ONLY = '?foo=bar&baz=qux&%E3%83%A2%E3%83%AA%E3%82%B9=%E3%81%99%E3%81%9F%E3%81%98%E3%81%8A'
|
7
8
|
|
8
9
|
def setup
|
9
10
|
Fluent::Test.setup
|
@@ -325,4 +326,87 @@ class ExtractQueryParamsOutputTest < Test::Unit::TestCase
|
|
325
326
|
assert_equal 2, r.size
|
326
327
|
assert_equal 'b', r['a']
|
327
328
|
end
|
329
|
+
|
330
|
+
def test_filter_record_with_url_scheme_host_port_path
|
331
|
+
d = create_driver(%[
|
332
|
+
key url
|
333
|
+
add_tag_prefix extracted.
|
334
|
+
|
335
|
+
add_url_scheme true
|
336
|
+
add_url_host true
|
337
|
+
add_url_port true
|
338
|
+
add_url_path true
|
339
|
+
])
|
340
|
+
tag = 'test'
|
341
|
+
record = {
|
342
|
+
'url' => URL,
|
343
|
+
}
|
344
|
+
d.instance.filter_record('test', Time.now, record)
|
345
|
+
|
346
|
+
assert_equal URL, record['url']
|
347
|
+
assert_equal 'bar', record['foo']
|
348
|
+
assert_equal 'qux', record['baz']
|
349
|
+
assert_equal 'すたじお', record['モリス']
|
350
|
+
assert_equal 'http', record['url_scheme']
|
351
|
+
assert_equal 'example.com', record['url_host']
|
352
|
+
assert_equal 80, record['url_port']
|
353
|
+
assert_equal '/', record['url_path']
|
354
|
+
end
|
355
|
+
|
356
|
+
def test_filter_record_with_field_prefix_and_url_scheme_host_port_path
|
357
|
+
d = create_driver(%[
|
358
|
+
key url
|
359
|
+
add_field_prefix query_
|
360
|
+
add_tag_prefix extracted.
|
361
|
+
|
362
|
+
add_url_scheme true
|
363
|
+
add_url_host true
|
364
|
+
add_url_port true
|
365
|
+
add_url_path true
|
366
|
+
])
|
367
|
+
|
368
|
+
tag = 'test'
|
369
|
+
record = {
|
370
|
+
'url' => URL,
|
371
|
+
}
|
372
|
+
d.instance.filter_record('test', Time.now, record)
|
373
|
+
|
374
|
+
assert_equal URL, record['url']
|
375
|
+
assert_nil record['foo']
|
376
|
+
assert_nil record['baz']
|
377
|
+
assert_nil record['モリス']
|
378
|
+
assert_equal 'bar', record['query_foo']
|
379
|
+
assert_equal 'qux', record['query_baz']
|
380
|
+
assert_equal 'すたじお', record['query_モリス']
|
381
|
+
assert_equal 'http', record['query_url_scheme']
|
382
|
+
assert_equal 'example.com', record['query_url_host']
|
383
|
+
assert_equal 80, record['query_url_port']
|
384
|
+
assert_equal '/', record['query_url_path']
|
385
|
+
end
|
386
|
+
|
387
|
+
def test_filter_record_from_query_only_url_with_url_scheme_host_port_path
|
388
|
+
d = create_driver(%[
|
389
|
+
key url
|
390
|
+
add_tag_prefix extracted.
|
391
|
+
|
392
|
+
add_url_scheme true
|
393
|
+
add_url_host true
|
394
|
+
add_url_port true
|
395
|
+
add_url_path true
|
396
|
+
])
|
397
|
+
tag = 'test'
|
398
|
+
record = {
|
399
|
+
'url' => QUERY_ONLY,
|
400
|
+
}
|
401
|
+
d.instance.filter_record('test', Time.now, record)
|
402
|
+
|
403
|
+
assert_equal QUERY_ONLY, record['url']
|
404
|
+
assert_equal 'bar', record['foo']
|
405
|
+
assert_equal 'qux', record['baz']
|
406
|
+
assert_equal 'すたじお', record['モリス']
|
407
|
+
assert_equal '', record['url_scheme']
|
408
|
+
assert_equal '', record['url_host']
|
409
|
+
assert_equal '', record['url_port']
|
410
|
+
assert_equal '', record['url_path']
|
411
|
+
end
|
328
412
|
end
|
metadata
CHANGED
@@ -1,46 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-extract_query_params
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.8
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Kentaro Kuribayashi
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-12-20 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: fluentd
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
description: Fluentd plugin to extract key/values from URL query parameters.
|
@@ -62,27 +57,26 @@ files:
|
|
62
57
|
homepage: http://github.com/kentaro/fluent-plugin-extract_query_params
|
63
58
|
licenses:
|
64
59
|
- MIT
|
60
|
+
metadata: {}
|
65
61
|
post_install_message:
|
66
62
|
rdoc_options: []
|
67
63
|
require_paths:
|
68
64
|
- lib
|
69
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
-
none: false
|
71
66
|
requirements:
|
72
|
-
- -
|
67
|
+
- - '>='
|
73
68
|
- !ruby/object:Gem::Version
|
74
69
|
version: '0'
|
75
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
-
none: false
|
77
71
|
requirements:
|
78
|
-
- -
|
72
|
+
- - '>='
|
79
73
|
- !ruby/object:Gem::Version
|
80
74
|
version: '0'
|
81
75
|
requirements: []
|
82
76
|
rubyforge_project:
|
83
|
-
rubygems_version:
|
77
|
+
rubygems_version: 2.0.14
|
84
78
|
signing_key:
|
85
|
-
specification_version:
|
79
|
+
specification_version: 4
|
86
80
|
summary: Fluentd plugin to extract key/values from URL query parameters
|
87
81
|
test_files:
|
88
82
|
- test/plugin/test_out_extract_query_params.rb
|