logstash-filter-age 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +2 -0
- data/CONTRIBUTORS +10 -0
- data/Gemfile +2 -0
- data/LICENSE +11 -0
- data/README.md +2 -0
- data/lib/logstash/filters/age.rb +38 -0
- data/logstash-filter-age.gemspec +22 -0
- data/spec/filters/age_spec.rb +27 -0
- data/spec/spec_helper.rb +4 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f06760d671f068e6824005137024f7e4e4482f24
|
4
|
+
data.tar.gz: 16c50a374bb907959b2376fe878492053ae3d71e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f4624bf68b5418ef451c577adf03596d4906545b1bb6d9b168a9a93c3f1a1ce27ea61c2e8a19ce1b9457733547410fb322c3f60eaba519f34ef2b51c8c7253f7
|
7
|
+
data.tar.gz: ce7985b34fc3b94a2710a29e6a7d50b748a65702db31ce4b64406eeb87e5ed4c71cfb178e5a1e74a9054f5fd744b00894100395b41b5bf91089cbfb571639f51
|
data/CHANGELOG.md
ADDED
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 logstash along its way.
|
3
|
+
|
4
|
+
Contributors:
|
5
|
+
* Joshua Spence - josh@joshuaspence.com
|
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/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
2
|
+
you may not use this file except in compliance with the License.
|
3
|
+
You may obtain a copy of the License at
|
4
|
+
|
5
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
|
7
|
+
Unless required by applicable law or agreed to in writing, software
|
8
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
See the License for the specific language governing permissions and
|
11
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'logstash/filters/base'
|
4
|
+
require 'logstash/namespace'
|
5
|
+
|
6
|
+
# A simple filter for calculating the age of an event.
|
7
|
+
#
|
8
|
+
# This filter calculates the age of an event by subtracting the event timestamp
|
9
|
+
# from the current timestamp. This allows you to drop Logstash events that are
|
10
|
+
# older than some threshold.
|
11
|
+
#
|
12
|
+
# [source,ruby]
|
13
|
+
# filter {
|
14
|
+
# age {}
|
15
|
+
#
|
16
|
+
# if [@metadata][age] > 86400 {
|
17
|
+
# drop {}
|
18
|
+
# }
|
19
|
+
# }
|
20
|
+
#
|
21
|
+
class LogStash::Filters::Age < LogStash::Filters::Base
|
22
|
+
|
23
|
+
config_name 'age'
|
24
|
+
|
25
|
+
# Define the target field for the event age, in seconds.
|
26
|
+
config :target, :default => '[@metadata][age]', :validate => :string
|
27
|
+
|
28
|
+
public
|
29
|
+
def register
|
30
|
+
# Nothing to do here
|
31
|
+
end
|
32
|
+
|
33
|
+
public
|
34
|
+
def filter(event)
|
35
|
+
event.set(@target, Time.now.to_f - event.timestamp.to_f)
|
36
|
+
filter_matched(event)
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'logstash-filter-age'
|
3
|
+
s.version = '1.0.0'
|
4
|
+
s.licenses = ['Apache License (2.0)']
|
5
|
+
s.summary = 'A Logstash filter for calculating the age of an event.'
|
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.homepage = 'https://github.com/joshuaspence/logstash-filter-json'
|
8
|
+
s.authors = ['Joshua Spence']
|
9
|
+
s.email = 'josh@joshuaspence.com'
|
10
|
+
s.require_paths = ['lib']
|
11
|
+
|
12
|
+
# Files
|
13
|
+
s.files = Dir['lib/**/*', 'spec/**/*', 'vendor/**/*', '*.gemspec', '*.md', 'CONTRIBUTORS', 'Gemfile', 'LICENSE', 'NOTICE.TXT']
|
14
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
15
|
+
|
16
|
+
# Special flag to let us know this is actually a Logstash plugin
|
17
|
+
s.metadata = { 'logstash_plugin' => 'true', 'logstash_group' => 'filter' }
|
18
|
+
|
19
|
+
# Gem dependencies
|
20
|
+
s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
|
21
|
+
s.add_development_dependency 'logstash-devutils'
|
22
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require_relative '../spec_helper'
|
4
|
+
|
5
|
+
describe LogStash::Filters::Age do
|
6
|
+
before do
|
7
|
+
allow(Time).to receive(:now).and_return(now)
|
8
|
+
end
|
9
|
+
let(:now) { Time.mktime(2017, 1, 1) }
|
10
|
+
|
11
|
+
context 'with default configuration' do
|
12
|
+
let(:config) { 'filter { age {} }' }
|
13
|
+
|
14
|
+
sample('message' => 'Hello World') do
|
15
|
+
expect(subject.get('[@metadata][age]')).to eq(now.to_f - subject.timestamp.to_f)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'with target' do
|
20
|
+
let(:config) { "filter { age { target => '#{target}' } }" }
|
21
|
+
let(:target) { 'age' }
|
22
|
+
|
23
|
+
sample('message' => 'Hello World') do
|
24
|
+
expect(subject.get(target)).to eq(now.to_f - subject.timestamp.to_f)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-filter-age
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joshua Spence
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-11 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.60'
|
19
|
+
- - "<="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.99'
|
22
|
+
name: logstash-core-plugin-api
|
23
|
+
prerelease: false
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.60'
|
30
|
+
- - "<="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.99'
|
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/logstash-plugin install gemname. This gem is not a stand-alone program
|
48
|
+
email: josh@joshuaspence.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- CHANGELOG.md
|
54
|
+
- CONTRIBUTORS
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE
|
57
|
+
- README.md
|
58
|
+
- lib/logstash/filters/age.rb
|
59
|
+
- logstash-filter-age.gemspec
|
60
|
+
- spec/filters/age_spec.rb
|
61
|
+
- spec/spec_helper.rb
|
62
|
+
homepage: https://github.com/joshuaspence/logstash-filter-json
|
63
|
+
licenses:
|
64
|
+
- Apache License (2.0)
|
65
|
+
metadata:
|
66
|
+
logstash_plugin: 'true'
|
67
|
+
logstash_group: filter
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 2.4.8
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: A Logstash filter for calculating the age of an event.
|
88
|
+
test_files:
|
89
|
+
- spec/filters/age_spec.rb
|
90
|
+
- spec/spec_helper.rb
|