logstash-codec-google_appengine 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ea3583c470ffc16060fd747cd7356cf06409623
4
- data.tar.gz: deb063973fa616655f86a96f02d5300f037dca15
3
+ metadata.gz: 65a25d37344d2d857ced131dfbca80891278dd78
4
+ data.tar.gz: 7b0c1042da8f3905e01f7743cc1868b1c1e4bbcb
5
5
  SHA512:
6
- metadata.gz: 23b6dadcb11cdb0e6114f5bde7f871e2893b4018f540e58f727c3bd8af852c27407cc9d11b115ca6b84d67e55a9de01bae0d2782762a45edc2d72b1f7a85e4c5
7
- data.tar.gz: 3c5eb1ca67af2bd978d695b98cfd8d6ed33627f96ddde6387feec451eb5a47ca1db1a0a32809d04ca0d61905a03af998ff3e1e2506abd5ca8bebbb1e1f8e445f
6
+ metadata.gz: 70f2f14571103eb44329f903f97b9e2e1483ecbca36954505b7b384f3f7ca04483ee7d1ca5b5208cb982390686b1ede49ff9f0f84010dc84894fbfbfcf3d73ac
7
+ data.tar.gz: 19308f459a967b1d2f7630f8b8f3ad6c633626e519384a969894b08da7991bc6422074d361412a332edac98da981c1662881dab78059ebfb4412674be474f3db
@@ -22,14 +22,13 @@ class LogStash::Codecs::GoogleAppengine < LogStash::Codecs::Base
22
22
  yield LogStash::Event.new(flattenedJson)
23
23
  }
24
24
  end
25
- rescue => e
26
- @logger.info("Failed to process data", :error => e, :data => data)
27
- yield LogStash::Event.new("message" => data, "tags" => ["_googleappengineparsefailure"])
25
+ rescue => e
26
+ @logger.info("Failed to process data", :error => e, :data => data)
27
+ yield LogStash::Event.new("message" => data, "tags" => ["_googleappengineparsefailure"])
28
28
  end
29
29
  end
30
30
  end
31
31
 
32
-
33
32
  private
34
33
 
35
34
  def is_parse_failure(event)
@@ -39,6 +38,10 @@ end
39
38
  def flatten(event)
40
39
  payload = event['protoPayload']
41
40
  lines = payload['line']
42
- payload.delete('line')
43
- lines.map { |line| payload.merge(line) }
41
+ if lines
42
+ payload.delete('line')
43
+ lines.map { |line| payload.merge(line) }
44
+ else
45
+ [payload]
46
+ end
44
47
  end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-codec-google_appengine'
4
- s.version = '1.2.0'
4
+ s.version = '1.3.0'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "This codec may be used to decode via inputs appengine logs"
7
7
  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"
@@ -0,0 +1 @@
1
+ {"metadata":{"serviceName":"appengine.googleapis.com","zone":"us9","labels":{"appengine.googleapis.com/module_id":"default","appengine.googleapis.com/request_id":"55e80a9c00ff096e0f91589f3f0001737e73686f7070696e672d67616d652d68726400013100010103","appengine.googleapis.com/version_id":"1"},"timestamp":"2015-09-03T08:53:48.617999Z"},"protoPayload":{"@type":"type.googleapis.com/google.appengine.logging.v1.RequestLog","appId":"s~shopping-game-hrd","versionId":"1","requestId":"NTVlODBhOWMwMGZmMDk2ZTBmOTE1ODlmM2YwMDAxNzM3ZTczNjg2ZjcwNzA2OTZlNjcyZDY3NjE2ZDY1MmQ2ODcyNjQwMDAxMzEwMDAxMDEwMw==","ip":"78.55.216.42","startTime":"2015-09-03T08:53:48.617999Z","endTime":"2015-09-03T08:53:48.671351Z","latency":"0.053352s","method":"GET","resource":"/images/website/welcome/keyFeatures/objectives.jpg","httpVersion":"HTTP/1.1","status":200,"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2439.0 Safari/537.36","host":"shopping-game.small-improvements.com","instanceIndex":-1,"appEngineRelease":"1.9.25"},"insertId":"2015-09-03|01:53:50.387721-07|10.106.166.136|1292431933","log":"appengine.googleapis.com/request_log","httpRequest":{"status":200}}
@@ -9,30 +9,48 @@ describe LogStash::Codecs::GoogleAppengine do
9
9
  next LogStash::Codecs::GoogleAppengine.new
10
10
  end
11
11
 
12
- data = File.open("spec/codecs/appengine.logs.jsonl", "rb").read
13
-
14
- context "#decode" do
15
- it "should return an event from json data" do
16
- subject.decode(data) do |event|
17
- insist { event.is_a? LogStash::Event }
18
- insist { event["@type"] } == "type.googleapis.com/google.appengine.logging.v1.RequestLog"
19
- end
12
+
13
+
14
+ context "#decode" do
15
+
16
+ it "should return an event from json data" do
17
+ data = File.open("spec/codecs/appengine.logs.jsonl", "rb").read
18
+ subject.decode(data) do |event|
19
+ insist { event.is_a? LogStash::Event }
20
+ insist { event["@type"] } == "type.googleapis.com/google.appengine.logging.v1.RequestLog"
20
21
  end
22
+ end
23
+
24
+ it "should merge the request payload with the reuest lines data" do
25
+ data = File.open("spec/codecs/appengine.logs.jsonl", "rb").read
26
+ collector = Array.new
27
+ subject.decode(data) do |event|
28
+ collector.push(event)
29
+ end
30
+
31
+ expect(collector.size).to eq(3)
21
32
 
22
- it "should merge the request payload with the reuest lines data" do
23
- collector = Array.new
24
- subject.decode(data) do |event|
25
- collector.push(event)
26
- end
33
+ expect(collector[0]["@type"]).to eq("type.googleapis.com/google.appengine.logging.v1.RequestLog")
34
+ expect(collector[0]["logMessage"]).to eq("IdentityFilter logUserIdentity: [[meta]] <anonymous:true>\n")
27
35
 
28
- expect(collector.size).to eq(3)
36
+ expect(collector[1]["@type"]).to eq("type.googleapis.com/google.appengine.logging.v1.RequestLog")
37
+ expect(collector[1]["logMessage"]).to eq("HttpOnlyFilter getSession: add additional Set-Cookie with httpOnly-flag for JSESSIONID\n")
38
+ end
39
+
40
+ it "should handle logs even when they have no lines" do
29
41
 
30
- expect(collector[0]["@type"]).to eq("type.googleapis.com/google.appengine.logging.v1.RequestLog")
31
- expect(collector[0]["logMessage"]).to eq("IdentityFilter logUserIdentity: [[meta]] <anonymous:true>\n")
42
+ data = File.open("spec/codecs/appengine.logs-without-lines.jsonl", "rb").read
32
43
 
33
- expect(collector[1]["@type"]).to eq("type.googleapis.com/google.appengine.logging.v1.RequestLog")
34
- expect(collector[1]["logMessage"]).to eq("HttpOnlyFilter getSession: add additional Set-Cookie with httpOnly-flag for JSESSIONID\n")
44
+ collector = Array.new
45
+
46
+ subject.decode(data) do |event|
47
+ collector.push(event)
35
48
  end
49
+
50
+ expect(collector.size).to eq(1)
51
+
52
+ expect(collector[0]["@type"]).to eq("type.googleapis.com/google.appengine.logging.v1.RequestLog")
53
+ expect(collector[0]["resource"]).to eq("/images/website/welcome/keyFeatures/objectives.jpg")
36
54
  end
37
55
 
38
56
  it "falls back to plain text" do
@@ -46,3 +64,6 @@ describe LogStash::Codecs::GoogleAppengine do
46
64
  insist { decoded } == true
47
65
  end
48
66
  end
67
+
68
+
69
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-codec-google_appengine
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Small Improvements
@@ -74,6 +74,7 @@ files:
74
74
  - lib/logstash/codecs/google_appengine.rb
75
75
  - logstash-codec-google-appengine.iml
76
76
  - logstash-codec-google_appengine.gemspec
77
+ - spec/codecs/appengine.logs-without-lines.jsonl
77
78
  - spec/codecs/appengine.logs.jsonl
78
79
  - spec/codecs/google_appengine_spec.rb
79
80
  homepage: https://github.com/MichaelRuhwedel/logstash-codec-google-appengine
@@ -103,5 +104,6 @@ signing_key:
103
104
  specification_version: 4
104
105
  summary: This codec may be used to decode via inputs appengine logs
105
106
  test_files:
107
+ - spec/codecs/appengine.logs-without-lines.jsonl
106
108
  - spec/codecs/appengine.logs.jsonl
107
109
  - spec/codecs/google_appengine_spec.rb