logstash-filter-google_appengine 0.10.0 → 0.20.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: e1b96291088f900e14df382bc7129fe213a8afc9
4
- data.tar.gz: 326f38a243387ed4cd3cafbe2c467ef3f2a6d121
3
+ metadata.gz: 577b86574c1d0bb8d3f8eae10c88b57cc7314b1c
4
+ data.tar.gz: 8ccf5230a7fa21e4255b2fca765e6f224d9475c3
5
5
  SHA512:
6
- metadata.gz: 81471cd56ff64740ecdffaf60b4e449a6619d5152e84851236166d30a210bee2e79c3685a1a38a491b417bf2972f79dbf7fcfd959d6d92da674f657aeb018342
7
- data.tar.gz: c68cea84c050ec9c3fb0534451a57e8d259b1ca26cdc36ceca96e04dd0c9e0c9fe48dbac81b6d1b1c5dbb8afb514993f66921bd5ce659298777d5e9933fa0550
6
+ metadata.gz: 7d83ed9a6456a4401ab379b9854c1a22d113eb4853682c2760e93864586d96b0857a6e14478e56c28a1be4eea6aa3c14ba9d40f4e8a1876ae9a64064fb5d7184
7
+ data.tar.gz: 95428d179177159334903fcd033a2dbf2d1eed033bf927a1504ddf791cbf7992443a6e13cb933414cc586f4d0631c4acab6fd667e63733058f17595581d1bb8e
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012–2015 Elasticsearch <http://www.elastic.co>
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # Logstash Plugin
2
+
3
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
4
+
5
+ It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
6
+
7
+ ## Documentation
8
+
9
+ Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
10
+
11
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
12
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
13
+
14
+ ## Need Help?
15
+
16
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
17
+
18
+ ## Developing
19
+
20
+ ### 1. Plugin Developement and Testing
21
+
22
+ #### Code
23
+ - To get started, you'll need JRuby with the Bundler gem installed.
24
+
25
+ - 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).
26
+
27
+ - Install dependencies
28
+ ```sh
29
+ bundle install
30
+ ```
31
+
32
+ #### Test
33
+
34
+ - Update your dependencies
35
+
36
+ ```sh
37
+ bundle install
38
+ ```
39
+
40
+ - Run tests
41
+
42
+ ```sh
43
+ bundle exec rspec
44
+ ```
45
+
46
+ ### 2. Running your unpublished Plugin in Logstash
47
+
48
+ #### 2.1 Run in a local Logstash clone
49
+
50
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
51
+ ```ruby
52
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
53
+ ```
54
+ - Install plugin
55
+ ```sh
56
+ bin/plugin install --no-verify
57
+ ```
58
+ - Run Logstash with your plugin
59
+ ```sh
60
+ bin/logstash -e 'filter {awesome {}}'
61
+ ```
62
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
63
+
64
+ #### 2.2 Run in an installed Logstash
65
+
66
+ 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:
67
+
68
+ - Build your plugin gem
69
+ ```sh
70
+ gem build logstash-filter-awesome.gemspec
71
+ ```
72
+ - Install the plugin from the Logstash home
73
+ ```sh
74
+ bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
75
+ ```
76
+ - Start Logstash and proceed to test the plugin
77
+
78
+ ## Contributing
79
+
80
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
81
+
82
+ 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.
83
+
84
+ It is more important to the community that you are able to contribute.
85
+
86
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ @files=[]
2
+
3
+ task :default do
4
+ system("rake -T")
5
+ end
6
+
7
+ require "logstash/devutils/rake"
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+ require "logstash/filters/base"
3
+ require "logstash/namespace"
4
+ require "logstash/environment"
5
+ require 'digest'
6
+
7
+ class LogStash::Filters::GoogleAppengine < LogStash::Filters::Base
8
+
9
+ config_name "google_appengine"
10
+
11
+ public
12
+ def register
13
+ @md5 = Digest::MD5.new
14
+ end
15
+
16
+ def filter(event)
17
+ begin
18
+ payload = event['protoPayload']
19
+ payload.delete '@type'
20
+ lines = payload.delete 'line'
21
+ if lines
22
+ lines.map.with_index { |line, i|
23
+ line_data = payload.merge line
24
+ line_data['_id'] = @md5.hexdigest line_data['requestId'] + i.to_s
25
+ line_data['message'] = line_data.delete 'logMessage'
26
+
27
+ new_event = LogStash::Event::new(line_data)
28
+ filter_matched(new_event)
29
+ yield new_event
30
+ }
31
+ else
32
+ payload['_id'] = @md5.hexdigest payload['requestId']
33
+ payload['time'] = payload['endTime']
34
+
35
+ new_event = LogStash::Event::new(payload)
36
+ filter_matched(new_event)
37
+ yield new_event
38
+ end
39
+ event.cancel
40
+ rescue => e
41
+ @logger.error "Failed to process event", :error => e, :data => event
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,23 @@
1
+ Gem::Specification.new do |s|
2
+
3
+ s.name = 'logstash-filter-google_appengine'
4
+ s.version = '0.20.0'
5
+ s.licenses = ['Apache License (2.0)']
6
+ s.summary = "This filter may be used to decode via inputs appengine logs"
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"
8
+ s.authors = ["Small Improvements"]
9
+ s.email = 'mruhwedel@small-improvements.com'
10
+ s.homepage = "https://github.com/MichaelRuhwedel/logstash-filter-google-appengine"
11
+ s.require_paths = ["lib"]
12
+
13
+ s.files = `git ls-files`.split($\)
14
+
15
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
16
+
17
+ s.metadata = {"logstash_plugin" => "true", "logstash_group" => "filter"}
18
+
19
+ s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
20
+
21
+ s.add_development_dependency 'logstash-devutils'
22
+ end
23
+
@@ -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}}
@@ -0,0 +1 @@
1
+ {"metadata":{"severity":"INFO","serviceName":"appengine.googleapis.com","zone":"us9","labels":{"appengine.googleapis.com/clone_id":"00c61b117cf5a23b1278e3feeb2520a35bb82f","appengine.googleapis.com/module_id":"default","appengine.googleapis.com/request_id":"55e8281c00ff08ebd0149c00ffc30001737e73686f7070696e672d67616d652d68726400013100010101","appengine.googleapis.com/version_id":"1"},"timestamp":"2015-09-03T10:59:40.584656Z"},"protoPayload":{"@type":"type.googleapis.com/google.appengine.logging.v1.RequestLog","appId":"s~shopping-game-hrd","versionId":"1","requestId":"NTVlODI4MWMwMGZmMDhlYmQwMTQ5YzAwZmZjMzAwMDE3MzdlNzM2ODZmNzA3MDY5NmU2NzJkNjc2MTZkNjUyZDY4NzI2NDAwMDEzMTAwMDEwMTAx","ip":"0.1.0.2","startTime":"2015-09-03T10:59:40.584656Z","endTime":"2015-09-03T10:59:40.700408Z","latency":"0.115752s","megaCycles":"57","method":"POST","resource":"/admin/tasks/executeThrottledTasks","httpVersion":"HTTP/1.1","status":200,"responseSize":"933","referrer":"http://shopping-game-hrd.appspot.com/admin/tasks/executeThrottledTasks/master/true","userAgent":"AppEngine-Google; (+http://code.google.com/appengine)","urlMapEntry":"unused","host":"shopping-game-hrd.appspot.com","cost":1.0426999999999999e-07,"taskQueueName":"throttledtasks","taskName":"0366082792844325968","instanceIndex":-1,"instanceId":"MDBjNjFiMTE3Y2Y1YTIzYjEyNzhlM2ZlZWIyNTIwYTM1YmI4MmY=","line":[{"time":"2015-09-03T10:59:40.589Z","severity":"INFO","logMessage":"IdentityFilter logUserIdentity: [[meta]] <anonymous:true>\n"},{"time":"2015-09-03T10:59:40.65Z","severity":"INFO","logMessage":"HttpOnlyFilter getSession: add additional Set-Cookie with httpOnly-flag for JSESSIONID\n"},{"time":"2015-09-03T10:59:40.652Z","severity":"INFO","logMessage":"SessionSafeAccessor reset: clearing the session safe\n"}],"appEngineRelease":"1.9.25","traceId":"17e8867d8b819bc7eb2fc2d26e006462"},"insertId":"2015-09-03|03:59:45.683978-07|10.106.187.131|33909730","log":"appengine.googleapis.com/request_log","httpRequest":{"status":200}}
@@ -0,0 +1,51 @@
1
+ require "logstash/devutils/rspec/spec_helper"
2
+ require "logstash/filters/google_appengine"
3
+ require "logstash/json"
4
+ require 'digest'
5
+
6
+ describe LogStash::Filters::GoogleAppengine do
7
+
8
+ md5 = Digest::MD5.new
9
+
10
+ describe "should merge the request payload with the reuest lines data" do
11
+ config <<-CONFIG
12
+ filter {
13
+ google_appengine { }
14
+ }
15
+ CONFIG
16
+
17
+ test_sample = LogStash::Json::load(File.open("spec/filters/appengine.logs.jsonl", "rb").read)
18
+ sample (test_sample) do
19
+ insist { subject.length } == 3
20
+
21
+ insist { subject[0]["message"] }=="IdentityFilter logUserIdentity: [[meta]] <anonymous:true>\n"
22
+ insist { subject[0]["_id"] }== md5.hexdigest(subject[0]["requestId"] + "0")
23
+ insist { subject[0]["time"] } == "2015-09-03T10:59:40.589Z"
24
+
25
+ insist { subject[0]["@type"] } == nil
26
+
27
+ insist { subject[1]["message"] }=="HttpOnlyFilter getSession: add additional Set-Cookie with httpOnly-flag for JSESSIONID\n"
28
+ insist { subject[1]["_id"] } == md5.hexdigest(subject[1]["requestId"] + "1")
29
+ insist { subject[1]["@type"] } == nil
30
+ insist { subject[1]["time"] } =="2015-09-03T10:59:40.65Z"
31
+ end
32
+ end
33
+
34
+ describe "should handle logs even when they have no lines" do
35
+ config <<-CONFIG
36
+ filter {
37
+ google_appengine { }
38
+ }
39
+ CONFIG
40
+ test_sample = LogStash::Json.load(File.open("spec/filters/appengine.logs-without-lines.jsonl", "rb").read)
41
+ sample (test_sample) do
42
+
43
+ insist { subject["resource"] }=="/images/website/welcome/keyFeatures/objectives.jpg"
44
+ insist { subject["_id"] }==md5.hexdigest(subject["requestId"])
45
+ insist { subject["time"] }==subject["endTime"]
46
+ insist { subject["@type"] } == nil
47
+ end
48
+ end
49
+ end
50
+
51
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-google_appengine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Small Improvements
@@ -49,7 +49,16 @@ email: mruhwedel@small-improvements.com
49
49
  executables: []
50
50
  extensions: []
51
51
  extra_rdoc_files: []
52
- files: []
52
+ files:
53
+ - Gemfile
54
+ - LICENSE
55
+ - README.md
56
+ - Rakefile
57
+ - lib/logstash/filters/google_appengine.rb
58
+ - logstash-filter-google_appengine.gemspec
59
+ - spec/filters/appengine.logs-without-lines.jsonl
60
+ - spec/filters/appengine.logs.jsonl
61
+ - spec/filters/google_appengine_spec.rb
53
62
  homepage: https://github.com/MichaelRuhwedel/logstash-filter-google-appengine
54
63
  licenses:
55
64
  - Apache License (2.0)
@@ -76,4 +85,7 @@ rubygems_version: 2.4.8
76
85
  signing_key:
77
86
  specification_version: 4
78
87
  summary: This filter may be used to decode via inputs appengine logs
79
- test_files: []
88
+ test_files:
89
+ - spec/filters/appengine.logs-without-lines.jsonl
90
+ - spec/filters/appengine.logs.jsonl
91
+ - spec/filters/google_appengine_spec.rb