logstash-output-seq 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +7 -0
- data/CONTRIBUTORS +10 -0
- data/DEVELOPER.md +2 -0
- data/Gemfile +2 -0
- data/LICENSE +22 -0
- data/README.md +92 -0
- data/lib/logstash/outputs/seq.rb +144 -0
- data/logstash-output-seq.gemspec +28 -0
- data/spec/outputs/seq_spec.rb +238 -0
- metadata +151 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3aef33aac0f8557023bcbed88315a492e7438384
|
4
|
+
data.tar.gz: 8284cb19c116ec0efec0564c1b726306233b04e4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4989e95c4ffc91f244dbaa84c099ea738ae3274a4c6690e5131c33f02e44e4090c8b01efccb2ee9f2e62fbef9f3c3a46bb8f3cffcc38210cca05e815d6b0c93f
|
7
|
+
data.tar.gz: 40ceb7fdb6cd09696e0eb311105e8197f7a15f37f9bf07b2a5a45299214060fc396943c9dc5156c0da0b728cc3302d90ee8b43838b3a9279e3aa3d0b88771dba
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
## 2.0.1
|
2
|
+
- Add encoding: utf-8 to spec files. This can help prevent issues during testing.
|
3
|
+
## 2.0.0
|
4
|
+
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
5
|
+
instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
|
6
|
+
- Dependency on logstash-core update to 2.0
|
7
|
+
|
data/CONTRIBUTORS
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
The following is a list of people who have contributed ideas, code, bug
|
2
|
+
reports, or in general have helped the Seq plugin for Logstash along its way.
|
3
|
+
|
4
|
+
Contributors:
|
5
|
+
* Adam Friedman (tintoy)
|
6
|
+
|
7
|
+
Note: If you've sent us patches, bug reports, or otherwise contributed to
|
8
|
+
Logstash, and you aren't on the list above and want to be, please let us know
|
9
|
+
and we'll make sure you're here. Contributions from folks like you are what make
|
10
|
+
open source awesome.
|
data/DEVELOPER.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 tin oscillator
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# Seq Logstash Plugin
|
2
|
+
|
3
|
+
[![Travis Build Status](https://travis-ci.org/tintoy/logstash-output-seq.svg)](https://travis-ci.org/tintoy/logstash-output-seq)
|
4
|
+
|
5
|
+
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
6
|
+
|
7
|
+
It is fully free and fully open source. The license is MIT, meaning you are pretty much free to use it however you want in whatever way.
|
8
|
+
|
9
|
+
Note that this plugin is just a skeleton for now; this documentation will be updated as work progresses.
|
10
|
+
|
11
|
+
## Documentation
|
12
|
+
|
13
|
+
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/).
|
14
|
+
|
15
|
+
- For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
|
16
|
+
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
|
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-output-seq", :path => "/your/local/logstash-output-seq"
|
53
|
+
```
|
54
|
+
- Install plugin
|
55
|
+
```sh
|
56
|
+
# Logstash 2.3 and higher
|
57
|
+
bin/logstash-plugin install --no-verify
|
58
|
+
|
59
|
+
# Prior to Logstash 2.3
|
60
|
+
bin/plugin install --no-verify
|
61
|
+
|
62
|
+
```
|
63
|
+
- Run Logstash with your plugin
|
64
|
+
```sh
|
65
|
+
bin/logstash -e 'output {seq {}}'
|
66
|
+
```
|
67
|
+
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
|
68
|
+
|
69
|
+
#### 2.2 Run in an installed Logstash
|
70
|
+
|
71
|
+
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:
|
72
|
+
|
73
|
+
- Build your plugin gem
|
74
|
+
```sh
|
75
|
+
gem build logstash-output-seq.gemspec
|
76
|
+
```
|
77
|
+
- Install the plugin from the Logstash home
|
78
|
+
```sh
|
79
|
+
# Logstash 2.3 and higher
|
80
|
+
bin/logstash-plugin install --no-verify
|
81
|
+
|
82
|
+
# Prior to Logstash 2.3
|
83
|
+
bin/plugin install --no-verify
|
84
|
+
|
85
|
+
```
|
86
|
+
- Start Logstash and proceed to test the plugin
|
87
|
+
|
88
|
+
## Contributing
|
89
|
+
|
90
|
+
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
|
91
|
+
|
92
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/tintoy/logstash-output-seq/blob/master/.github/CONTRIBUTING.md) file.
|
@@ -0,0 +1,144 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'json/ext'
|
3
|
+
require 'logstash/outputs/base'
|
4
|
+
require 'logstash/plugin_mixins/http_client'
|
5
|
+
require 'logstash/json'
|
6
|
+
require 'logstash/namespace'
|
7
|
+
|
8
|
+
# An output that sends events to Seq.
|
9
|
+
class LogStash::Outputs::Seq < LogStash::Outputs::Base
|
10
|
+
include LogStash::PluginMixins::HttpClient
|
11
|
+
|
12
|
+
@@ignore_properties = {
|
13
|
+
'@timestamp' => true,
|
14
|
+
'@level' => true,
|
15
|
+
'@version' => true,
|
16
|
+
'message' => true
|
17
|
+
}
|
18
|
+
|
19
|
+
config_name 'seq'
|
20
|
+
|
21
|
+
# The Seq server URL
|
22
|
+
config :url, :validate => :string, :required => :true
|
23
|
+
|
24
|
+
# The Seq API key
|
25
|
+
config :api_key, :validate => :string, :optional => :true
|
26
|
+
|
27
|
+
public
|
28
|
+
def register
|
29
|
+
url = @url
|
30
|
+
|
31
|
+
url += '/' unless url.end_with? '/'
|
32
|
+
url += 'api/events/raw'
|
33
|
+
|
34
|
+
@url = url
|
35
|
+
|
36
|
+
@default_headers = {
|
37
|
+
'X-Seq-ApiKey' => @api_key,
|
38
|
+
'Content-Type' => 'application/json'
|
39
|
+
}
|
40
|
+
|
41
|
+
# We count outstanding requests with this queue; it tracks outstanding requests to create backpressure
|
42
|
+
# When this queue is empty no new requests may be sent, tokens must be added back by the client on success
|
43
|
+
@request_tokens = SizedQueue.new(@pool_max)
|
44
|
+
@pool_max.times {|t| @request_tokens << true }
|
45
|
+
end # def register
|
46
|
+
|
47
|
+
public
|
48
|
+
def multi_receive(events)
|
49
|
+
payload = {
|
50
|
+
'Events' => events.map {|event| to_seq_payload(event)}
|
51
|
+
}
|
52
|
+
post_to_seq(payload)
|
53
|
+
|
54
|
+
"#{events.length} events received"
|
55
|
+
end # def multi_receive
|
56
|
+
|
57
|
+
public
|
58
|
+
def receive(event)
|
59
|
+
payload = {
|
60
|
+
'Events' => [to_seq_payload(event)]
|
61
|
+
}
|
62
|
+
post_to_seq(payload)
|
63
|
+
|
64
|
+
'Event received'
|
65
|
+
end # def receive
|
66
|
+
|
67
|
+
private
|
68
|
+
def post_to_seq(payload)
|
69
|
+
token = @request_tokens.pop
|
70
|
+
|
71
|
+
request = client.post(@url, {
|
72
|
+
headers: @default_headers,
|
73
|
+
body: payload.to_json,
|
74
|
+
async: true
|
75
|
+
})
|
76
|
+
|
77
|
+
request.on_complete do
|
78
|
+
@request_tokens << token
|
79
|
+
end
|
80
|
+
|
81
|
+
request.on_success do |response|
|
82
|
+
if response.code < 200 || response.code > 299
|
83
|
+
log_failure("Encountered non-200 HTTP code #{200}",
|
84
|
+
:response_code => response.code,
|
85
|
+
:url => url,
|
86
|
+
:event => event
|
87
|
+
)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
request.on_failure do |exception|
|
92
|
+
log_failure("Could not submit POST request.",
|
93
|
+
:url => url,
|
94
|
+
:method => @http_method,
|
95
|
+
:body => body,
|
96
|
+
:headers => headers,
|
97
|
+
:message => exception.message,
|
98
|
+
:class => exception.class.name,
|
99
|
+
:backtrace => exception.backtrace
|
100
|
+
)
|
101
|
+
end
|
102
|
+
|
103
|
+
request_async_background(request)
|
104
|
+
end # def post_to_seq
|
105
|
+
|
106
|
+
# Convert a Logstash event to a Seq event payload.
|
107
|
+
#
|
108
|
+
# Note that we return a hash here, not the JSON, because it's more efficient to convert batched events to JSON all-in-one go.
|
109
|
+
private
|
110
|
+
def to_seq_payload(event)
|
111
|
+
props = {
|
112
|
+
'@Version' => event['@version']
|
113
|
+
}
|
114
|
+
payload = {
|
115
|
+
:Timestamp => event['@timestamp'],
|
116
|
+
:Level => get_level(event),
|
117
|
+
:MessageTemplate => event['message'],
|
118
|
+
:Properties => props
|
119
|
+
}
|
120
|
+
|
121
|
+
event.instance_variable_get(:@data).each do |property, value|
|
122
|
+
props[property] = value unless @@ignore_properties.has_key? property
|
123
|
+
end
|
124
|
+
|
125
|
+
payload
|
126
|
+
end # def to_seq_payload
|
127
|
+
|
128
|
+
private
|
129
|
+
def get_level(event)
|
130
|
+
level = event['@level']
|
131
|
+
|
132
|
+
level ? level : 'Verbose'
|
133
|
+
end # def get_level
|
134
|
+
|
135
|
+
# Manticore doesn't provide a way to attach handlers to background or async requests well
|
136
|
+
# It wants you to use futures. The #async method kinda works but expects single thread batches
|
137
|
+
# and background only returns futures.
|
138
|
+
# Proposed fix to manticore here: https://github.com/cheald/manticore/issues/32
|
139
|
+
private
|
140
|
+
def request_async_background(request)
|
141
|
+
@method ||= client.executor.java_method(:submit, [java.util.concurrent.Callable.java_class])
|
142
|
+
@method.call(request)
|
143
|
+
end
|
144
|
+
end # class LogStash::Outputs::Seq
|
@@ -0,0 +1,28 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'logstash-output-seq'
|
3
|
+
s.version = "0.0.1"
|
4
|
+
s.licenses = ["MIT"]
|
5
|
+
s.summary = "This plugin outputs log entries to Seq (https://getseq.net)."
|
6
|
+
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
7
|
+
s.authors = ["tintoy"]
|
8
|
+
s.email = "tintoy@tintoy.io"
|
9
|
+
s.homepage = "https://github.com/tintoy/logstash-output-seq"
|
10
|
+
s.require_paths = ["lib"]
|
11
|
+
|
12
|
+
# Files
|
13
|
+
s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE']
|
14
|
+
# Tests
|
15
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
16
|
+
|
17
|
+
# Special flag to let us know this is actually a logstash plugin
|
18
|
+
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
|
19
|
+
|
20
|
+
# Gem dependencies
|
21
|
+
s.add_runtime_dependency "logstash-core", ">= 2.3.4", "< 3.0.0"
|
22
|
+
s.add_runtime_dependency "logstash-mixin-http_client", ">= 2.2.4", "< 3.0.0"
|
23
|
+
s.add_runtime_dependency "logstash-codec-plain"
|
24
|
+
|
25
|
+
s.add_development_dependency "logstash-devutils", "~> 0.0.15"
|
26
|
+
s.add_development_dependency "sinatra"
|
27
|
+
s.add_development_dependency "webrick"
|
28
|
+
end
|
@@ -0,0 +1,238 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'logstash/devutils/rspec/spec_helper'
|
3
|
+
require 'logstash/outputs/seq'
|
4
|
+
require 'logstash/codecs/plain'
|
5
|
+
require 'logstash/event'
|
6
|
+
|
7
|
+
require "json"
|
8
|
+
require "sinatra"
|
9
|
+
|
10
|
+
describe LogStash::Outputs::Seq do
|
11
|
+
# Output and its configuration
|
12
|
+
let(:port) { PORT }
|
13
|
+
let(:url) { "http://localhost:#{port}/" }
|
14
|
+
let(:output) {
|
15
|
+
LogStash::Outputs::Seq.new({
|
16
|
+
'url' => url,
|
17
|
+
'pool_max' => 1 # Required so we can block until the request completes.
|
18
|
+
})
|
19
|
+
}
|
20
|
+
|
21
|
+
# Captured request
|
22
|
+
let(:request_failed) { TestApp.last_request_failed }
|
23
|
+
let(:last_request) { TestApp.last_request }
|
24
|
+
let(:request_body) { last_request.body.read }
|
25
|
+
let(:request_content_type) { last_request ? last_request.env["CONTENT_TYPE"] : nil }
|
26
|
+
let(:posted_events) { JSON.parse(request_body) }
|
27
|
+
|
28
|
+
# Sample events
|
29
|
+
let(:sample_event) {
|
30
|
+
LogStash::Event.new({
|
31
|
+
'@timestamp' => '2016-07-23T10:09:08.12345+10:00',
|
32
|
+
'host' => 'localhost',
|
33
|
+
'message' => 'Hi, Single Event'
|
34
|
+
})
|
35
|
+
}
|
36
|
+
let(:sample_events) {
|
37
|
+
[
|
38
|
+
LogStash::Event.new({
|
39
|
+
'@timestamp' => '2016-07-23T00:09:08.123Z',
|
40
|
+
'@level' => 'Info',
|
41
|
+
'host' => 'localhost',
|
42
|
+
'message' => 'Hello, World!',
|
43
|
+
'name' => 'World'
|
44
|
+
}),
|
45
|
+
LogStash::Event.new({
|
46
|
+
'@timestamp' => '2016-07-23T00:09:00.456Z',
|
47
|
+
'@level' => 'Warning',
|
48
|
+
'host' => 'localhost',
|
49
|
+
'message' => 'Goodbye Moon?',
|
50
|
+
'name' => 'Moon'
|
51
|
+
})
|
52
|
+
]
|
53
|
+
}
|
54
|
+
|
55
|
+
before do
|
56
|
+
TestApp.reset
|
57
|
+
end
|
58
|
+
|
59
|
+
before do
|
60
|
+
output.register
|
61
|
+
end
|
62
|
+
|
63
|
+
describe 'receive message' do
|
64
|
+
before do
|
65
|
+
output.receive(sample_event)
|
66
|
+
wait_for_request
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'makes a request' do
|
70
|
+
expect(last_request).to_not be_nil
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'does an HTTP POST' do
|
74
|
+
expect(request_failed).to be(false)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'sends JSON' do
|
78
|
+
expect(request_content_type).to eq('application/json')
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'sends a valid event event data payload' do
|
82
|
+
expect(posted_events).to eq(
|
83
|
+
{
|
84
|
+
'Events' => [
|
85
|
+
{
|
86
|
+
'Timestamp' => '2016-07-23T00:09:08.123Z',
|
87
|
+
'Level' => 'Verbose',
|
88
|
+
'MessageTemplate' => 'Hi, Single Event',
|
89
|
+
'Properties' => {
|
90
|
+
'@Version' => "1",
|
91
|
+
'host' => 'localhost'
|
92
|
+
}
|
93
|
+
}
|
94
|
+
]
|
95
|
+
}
|
96
|
+
)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe 'receive messages' do
|
101
|
+
before do
|
102
|
+
output.multi_receive(sample_events)
|
103
|
+
wait_for_request
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'makes a request' do
|
107
|
+
expect(last_request).to_not be_nil
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'does an HTTP POST' do
|
111
|
+
expect(request_failed).to be(false)
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'sends JSON' do
|
115
|
+
expect(request_content_type).to eq('application/json')
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'sends a valid event event data payload' do
|
119
|
+
expect(posted_events).to eq(
|
120
|
+
{
|
121
|
+
'Events' => [
|
122
|
+
{
|
123
|
+
'Timestamp' => '2016-07-23T00:09:08.123Z',
|
124
|
+
'Level' => 'Info',
|
125
|
+
'MessageTemplate' => 'Hello, World!',
|
126
|
+
'Properties' => {
|
127
|
+
'@Version' => "1",
|
128
|
+
'host' => 'localhost',
|
129
|
+
'name' => 'World'
|
130
|
+
}
|
131
|
+
},
|
132
|
+
{
|
133
|
+
'Timestamp' => '2016-07-23T00:09:00.456Z',
|
134
|
+
'Level' => 'Warning',
|
135
|
+
'MessageTemplate' => 'Goodbye Moon?',
|
136
|
+
'Properties' => {
|
137
|
+
'@Version' => "1",
|
138
|
+
'host' => 'localhost',
|
139
|
+
'name' => 'Moon'
|
140
|
+
}
|
141
|
+
}
|
142
|
+
]
|
143
|
+
}
|
144
|
+
)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def wait_for_request()
|
149
|
+
# Wait for the current request to complete.
|
150
|
+
output.request_tokens.pop
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
# Enable access to request tokens from the test.
|
155
|
+
class LogStash::Outputs::Seq
|
156
|
+
attr_reader :request_tokens
|
157
|
+
end
|
158
|
+
|
159
|
+
PORT = rand(65535-1024) + 1025
|
160
|
+
|
161
|
+
RSpec.configure do |config|
|
162
|
+
#http://stackoverflow.com/questions/6557079/start-and-call-ruby-http-server-in-the-same-script
|
163
|
+
def sinatra_run_wait(app, opts)
|
164
|
+
queue = Queue.new
|
165
|
+
|
166
|
+
Thread.new(queue) do |queue|
|
167
|
+
begin
|
168
|
+
app.run!(opts) do |server|
|
169
|
+
queue.push("started")
|
170
|
+
end
|
171
|
+
rescue
|
172
|
+
# ignore
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
queue.pop # blocks until the run! callback runs
|
177
|
+
end
|
178
|
+
|
179
|
+
config.before(:suite) do
|
180
|
+
sinatra_run_wait(TestApp, :port => PORT, :server => 'webrick')
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
# note that Sinatra startup and shutdown messages are directly logged to stderr so
|
185
|
+
# it is not really possible to disable them without reopening stderr which is not advisable.
|
186
|
+
#
|
187
|
+
# == Sinatra (v1.4.6) has taken the stage on 51572 for development with backup from WEBrick
|
188
|
+
# == Sinatra has ended his set (crowd applauds)
|
189
|
+
|
190
|
+
class TestApp < Sinatra::Base
|
191
|
+
|
192
|
+
# disable WEBrick logging
|
193
|
+
def self.server_settings
|
194
|
+
{ :AccessLog => [], :Logger => WEBrick::BasicLog::new(nil, WEBrick::BasicLog::FATAL) }
|
195
|
+
end
|
196
|
+
|
197
|
+
def self.reset()
|
198
|
+
@last_request_failed = false
|
199
|
+
@last_request = nil
|
200
|
+
end
|
201
|
+
|
202
|
+
def self.last_request_failed=(last_request_failed)
|
203
|
+
@last_request_failed = last_request_failed
|
204
|
+
end
|
205
|
+
|
206
|
+
def self.last_request_failed
|
207
|
+
@last_request_failed
|
208
|
+
end
|
209
|
+
|
210
|
+
def self.last_request=(request)
|
211
|
+
@last_request = request
|
212
|
+
end
|
213
|
+
|
214
|
+
def self.last_request
|
215
|
+
@last_request
|
216
|
+
end
|
217
|
+
|
218
|
+
def self.multiroute(methods, path, &block)
|
219
|
+
methods.each do |method|
|
220
|
+
method.to_sym
|
221
|
+
self.send method, path, &block
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
post "/api/events/raw" do
|
226
|
+
self.class.last_request = request
|
227
|
+
# Success after failure stills means failure until reset
|
228
|
+
|
229
|
+
[200, '{"MinimumLevelAccepted": null}']
|
230
|
+
end
|
231
|
+
|
232
|
+
multiroute(%w(get post put patch delete), "/*") do
|
233
|
+
self.class.last_request = request
|
234
|
+
self.class.last_request_failed = true
|
235
|
+
|
236
|
+
[500, "{\"Error\": \"Unexpected request: #{request.request_method} '#{request.url}'\"}"]
|
237
|
+
end
|
238
|
+
end
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-output-seq
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- tintoy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 2.3.4
|
19
|
+
- - "<"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.0.0
|
22
|
+
name: logstash-core
|
23
|
+
prerelease: false
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.3.4
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.0.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 2.2.4
|
39
|
+
- - "<"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 3.0.0
|
42
|
+
name: logstash-mixin-http_client
|
43
|
+
prerelease: false
|
44
|
+
type: :runtime
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 2.2.4
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 3.0.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
name: logstash-codec-plain
|
60
|
+
prerelease: false
|
61
|
+
type: :runtime
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
requirement: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 0.0.15
|
73
|
+
name: logstash-devutils
|
74
|
+
prerelease: false
|
75
|
+
type: :development
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 0.0.15
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
requirement: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
name: sinatra
|
88
|
+
prerelease: false
|
89
|
+
type: :development
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
name: webrick
|
102
|
+
prerelease: false
|
103
|
+
type: :development
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
description: This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program
|
110
|
+
email: tintoy@tintoy.io
|
111
|
+
executables: []
|
112
|
+
extensions: []
|
113
|
+
extra_rdoc_files: []
|
114
|
+
files:
|
115
|
+
- CHANGELOG.md
|
116
|
+
- CONTRIBUTORS
|
117
|
+
- DEVELOPER.md
|
118
|
+
- Gemfile
|
119
|
+
- LICENSE
|
120
|
+
- README.md
|
121
|
+
- lib/logstash/outputs/seq.rb
|
122
|
+
- logstash-output-seq.gemspec
|
123
|
+
- spec/outputs/seq_spec.rb
|
124
|
+
homepage: https://github.com/tintoy/logstash-output-seq
|
125
|
+
licenses:
|
126
|
+
- MIT
|
127
|
+
metadata:
|
128
|
+
logstash_plugin: 'true'
|
129
|
+
logstash_group: output
|
130
|
+
post_install_message:
|
131
|
+
rdoc_options: []
|
132
|
+
require_paths:
|
133
|
+
- lib
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
requirements: []
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 2.4.8
|
147
|
+
signing_key:
|
148
|
+
specification_version: 4
|
149
|
+
summary: This plugin outputs log entries to Seq (https://getseq.net).
|
150
|
+
test_files:
|
151
|
+
- spec/outputs/seq_spec.rb
|