logstash-codec-trigger 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/Gemfile +2 -0
- data/LICENSE +13 -0
- data/Rakefile +7 -0
- data/lib/logstash/codecs/trigger.rb +66 -0
- data/logstash-codec-trigger.gemspec +27 -0
- data/spec/codecs/trigger_spec.rb +18 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9b505668e9ae1df4788695140fe70ba410bc0690
|
4
|
+
data.tar.gz: fdc79f630ed175dd6d7f19c750cfc187b8d45aa3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f682b8247edbbe0899a81a3dd80a12ed4bc8315a2506376e4b2e4a2f81c29d579a837f374aeaa0a2b2d0b8c0497d5440bda806faff2ff886bc558c2d47710357
|
7
|
+
data.tar.gz: 6b73fcb2c68d88b314a554e15297088c5ca5d1411f9df82d012ff41374d0c890eda2ccba994f8a3a67d9e7179686ee74454cd593b6397534673b997b45feaf39
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2012-2014 Elasticsearch <http://www.elasticsearch.org>
|
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/Rakefile
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require "logstash/codecs/base"
|
2
|
+
require "logstash/util/charset"
|
3
|
+
|
4
|
+
# The "trigger" codec is for reading triggers from a file for later use in trigger-filters.
|
5
|
+
class LogStash::Codecs::Trigger < LogStash::Codecs::Base
|
6
|
+
config_name "trigger"
|
7
|
+
|
8
|
+
# Set the message you which to emit for each event. This supports sprintf
|
9
|
+
# strings.
|
10
|
+
#
|
11
|
+
# This setting only affects outputs (encoding of events).
|
12
|
+
config :format, :validate => :string
|
13
|
+
|
14
|
+
# The character encoding used in this input. Examples include "UTF-8"
|
15
|
+
# and "cp1252"
|
16
|
+
#
|
17
|
+
# This setting is useful if your log files are in Latin-1 (aka cp1252)
|
18
|
+
# or in another character set other than UTF-8.
|
19
|
+
#
|
20
|
+
# This only affects "plain" format logs since json is UTF-8 already.
|
21
|
+
config :charset, :validate => ::Encoding.name_list, :default => "UTF-8"
|
22
|
+
|
23
|
+
# The attribute/field, where the matching triggers will be saved
|
24
|
+
config :trigger_attribute, :validate => :string, :default => "trigger"
|
25
|
+
|
26
|
+
# The prefix for the foldername, where the files should be written
|
27
|
+
config :trigger_folder_prefix, :validate => :string, :default => "Trigger_"
|
28
|
+
|
29
|
+
# The format for the foldername, where the files should be written
|
30
|
+
config :trigger_folder_format, :validate => :string, :default => "yyyyMMdd_HHmmss"
|
31
|
+
|
32
|
+
public
|
33
|
+
def register
|
34
|
+
@converter = LogStash::Util::Charset.new(@charset)
|
35
|
+
@converter.logger = @logger
|
36
|
+
end
|
37
|
+
|
38
|
+
public
|
39
|
+
def decode(data)
|
40
|
+
yield LogStash::Event.new("message" => @converter.convert(data))
|
41
|
+
end # def decode
|
42
|
+
|
43
|
+
public
|
44
|
+
def encode(event)
|
45
|
+
if event.include?(@trigger_attribute)
|
46
|
+
|
47
|
+
event[@trigger_attribute].each do |trigger|
|
48
|
+
|
49
|
+
dirname = File.dirname(event['path'])
|
50
|
+
basename = File.basename(event['path'])
|
51
|
+
|
52
|
+
timestamp = org.joda.time.DateTime.new(trigger[:timestamp])
|
53
|
+
triggerfolder = @trigger_folder_prefix + timestamp.toString(@trigger_folder_format);
|
54
|
+
|
55
|
+
path = "#{dirname}/#{triggerfolder}/#{basename}"
|
56
|
+
|
57
|
+
@logger.debug("Path from trigger", :path => path) if @logger.debug?
|
58
|
+
|
59
|
+
new_event = event.clone
|
60
|
+
new_event["path"] = path
|
61
|
+
|
62
|
+
@on_event.call(new_event)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end # def encode
|
66
|
+
end # class LogStash::Codecs::Plain
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
|
3
|
+
s.name = 'logstash-codec-trigger'
|
4
|
+
s.version = '0.1.0'
|
5
|
+
s.licenses = ['Apache License (2.0)']
|
6
|
+
s.summary = "The 'trigger' codec is for reading triggers from a file for later use in trigger-filters."
|
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 = ["Signify"]
|
9
|
+
s.email = 'dietmar@signifydata.com'
|
10
|
+
s.homepage = "http://www.signifydata.com"
|
11
|
+
s.require_paths = ["lib"]
|
12
|
+
|
13
|
+
# Files
|
14
|
+
s.files = `git ls-files`.split($\)
|
15
|
+
|
16
|
+
# Tests
|
17
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
18
|
+
|
19
|
+
# Special flag to let us know this is actually a logstash plugin
|
20
|
+
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "codec" }
|
21
|
+
|
22
|
+
# Gem dependencies
|
23
|
+
s.add_runtime_dependency 'logstash-core', '>= 1.4.0', '< 2.0.0'
|
24
|
+
|
25
|
+
s.add_development_dependency 'logstash-devutils'
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "logstash/devutils/rspec/spec_helper"
|
4
|
+
require "logstash/codecs/line"
|
5
|
+
require "logstash/event"
|
6
|
+
|
7
|
+
describe LogStash::Codecs::Trigger do
|
8
|
+
subject do
|
9
|
+
next LogStash::Codecs::Trigger.new
|
10
|
+
end
|
11
|
+
|
12
|
+
context "#encode" do
|
13
|
+
let (:event) {LogStash::Event.new({"message" => "hello world", "host" => "test"})}
|
14
|
+
end
|
15
|
+
|
16
|
+
context "#decode" do
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-codec-trigger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Signify
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-25 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: 1.4.0
|
19
|
+
- - <
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.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: 1.4.0
|
30
|
+
- - <
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.0.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
name: logstash-devutils
|
40
|
+
prerelease: false
|
41
|
+
type: :development
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
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
|
48
|
+
email: dietmar@signifydata.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE
|
56
|
+
- Rakefile
|
57
|
+
- lib/logstash/codecs/trigger.rb
|
58
|
+
- logstash-codec-trigger.gemspec
|
59
|
+
- spec/codecs/trigger_spec.rb
|
60
|
+
homepage: http://www.signifydata.com
|
61
|
+
licenses:
|
62
|
+
- Apache License (2.0)
|
63
|
+
metadata:
|
64
|
+
logstash_plugin: 'true'
|
65
|
+
logstash_group: codec
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.1.9
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: The 'trigger' codec is for reading triggers from a file for later use in trigger-filters.
|
86
|
+
test_files:
|
87
|
+
- spec/codecs/trigger_spec.rb
|