logstash-codec-google_appengine 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4c728ea2fafe715079ed06e61bad3fc2e6e63987
4
+ data.tar.gz: f1dda6b6e77e03a5f186ff288751b48d7005e557
5
+ SHA512:
6
+ metadata.gz: af0e9cd5baf6d2b5a6bd7cf6fd404359cf54c1bf3fa33b7477c76d88e70a94c84b7f9b82e29adaba1af239a8eb937c18a637d27e7a55bb7b749074834fccb7b6
7
+ data.tar.gz: 407974819b0e81ccd7e0d8284eccfb466bdf6dc288a20dc13bcc0ea31b2c0de9d7920bff1b2676c52b4e1df4c179b913cdb55350af83474dbc51646f435c364b
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
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"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "logstash/codec/google/appengine"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+ require "logstash/codecs/base"
3
+ require "logstash/namespace"
4
+ require "logstash/codecs/json"
5
+
6
+ class LogStash::Codecs::GoogleAppengine < LogStash::Codecs::Base
7
+ config_name "google_appengine"
8
+
9
+ public
10
+
11
+ def register
12
+ @json = LogStash::Codecs::JSON.new
13
+ end
14
+
15
+ def decode(data)
16
+ @json.decode(data) do |json|
17
+ if is_parse_failure(json)
18
+ return yield json
19
+ end
20
+ flatten(json).each { |flattenedJson|
21
+ yield LogStash::Event.new(flattenedJson)
22
+ }
23
+ end
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def is_parse_failure(event)
30
+ event["tags"] && event["tags"].include?("_jsonparsefailure")
31
+ end
32
+
33
+ def flatten(event)
34
+ payload = event['protoPayload']
35
+ lines = payload['line']
36
+ payload.delete('line')
37
+ lines.map { |line| payload.merge(line) }
38
+ end
@@ -0,0 +1,52 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="FacetManager">
4
+ <facet type="gem" name="Ruby Gem">
5
+ <configuration>
6
+ <option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
7
+ <option name="GEM_APP_TEST_PATH" value="$MODULE_DIR$/test" />
8
+ <option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
9
+ </configuration>
10
+ </facet>
11
+ </component>
12
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
13
+ <exclude-output />
14
+ <content url="file://$MODULE_DIR$">
15
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
16
+ <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
17
+ </content>
18
+ <orderEntry type="jdk" jdkName="jruby-9.0.1.0-p0" jdkType="JRUBY_SDK" />
19
+ <orderEntry type="sourceFolder" forTests="false" />
20
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.10.6, jruby-9.0.1.0-p0) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="cabin (v0.7.1, jruby-9.0.1.0-p0) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="clamp (v0.6.5, jruby-9.0.1.0-p0) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="coderay (v1.1.0, jruby-9.0.1.0-p0) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, jruby-9.0.1.0-p0) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="ffi (v1.9.10, jruby-9.0.1.0-p0) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="filesize (v0.0.4, jruby-9.0.1.0-p0) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="gem_publisher (v1.5.0, jruby-9.0.1.0-p0) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="gems (v0.8.3, jruby-9.0.1.0-p0) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="i18n (v0.6.9, jruby-9.0.1.0-p0) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="insist (v1.0.0, jruby-9.0.1.0-p0) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="jrjackson (v0.2.9, jruby-9.0.1.0-p0) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="kramdown (v1.8.0, jruby-9.0.1.0-p0) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="logstash-codec-json (v1.0.1, jruby-9.0.1.0-p0) [gem]" level="application" />
34
+ <orderEntry type="library" scope="PROVIDED" name="logstash-core (v1.5.4, jruby-9.0.1.0-p0) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="logstash-devutils (v0.0.15, jruby-9.0.1.0-p0) [gem]" level="application" />
36
+ <orderEntry type="library" scope="PROVIDED" name="method_source (v0.8.2, jruby-9.0.1.0-p0) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="minitar (v0.5.4, jruby-9.0.1.0-p0) [gem]" level="application" />
38
+ <orderEntry type="library" scope="PROVIDED" name="polyglot (v0.3.5, jruby-9.0.1.0-p0) [gem]" level="application" />
39
+ <orderEntry type="library" scope="PROVIDED" name="pry (v0.10.1, jruby-9.0.1.0-p0) [gem]" level="application" />
40
+ <orderEntry type="library" scope="PROVIDED" name="rake (v10.4.2, jruby-9.0.1.0-p0) [gem]" level="application" />
41
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.1.0, jruby-9.0.1.0-p0) [gem]" level="application" />
42
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.1.7, jruby-9.0.1.0-p0) [gem]" level="application" />
43
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.1.2, jruby-9.0.1.0-p0) [gem]" level="application" />
44
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.1.3, jruby-9.0.1.0-p0) [gem]" level="application" />
45
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.1.2, jruby-9.0.1.0-p0) [gem]" level="application" />
46
+ <orderEntry type="library" scope="PROVIDED" name="slop (v3.6.0, jruby-9.0.1.0-p0) [gem]" level="application" />
47
+ <orderEntry type="library" scope="PROVIDED" name="spoon (v0.0.4, jruby-9.0.1.0-p0) [gem]" level="application" />
48
+ <orderEntry type="library" scope="PROVIDED" name="stud (v0.0.21, jruby-9.0.1.0-p0) [gem]" level="application" />
49
+ <orderEntry type="library" scope="PROVIDED" name="thread_safe (v0.3.5, jruby-9.0.1.0-p0) [gem]" level="application" />
50
+ <orderEntry type="library" scope="PROVIDED" name="treetop (v1.4.15, jruby-9.0.1.0-p0) [gem]" level="application" />
51
+ </component>
52
+ </module>
@@ -0,0 +1,25 @@
1
+ Gem::Specification.new do |s|
2
+
3
+ s.name = 'logstash-codec-google_appengine'
4
+ s.version = '1.1.0'
5
+ s.licenses = ['Apache License (2.0)']
6
+ s.summary = "This codec 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-codec-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" => "codec"}
18
+
19
+ s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
20
+
21
+ s.add_development_dependency 'logstash-devutils'
22
+ s.add_development_dependency 'logstash-codec-json'
23
+ #s.add_development_dependency 'logstash-codec-json_lines'
24
+ end
25
+
@@ -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,48 @@
1
+ require "logstash/devutils/rspec/spec_helper"
2
+ require "logstash/codecs/google_appengine"
3
+ require "logstash/event"
4
+ require "logstash/json"
5
+ require "insist"
6
+
7
+ describe LogStash::Codecs::GoogleAppengine do
8
+ subject do
9
+ next LogStash::Codecs::GoogleAppengine.new
10
+ end
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
20
+ end
21
+
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
27
+
28
+ expect(collector.size).to eq(3)
29
+
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")
32
+
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")
35
+ end
36
+ end
37
+
38
+ it "falls back to plain text" do
39
+ decoded = false
40
+ subject.decode("something that isn't json") do |event|
41
+ decoded = true
42
+ insist { event.is_a? LogStash::Event }
43
+ insist { event["message"] } == "something that isn't json"
44
+ insist { event["tags"] }.include?("_jsonparsefailure")
45
+ end
46
+ insist { decoded } == true
47
+ end
48
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-codec-google_appengine
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Small Improvements
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: logstash-core
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.4.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 2.0.0
23
+ requirement: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: 1.4.0
28
+ - - "<"
29
+ - !ruby/object:Gem::Version
30
+ version: 2.0.0
31
+ prerelease: false
32
+ type: :runtime
33
+ - !ruby/object:Gem::Dependency
34
+ name: logstash-devutils
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirement: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ prerelease: false
46
+ type: :development
47
+ - !ruby/object:Gem::Dependency
48
+ name: logstash-codec-json
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirement: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ prerelease: false
60
+ type: :development
61
+ 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
62
+ email: mruhwedel@small-improvements.com
63
+ executables: []
64
+ extensions: []
65
+ extra_rdoc_files: []
66
+ files:
67
+ - ".gitignore"
68
+ - Gemfile
69
+ - LICENSE
70
+ - README.md
71
+ - Rakefile
72
+ - bin/console
73
+ - bin/setup
74
+ - lib/logstash/codecs/google_appengine.rb
75
+ - logstash-codec-google-appengine.iml
76
+ - logstash-codec-google_appengine.gemspec
77
+ - spec/codecs/appengine.logs.jsonl
78
+ - spec/codecs/google_appengine_spec.rb
79
+ homepage: https://github.com/MichaelRuhwedel/logstash-codec-google-appengine
80
+ licenses:
81
+ - Apache License (2.0)
82
+ metadata:
83
+ logstash_plugin: 'true'
84
+ logstash_group: codec
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.4.8
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: This codec may be used to decode via inputs appengine logs
105
+ test_files:
106
+ - spec/codecs/appengine.logs.jsonl
107
+ - spec/codecs/google_appengine_spec.rb