logstash-filter-sumo 3.0.22 → 3.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/logstash/filters/sumo.rb +102 -59
- data/logstash-filter-sumo.gemspec +2 -4
- data/spec/filters/sumo_spec.rb +55 -1
- metadata +8 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f33a38e9d825ac9c11e56c73f870357cacf217b5
|
4
|
+
data.tar.gz: 2e8cf5b1fe19a4dae2b0b182bb9758ff3ea30c62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a83ac97a4e74948f3953b66ad26f78f9288627856dcee9f0781d4a96a913678e0c9e7d4ffc226de9a3c02403a483b3abf822f92bc2f43f05f201b343907bf44a
|
7
|
+
data.tar.gz: cfa280d10677fb1cbd2d0e8c58b803156bc12bd2bef4b0d84306d49602e4617b38654803f688d2557a6b842a1eb276de709d650fd059afe5d51a038c9f3b4f51
|
data/README.md
CHANGED
@@ -14,7 +14,10 @@ This projects needs jruby, so use "rvm use jruby". Tested and deployed with jrub
|
|
14
14
|
3.0.20 Added support for hdsvod
|
15
15
|
3.0.21 Added support for vod4
|
16
16
|
3.0.22 Added support for /origin1-live.akamai.tv2.no/live/727992.isml/Manifest
|
17
|
-
|
17
|
+
3.0.23 Fix of bug in parsing origin1-live urls
|
18
|
+
3.0.25 Added support for akamai cache_key
|
19
|
+
3.0.26 Added support for /origin2-od.akamai.tv2.no/ismusp/isi_mp4_0/2014-04-25/G018902sumo(809735_ISMUSP).ism/Manifest
|
20
|
+
3.0.27 Added exception handling for page_parse part
|
18
21
|
|
19
22
|
## Build
|
20
23
|
Update the version numder in logstash-filter-sumo.gemspec
|
@@ -52,6 +52,16 @@ class LogStash::Filters::Sumo < LogStash::Filters::Base
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def ismusp_parse uarray
|
55
|
+
if uarray.last == "Manifest"
|
56
|
+
# handle /origin2-od.akamai.tv2.no/ismusp/isi_mp4_0/2014-04-25/G018902sumo(809735_ISMUSP).ism/Manifest
|
57
|
+
last_seg = uarray[-2].split(".")
|
58
|
+
asset_id = last_seg[0].split("(")[1].split("_").first.to_i
|
59
|
+
video_type = last_seg.last
|
60
|
+
|
61
|
+
return {path_type: "ismusp", dist_type: "vod", video_type: video_type, asset_id: asset_id,vtype: "manifest"}
|
62
|
+
|
63
|
+
end
|
64
|
+
|
55
65
|
last_seg = uarray.last.split(".")
|
56
66
|
asset_id = last_seg[0].split("(")[1].split("_").first.to_i
|
57
67
|
video_type = last_seg.last
|
@@ -90,7 +100,13 @@ class LogStash::Filters::Sumo < LogStash::Filters::Base
|
|
90
100
|
def ism_parse uarray
|
91
101
|
page_type = uarray.pop.split(".")
|
92
102
|
page_info = uarray.pop
|
93
|
-
|
103
|
+
|
104
|
+
ua = page_info.split("(")
|
105
|
+
puts "ism_parse ua = #{ua}"
|
106
|
+
asset_id = nil
|
107
|
+
if ua.count > 1
|
108
|
+
asset_id = ua[1].split("_")[0].to_i
|
109
|
+
end
|
94
110
|
|
95
111
|
{path_type: "ism", dist_type: "vod", video_type: page_type.last, asset_id: asset_id}
|
96
112
|
end
|
@@ -111,16 +127,14 @@ class LogStash::Filters::Sumo < LogStash::Filters::Base
|
|
111
127
|
def isml_parse uarray
|
112
128
|
# ["", "live", "727992.isml"]
|
113
129
|
|
114
|
-
# /
|
115
|
-
if uarray.last == "Manifest" && uarray[
|
116
|
-
aparts = uarray[
|
130
|
+
# /live/727992.isml/Manifest
|
131
|
+
if uarray.length > 2 && uarray.last == "Manifest" && uarray[1]== "live"
|
132
|
+
aparts = uarray[2].to_s.split(".")
|
117
133
|
asset_id = aparts[0]
|
118
134
|
|
119
135
|
return {path_type: "live", dist_type: "live", video_type: "ism", vtype: "manifest", asset_id: asset_id.to_s.to_i}
|
120
136
|
end
|
121
137
|
|
122
|
-
|
123
|
-
|
124
138
|
page_name = uarray.pop
|
125
139
|
splitted_page = page_name.split(".")
|
126
140
|
|
@@ -198,45 +212,66 @@ class LogStash::Filters::Sumo < LogStash::Filters::Base
|
|
198
212
|
|
199
213
|
def parse_page page
|
200
214
|
return {} unless page.to_s.strip.length > 0
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
215
|
+
begin
|
216
|
+
rc = {page: page}
|
217
|
+
uri = URI.parse(page)
|
218
|
+
|
219
|
+
# puts "URI = #{uri} page=#{page}"
|
220
|
+
|
221
|
+
uarray = uri.path.split("/")
|
222
|
+
return {} if uarray.length < 2
|
223
|
+
|
224
|
+
cache_key = ""
|
225
|
+
start_word = uarray[1].to_s
|
226
|
+
if start_word.include?("origin") && start_word.include?("akamai")
|
227
|
+
cache_key = uarray.delete_at(1)
|
228
|
+
# puts "CACHEKEY #{cache_key}"
|
229
|
+
end
|
230
|
+
|
231
|
+
|
232
|
+
page_type = uarray[-2]
|
233
|
+
|
234
|
+
return {} unless page_type && uarray.count > 0
|
235
|
+
|
236
|
+
root_page = uarray[1].to_s.downcase
|
237
|
+
|
238
|
+
#puts "root_page #{root_page} page_type=#{page_type} page=#{page}"
|
239
|
+
|
240
|
+
rc = {}
|
241
|
+
|
242
|
+
if root_page == 'wzlive'
|
243
|
+
rc = wzlive_parse(uarray)
|
244
|
+
elsif root_page.include?('dashvod')
|
245
|
+
rc = dashvod_parse(uarray)
|
246
|
+
elsif root_page == 'vod2'
|
247
|
+
rc = vod2_parse(uarray)
|
248
|
+
elsif root_page.start_with? 'vod'
|
249
|
+
rc = vod_parse(uarray)
|
250
|
+
elsif root_page == 'ismusp'
|
251
|
+
rc = ismusp_parse(uarray)
|
252
|
+
elsif root_page.include?('ismvod')
|
253
|
+
rc = ismvod_parse(uarray)
|
254
|
+
elsif root_page.include?('hdsvod')
|
255
|
+
rc = hdsvod_parse(uarray)
|
256
|
+
elsif root_page == 'out'
|
257
|
+
rc = out_parse uarray
|
258
|
+
elsif page_type.to_s.include?(".isml") && root_page.to_s.include?("live")
|
259
|
+
rc = isml_parse(uarray)
|
260
|
+
elsif page_type.to_s.include?(".ism")
|
261
|
+
rc = ism_parse(uarray)
|
262
|
+
elsif root_page == 'live'
|
263
|
+
rc = isml_parse uarray
|
264
|
+
elsif root_page.include?("healthcheck")
|
265
|
+
rc = {path_type: "healthcheck", dist_type: "healthcheck", video_type:"healthcheck"}
|
266
|
+
end
|
267
|
+
rc[:cache_key]= cache_key if cache_key.length > 0
|
268
|
+
rescue => e
|
269
|
+
rc[:exception]= e.to_json
|
270
|
+
rc[:page] = page
|
271
|
+
puts "SUMO parse_page #{e} rc=#{rc}"
|
272
|
+
@logger.error("SUMO.parse_page> ", :page => page, :exception => e)
|
239
273
|
end
|
274
|
+
rc
|
240
275
|
end
|
241
276
|
|
242
277
|
|
@@ -250,25 +285,33 @@ class LogStash::Filters::Sumo < LogStash::Filters::Base
|
|
250
285
|
public
|
251
286
|
def filter(event)
|
252
287
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
288
|
+
begin
|
289
|
+
return unless filter?(@field)
|
290
|
+
|
291
|
+
if @field
|
292
|
+
fieldValue = event.get(@field)
|
293
|
+
|
294
|
+
if fieldValue
|
295
|
+
begin
|
296
|
+
data = parse_page(fieldValue)
|
297
|
+
data.each { |k, v| event.set(k.to_s,v) } if data
|
298
|
+
rescue => e
|
299
|
+
sep = "\n"
|
300
|
+
puts "Error : #{e} data = #{data} backtrace=#{e.backtrace[0..2].join(sep)}"
|
301
|
+
@logger.error("SUMO> ", :pg => fieldValue, :exception => e)
|
302
|
+
end
|
265
303
|
end
|
266
304
|
end
|
267
|
-
end
|
268
305
|
|
269
306
|
|
270
|
-
|
271
|
-
|
307
|
+
# filter_matched should go in the last line of our successful code
|
308
|
+
rc = filter_matched(event)
|
309
|
+
|
310
|
+
rescue => e
|
311
|
+
puts "SUMO error #{e} #fieldvalue #{fieldValue} "
|
312
|
+
@logger.error("SUMO> ", :pg => fieldValue, :exception => e)
|
313
|
+
end
|
314
|
+
rc
|
272
315
|
end # def filter
|
273
316
|
|
274
317
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-filter-sumo'
|
3
|
-
s.version = '3.0.
|
3
|
+
s.version = '3.0.27'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "This filter extracts interessting SUMO values from the page element if present."
|
6
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"
|
@@ -20,8 +20,6 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
# Gem dependencies
|
22
22
|
s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
|
23
|
-
s.add_runtime_dependency 'redis'
|
24
|
-
s.add_development_dependency 'rspec', '~> 3.1'
|
25
23
|
s.add_development_dependency 'logstash-devutils'
|
26
|
-
|
24
|
+
s.add_development_dependency 'rspec', '~> 3.1'
|
27
25
|
end
|
data/spec/filters/sumo_spec.rb
CHANGED
@@ -39,6 +39,17 @@ describe LogStash::Filters::Sumo do
|
|
39
39
|
expect(subject.get('asset_id')).to eq(763009)
|
40
40
|
end
|
41
41
|
|
42
|
+
#
|
43
|
+
sample("page"=>"/origin2-od.akamai.tv2.no/ismusp/isi_mp4_0/2014-04-25/G018902sumo(809735_ISMUSP).ism/Manifest" ) do
|
44
|
+
insist { subject.get('path_type') } == 'ismusp'
|
45
|
+
|
46
|
+
expect(subject.get('dist_type')).to eq('vod')
|
47
|
+
expect(subject.get('video_type')).to eq('ism')
|
48
|
+
expect(subject.get('vtype')).to eq('manifest')
|
49
|
+
expect(subject.get('asset_id')).to eq(809735)
|
50
|
+
expect(subject.get('cache_key')).to eq("origin2-od.akamai.tv2.no")
|
51
|
+
|
52
|
+
end
|
42
53
|
end
|
43
54
|
|
44
55
|
describe "vod2" do
|
@@ -345,6 +356,19 @@ describe LogStash::Filters::Sumo do
|
|
345
356
|
end
|
346
357
|
|
347
358
|
|
359
|
+
end
|
360
|
+
|
361
|
+
describe "ISML url /origin1-live.akamai.tv2.no/live/727992.isml/Manifest" do
|
362
|
+
let(:config) do <<-CONFIG
|
363
|
+
filter {
|
364
|
+
sumo {
|
365
|
+
field => "pg"
|
366
|
+
}
|
367
|
+
}
|
368
|
+
CONFIG
|
369
|
+
end
|
370
|
+
|
371
|
+
|
348
372
|
# /origin1-live.akamai.tv2.no/live/727992.isml/Manifest
|
349
373
|
sample("pg"=>"/origin1-live.akamai.tv2.no/live/727992.isml/Manifest" ) do
|
350
374
|
insist { subject.get('path_type') } == 'live'
|
@@ -352,9 +376,39 @@ describe LogStash::Filters::Sumo do
|
|
352
376
|
expect(subject.get('video_type')).to eq('ism')
|
353
377
|
expect(subject.get('asset_id')).to eq(727992)
|
354
378
|
expect(subject.get('vtype')).to eq("manifest")
|
379
|
+
expect(subject.get('cache_key')).to eq("origin1-live.akamai.tv2.no")
|
355
380
|
end
|
356
381
|
|
382
|
+
# /origin1-live.akamai.tv2.no/live/727992.isml/Manifest
|
383
|
+
sample("pg"=>"/origin3-hlslive.akamai.tv2.no/out/u/1285463.ism/Manifest" ) do
|
384
|
+
insist { subject.get('path_type') } == 'elemental live'
|
385
|
+
expect(subject.get('dist_type')).to eq('live')
|
386
|
+
expect(subject.get('video_type')).to eq('ism')
|
387
|
+
expect(subject.get('asset_id')).to eq(1285463)
|
388
|
+
expect(subject.get('vtype')).to eq("manifest")
|
389
|
+
expect(subject.get('cache_key')).to eq("origin3-hlslive.akamai.tv2.no")
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
393
|
+
# /stagevod/_definst_/amlst:1212305_ps97070_pd3161140.smil.ism/Manifest
|
394
|
+
describe "ISML url /stagevod/_definst_/amlst:1212305_ps97070_pd3161140.smil.ism/Manifes" do
|
395
|
+
let(:config) do <<-CONFIG
|
396
|
+
filter {
|
397
|
+
sumo {
|
398
|
+
field => "pg"
|
399
|
+
}
|
400
|
+
}
|
401
|
+
CONFIG
|
402
|
+
end
|
403
|
+
|
404
|
+
sample("pg"=>" /stagevod/_definst_/amlst:1212305_ps97070_pd3161140.smil.ism/Manifest" ) do
|
405
|
+
insist { subject.get('path_type') } == 'ismvod'
|
406
|
+
expect(subject.get('dist_type')).to eq('vod')
|
407
|
+
expect(subject.get('video_type')).to eq('ism')
|
408
|
+
expect(subject.get('asset_id')).to eq(1212305)
|
409
|
+
expect(subject.get('vtype')).to eq("manifest")
|
410
|
+
end
|
357
411
|
|
358
412
|
end
|
359
413
|
|
360
|
-
end
|
414
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-sumo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TV 2
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-02-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -31,9 +31,9 @@ dependencies:
|
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
|
-
name:
|
34
|
+
name: logstash-devutils
|
35
35
|
prerelease: false
|
36
|
-
type: :
|
36
|
+
type: :development
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ">="
|
@@ -53,21 +53,9 @@ dependencies:
|
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '3.1'
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
name: logstash-devutils
|
63
|
-
prerelease: false
|
64
|
-
type: :development
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
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
|
56
|
+
description: This gem is a logstash plugin required to be installed on top of the
|
57
|
+
Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not
|
58
|
+
a stand-alone program
|
71
59
|
email: leffen@gmail.com
|
72
60
|
executables: []
|
73
61
|
extensions: []
|
@@ -104,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
92
|
version: '0'
|
105
93
|
requirements: []
|
106
94
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.6.
|
95
|
+
rubygems_version: 2.6.14
|
108
96
|
signing_key:
|
109
97
|
specification_version: 4
|
110
98
|
summary: This filter extracts interessting SUMO values from the page element if present.
|