logstash-codec-google_appengine 1.4.0 → 1.7.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: f5fb3af88d07784e2036635333aab73f34b06777
4
- data.tar.gz: 9327c06b5e466c1bd53f12fc160b239c71559a38
3
+ metadata.gz: 6db4c3cf8aa0ba60ea6f2f5bb4245b53d1e92844
4
+ data.tar.gz: 3bea6324986e9c18fe6e37f14d7ea45846d6b849
5
5
  SHA512:
6
- metadata.gz: 652a4759ceb5d12bd694a7fdeadf38d1e9a6d2ad4d3f31504d259b166cc31e98758d592a64a09c2cba1dbb1b028964c5538918530b08742ebbb9c232328aea65
7
- data.tar.gz: 902b7ed73f9f26cc8bff117cf8f1504f37e63b421a010c6bc1409d7218adc8948303c6269afd2113d9624ed3e00d68e2a995c409a941ecfd038a9c175d6e2efb
6
+ metadata.gz: e106b9a96bf7f6c603a6dccc9f5c2b318834a6dadb17285c7274cbd58fa49577abca97641bb89fc8a483c8db1fcc31719779c6157b1df8e6a1a1ae70ad5b7ff2
7
+ data.tar.gz: 0522f90a6f35d125889e9b7f3174092b5110a31ae931a7dff19735ff99dd04e2488a95a57d36d2c6f0931ba3a128dabc0daf408b878cced269d1e97d0b99b358
@@ -2,6 +2,7 @@
2
2
  require "logstash/codecs/base"
3
3
  require "logstash/namespace"
4
4
  require "logstash/codecs/json"
5
+ require 'securerandom'
5
6
 
6
7
  class LogStash::Codecs::GoogleAppengine < LogStash::Codecs::Base
7
8
  config_name "google_appengine"
@@ -16,8 +17,9 @@ class LogStash::Codecs::GoogleAppengine < LogStash::Codecs::Base
16
17
  begin
17
18
  @json.decode(data) do |json|
18
19
  if is_parse_failure(json)
19
- return yield json
20
+ return @logger.error("Failed to process data", :data => json)
20
21
  end
22
+
21
23
  flatten(json).each { |flattenedJson|
22
24
  yield LogStash::Event.new(flattenedJson)
23
25
  }
@@ -37,11 +39,17 @@ end
37
39
  def flatten(event)
38
40
  payload = event['protoPayload']
39
41
  lines = payload['line']
42
+ payload.delete('@type')
40
43
  if lines
41
44
  payload.delete('line')
42
- lines.map { |line| payload.merge(line) }
45
+ lines.map.with_index { |line, i|
46
+ merged = payload.merge(line)
47
+ merged['lineId'] = merged['requestId'] + i.to_s
48
+ merged
49
+ }
43
50
  else
44
51
  payload['time'] = payload['endTime']
52
+ payload['lineId'] = payload['requestId']
45
53
  [payload]
46
54
  end
47
55
  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.4.0'
4
+ s.version = '1.7.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"
@@ -20,6 +20,5 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.add_development_dependency 'logstash-devutils'
22
22
  s.add_development_dependency 'logstash-codec-json'
23
- #s.add_development_dependency 'logstash-codec-json_lines'
24
23
  end
25
24
 
@@ -30,11 +30,11 @@ context "#decode" do
30
30
 
31
31
  expect(collector.size).to eq(3)
32
32
 
33
- expect(collector[0]["@type"]).to eq("type.googleapis.com/google.appengine.logging.v1.RequestLog")
34
33
  expect(collector[0]["logMessage"]).to eq("IdentityFilter logUserIdentity: [[meta]] <anonymous:true>\n")
34
+ expect(collector[0]["lineId"]).to eq(collector[0]["requestId"] + "0")
35
35
 
36
- expect(collector[1]["@type"]).to eq("type.googleapis.com/google.appengine.logging.v1.RequestLog")
37
36
  expect(collector[1]["logMessage"]).to eq("HttpOnlyFilter getSession: add additional Set-Cookie with httpOnly-flag for JSESSIONID\n")
37
+ expect(collector[1]["lineId"]).to eq(collector[1]["requestId"] + "1")
38
38
  end
39
39
 
40
40
  it "should handle logs even when they have no lines" do
@@ -49,19 +49,17 @@ context "#decode" do
49
49
 
50
50
  expect(collector.size).to eq(1)
51
51
 
52
- expect(collector[0]["@type"]).to eq("type.googleapis.com/google.appengine.logging.v1.RequestLog")
53
52
  expect(collector[0]["resource"]).to eq("/images/website/welcome/keyFeatures/objectives.jpg")
53
+ expect(collector[0]["lineId"]).to eq(collector[0]["requestId"])
54
+ expect(collector[0]["time"]).to eq(collector[0]["endTime"])
54
55
  end
55
56
 
56
- it "falls back to plain text" do
57
+ it "falls not emit an event when it can't be parsed" do
57
58
  decoded = false
58
59
  subject.decode("something that isn't json") do |event|
59
60
  decoded = true
60
- insist { event.is_a? LogStash::Event }
61
- insist { event["message"] } == "something that isn't json"
62
- insist { event["tags"] }.include?("_jsonparsefailure")
63
61
  end
64
- insist { decoded } == true
62
+ insist { decoded } == false
65
63
  end
66
64
  end
67
65
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-codec-google_appengine
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Small Improvements
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-07 00:00:00.000000000 Z
11
+ date: 2015-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-core