logstash-filter-sumo 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +4 -0
- data/CONTRIBUTORS +6 -0
- data/Gemfile +7 -0
- data/LICENSE +1 -0
- data/README.md +78 -0
- data/lib/logstash/filters/sumo.rb +109 -0
- data/logstash-filter-sumo.gemspec +26 -0
- data/spec/filters/sumo_spec.rb +112 -0
- data/spec/spec_helper.rb +2 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9791dfa89ad6be36898f04ab8f49d05ad9bbb44b
|
4
|
+
data.tar.gz: 310bcb75636ebae5a57bc1e5d4d8ee9704e739cb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d12ee98e71095afe03c0ae1b090917081459c7c76c8d512abb8c944949395b725c97c33808bcd0ec04b790051ac5ff86e44452f2e37083d2a298f5f2bce8aa36
|
7
|
+
data.tar.gz: b3946cda9ea2c5526aefda2fdd527c731ebb43584054a189b10bdb402f003f152aebdbb50f697cdb16a230fd01a48ddd0463c98d9862183ffab3d658166c2586
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Noe lisens informasjon
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# Logstash Plugin
|
2
|
+
|
3
|
+
[](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Filters/job/logstash-plugin-filter-example-unit/)
|
5
|
+
|
6
|
+
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
7
|
+
|
8
|
+
## Documentation
|
9
|
+
|
10
|
+
## Developing
|
11
|
+
|
12
|
+
### 1. Plugin Developement and Testing
|
13
|
+
|
14
|
+
#### Code
|
15
|
+
- To get started, you'll need JRuby with the Bundler gem installed.
|
16
|
+
|
17
|
+
- 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).
|
18
|
+
|
19
|
+
- Install dependencies
|
20
|
+
```sh
|
21
|
+
bundle install
|
22
|
+
```
|
23
|
+
|
24
|
+
#### Test
|
25
|
+
|
26
|
+
- Update your dependencies
|
27
|
+
|
28
|
+
```sh
|
29
|
+
bundle install
|
30
|
+
```
|
31
|
+
|
32
|
+
- Run tests
|
33
|
+
|
34
|
+
```sh
|
35
|
+
bundle exec rspec
|
36
|
+
```
|
37
|
+
|
38
|
+
### 2. Running your unpublished Plugin in Logstash
|
39
|
+
|
40
|
+
#### 2.1 Run in a local Logstash clone
|
41
|
+
|
42
|
+
- Edit Logstash `Gemfile` and add the local plugin path, for example:
|
43
|
+
```ruby
|
44
|
+
gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
45
|
+
```
|
46
|
+
- Install plugin
|
47
|
+
```sh
|
48
|
+
bin/plugin install --no-verify
|
49
|
+
```
|
50
|
+
- Run Logstash with your plugin
|
51
|
+
```sh
|
52
|
+
bin/logstash -e 'filter {awesome {}}'
|
53
|
+
```
|
54
|
+
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
|
55
|
+
|
56
|
+
#### 2.2 Run in an installed Logstash
|
57
|
+
|
58
|
+
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:
|
59
|
+
|
60
|
+
- Build your plugin gem
|
61
|
+
```sh
|
62
|
+
gem build logstash-filter-awesome.gemspec
|
63
|
+
```
|
64
|
+
- Install the plugin from the Logstash home
|
65
|
+
```sh
|
66
|
+
bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
|
67
|
+
```
|
68
|
+
- Start Logstash and proceed to test the plugin
|
69
|
+
|
70
|
+
## Contributing
|
71
|
+
|
72
|
+
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
|
73
|
+
|
74
|
+
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.
|
75
|
+
|
76
|
+
It is more important to the community that you are able to contribute.
|
77
|
+
|
78
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/filters/base"
|
3
|
+
require "logstash/namespace"
|
4
|
+
require 'uri'
|
5
|
+
|
6
|
+
|
7
|
+
class LogStash::Filters::Sumo < LogStash::Filters::Base
|
8
|
+
config_name "sumo"
|
9
|
+
|
10
|
+
config :page, :validate => :string, :default => ""
|
11
|
+
|
12
|
+
|
13
|
+
def wzlive_parse(uarray)
|
14
|
+
web_stream = uarray[3].split(":")[1]
|
15
|
+
video_type = uarray.last.split(".").last
|
16
|
+
asset_id = uarray[4].split(".").first.split("_").first.to_i
|
17
|
+
|
18
|
+
{path_type: "wzlive", dist_type: "live", web_stream: web_stream, video_type: video_type, asset_id: asset_id}
|
19
|
+
end
|
20
|
+
|
21
|
+
def dashvod_parse(uarray)
|
22
|
+
asset_id = uarray[3].split(":")[1].split("_").first.to_i
|
23
|
+
last_seg = uarray.last.split(".")
|
24
|
+
video_type = last_seg.last
|
25
|
+
chunk_type = last_seg.first.include?('chunk_ctaudio') ? :audio : (last_seg.first.include?('chunk_ctvideo') ? :video : :other)
|
26
|
+
|
27
|
+
{path_type: "dashvod", dist_type: "vod", video_type: video_type, asset_id: asset_id, chunk_type: chunk_type}
|
28
|
+
end
|
29
|
+
|
30
|
+
def vod2_parse uarray
|
31
|
+
asset_id = uarray[3].split(":")[1].split("_").first.to_i
|
32
|
+
last_seg = uarray.last.split(".")
|
33
|
+
video_type = last_seg.last
|
34
|
+
|
35
|
+
#,video_type: video_type, asset_id: asset_id,chunk_type: chunk_type
|
36
|
+
{path_type: "vod2", dist_type: "vod", video_type: video_type, asset_id: asset_id}
|
37
|
+
end
|
38
|
+
|
39
|
+
# /ismusp/2013-10-22/N_RYANAIR_221013_TOB_NET(763009_R22MP41000).mp4
|
40
|
+
def ismusp_parse uarray
|
41
|
+
last_seg = uarray.last.split(".")
|
42
|
+
asset_id = last_seg[0].split("(")[1].split("_").first.to_i
|
43
|
+
video_type = last_seg.last
|
44
|
+
|
45
|
+
{path_type: "ismusp", dist_type: "vod", video_type: video_type, asset_id: asset_id}
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
# /ismusp/2013-10-22/N_RYANAIR_221013_TOB_NET(763009_R22MP41000).mp4
|
50
|
+
def ismvod_parse uarray
|
51
|
+
last_seg = uarray.last.split(".")
|
52
|
+
asset_id = uarray[3].split(":")[1].split(".").first.to_i
|
53
|
+
video_type = last_seg.last
|
54
|
+
|
55
|
+
{path_type: "ismvod", dist_type: "vod", video_type: video_type, asset_id: asset_id}
|
56
|
+
end
|
57
|
+
|
58
|
+
# /coraid_ism_1/2015-06-11/Bloggerne_4_(924507_ISM).ism/Manifest
|
59
|
+
# /netapp_ism_10/2015-04-01/R_BLOGGERNE4_EP25_G02371(902135_R283ISMH).ism/Manifest
|
60
|
+
def ism_parse uarray
|
61
|
+
page_type = uarray.pop.split(".")
|
62
|
+
page_info = uarray.pop
|
63
|
+
asset_id = page_info.split("(")[1].split("_")[0].to_i
|
64
|
+
|
65
|
+
{path_type: "ism", dist_type: "vod", video_type: page_type.last, asset_id: asset_id}
|
66
|
+
end
|
67
|
+
|
68
|
+
def parse_page page
|
69
|
+
return {} unless page.to_s.strip.length > 0
|
70
|
+
uri = URI.parse(page)
|
71
|
+
uarray = uri.path.split("/")
|
72
|
+
page_type = uarray[-2]
|
73
|
+
|
74
|
+
if uarray[1] == 'wzlive'
|
75
|
+
wzlive_parse(uarray)
|
76
|
+
elsif uarray[1] == 'dashvod'
|
77
|
+
dashvod_parse(uarray)
|
78
|
+
elsif uarray[1] == 'vod2'
|
79
|
+
vod2_parse(uarray)
|
80
|
+
elsif uarray[1] == 'ismusp'
|
81
|
+
ismusp_parse(uarray)
|
82
|
+
elsif uarray[1] == 'ismvod'
|
83
|
+
ismvod_parse(uarray)
|
84
|
+
elsif page_type.to_s.include?(".ism")
|
85
|
+
ism_parse(uarray)
|
86
|
+
else
|
87
|
+
{}
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
public
|
93
|
+
def register
|
94
|
+
# Add instance variables
|
95
|
+
end
|
96
|
+
|
97
|
+
# def register
|
98
|
+
|
99
|
+
public
|
100
|
+
def filter(event)
|
101
|
+
if @page
|
102
|
+
data = parse_page(@page)
|
103
|
+
data.each { |k, v|event[k.to_s]=v }
|
104
|
+
end
|
105
|
+
|
106
|
+
# filter_matched should go in the last line of our successful code
|
107
|
+
filter_matched(event)
|
108
|
+
end # def filter
|
109
|
+
end # class LogStash::Filters::Sumo
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'logstash-filter-sumo'
|
3
|
+
s.version = '1.0.0'
|
4
|
+
s.licenses = ['Apache License (2.0)']
|
5
|
+
s.summary = "This filter extracts interessting SUMO values from the page element if present."
|
6
|
+
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
|
7
|
+
s.authors = ["TV 2","Leif Terje Fonnes"]
|
8
|
+
s.email = 'leffen@gmail.com'
|
9
|
+
s.homepage = "http://tv2.no"
|
10
|
+
s.require_paths = ["lib"]
|
11
|
+
|
12
|
+
# Files
|
13
|
+
s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE']
|
14
|
+
|
15
|
+
# Tests
|
16
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
17
|
+
|
18
|
+
# Special flag to let us know this is actually a logstash plugin
|
19
|
+
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
|
20
|
+
|
21
|
+
# Gem dependencies
|
22
|
+
s.add_runtime_dependency "logstash-core", ">= 2.0.0", "< 3.0.0"
|
23
|
+
s.add_development_dependency 'logstash-devutils'
|
24
|
+
s.add_development_dependency 'rspec', '~> 2.7'
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require "logstash/filters/sumo"
|
4
|
+
|
5
|
+
describe LogStash::Filters::Sumo do
|
6
|
+
describe "Dashvod" do
|
7
|
+
let(:config) do <<-CONFIG
|
8
|
+
filter {
|
9
|
+
sumo {
|
10
|
+
page => "/dashvod/_definst_/amlst:993514_ps20000_pd1291830.smil/chunk_ctaudio_cfm4s_ridp0a1r1_cs28929600_mpd.m4s"
|
11
|
+
}
|
12
|
+
}
|
13
|
+
CONFIG
|
14
|
+
end
|
15
|
+
|
16
|
+
sample("page"=>"" ) do
|
17
|
+
expect(subject).to include("path_type")
|
18
|
+
expect(subject['path_type']).to eq('dashvod')
|
19
|
+
expect(subject['dist_type']).to eq('vod')
|
20
|
+
expect(subject['video_type']).to eq('m4s')
|
21
|
+
expect(subject['asset_id']).to eq(993514)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "ismusp" do
|
27
|
+
let(:config) do <<-CONFIG
|
28
|
+
filter {
|
29
|
+
sumo {
|
30
|
+
page => "/ismusp/2013-10-22/N_RYANAIR_221013_TOB_NET(763009_R22MP41000).mp4"
|
31
|
+
}
|
32
|
+
}
|
33
|
+
CONFIG
|
34
|
+
end
|
35
|
+
|
36
|
+
sample("page"=>"" ) do
|
37
|
+
expect(subject).to include("path_type")
|
38
|
+
expect(subject['path_type']).to eq('ismusp')
|
39
|
+
expect(subject['dist_type']).to eq('vod')
|
40
|
+
expect(subject['video_type']).to eq('mp4')
|
41
|
+
expect(subject['asset_id']).to eq(763009)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "vod2" do
|
47
|
+
let(:config) do <<-CONFIG
|
48
|
+
filter {
|
49
|
+
sumo {
|
50
|
+
page => "/vod2/_definst_/amlst:1027448_ps55210_pd1373700_HRDNGR.smil/media_b6378000_43.ts"
|
51
|
+
}
|
52
|
+
}
|
53
|
+
CONFIG
|
54
|
+
end
|
55
|
+
|
56
|
+
sample("page"=>"" ) do
|
57
|
+
expect(subject).to include("path_type")
|
58
|
+
expect(subject['path_type']).to eq('vod2')
|
59
|
+
expect(subject['dist_type']).to eq('vod')
|
60
|
+
expect(subject['video_type']).to eq('ts')
|
61
|
+
expect(subject['asset_id']).to eq(1027448)
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "wzlive" do
|
67
|
+
let(:config) do <<-CONFIG
|
68
|
+
filter {
|
69
|
+
sumo {
|
70
|
+
page => "/wzlive/_definst_/amlst:LS6/433127.smil/manifest.mpd"
|
71
|
+
}
|
72
|
+
}
|
73
|
+
CONFIG
|
74
|
+
end
|
75
|
+
|
76
|
+
sample("page"=>"" ) do
|
77
|
+
expect(subject).to include("path_type")
|
78
|
+
expect(subject['path_type']).to eq('wzlive')
|
79
|
+
expect(subject['dist_type']).to eq('live')
|
80
|
+
expect(subject['video_type']).to eq('mpd')
|
81
|
+
expect(subject['asset_id']).to eq(433127)
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
describe "wzlive" do
|
88
|
+
let(:config) do <<-CONFIG
|
89
|
+
filter {
|
90
|
+
sumo {
|
91
|
+
page => "/ismvod/_definst_/amlst:1027479.smil.ism/QualityLevels(126793)/Fragments(audio=143034920).isma"
|
92
|
+
}
|
93
|
+
}
|
94
|
+
CONFIG
|
95
|
+
end
|
96
|
+
|
97
|
+
sample("page"=>"" ) do
|
98
|
+
expect(subject).to include("path_type")
|
99
|
+
expect(subject['path_type']).to eq('ismvod')
|
100
|
+
expect(subject['dist_type']).to eq('vod')
|
101
|
+
expect(subject['video_type']).to eq('isma')
|
102
|
+
expect(subject['asset_id']).to eq(1027479)
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-filter-sumo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- TV 2
|
8
|
+
- Leif Terje Fonnes
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-03-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.0.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.0.0
|
23
|
+
name: logstash-core
|
24
|
+
prerelease: false
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 2.0.0
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.0.0
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
name: logstash-devutils
|
41
|
+
prerelease: false
|
42
|
+
type: :development
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.7'
|
54
|
+
name: rspec
|
55
|
+
prerelease: false
|
56
|
+
type: :development
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.7'
|
62
|
+
description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
|
63
|
+
email: leffen@gmail.com
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files: []
|
67
|
+
files:
|
68
|
+
- CHANGELOG.md
|
69
|
+
- CONTRIBUTORS
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE
|
72
|
+
- README.md
|
73
|
+
- lib/logstash/filters/sumo.rb
|
74
|
+
- logstash-filter-sumo.gemspec
|
75
|
+
- spec/filters/sumo_spec.rb
|
76
|
+
- spec/spec_helper.rb
|
77
|
+
homepage: http://tv2.no
|
78
|
+
licenses:
|
79
|
+
- Apache License (2.0)
|
80
|
+
metadata:
|
81
|
+
logstash_plugin: 'true'
|
82
|
+
logstash_group: filter
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.4.8
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: This filter extracts interessting SUMO values from the page element if present.
|
103
|
+
test_files:
|
104
|
+
- spec/filters/sumo_spec.rb
|
105
|
+
- spec/spec_helper.rb
|