fluent-plugin-time-filter 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.circleci/config.yml +90 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +80 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +13 -0
- data/README.md +57 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/fluent-plugin-time-filter.gemspec +28 -0
- data/lib/fluent/plugin/filter_time.rb +41 -0
- metadata +175 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: de334ca502ca99b2e994b3eb8a617d873164f5cd691d4e652e5f937b49252248
|
4
|
+
data.tar.gz: e6a2d6d4c52d407a6ceae423eb5f12e9097654218ff82c7dbf87e20c8556518c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b3918813b13a7b2ec41cad79d42084c293d735201979cecc6b91f4e166436db50fc0aa0c453dbbc83237c49b05c25c9c7078e9356a0186dec3da06ad6a121689
|
7
|
+
data.tar.gz: ceb2143d584a1b5b6c7e8cc1f60787760739b5c2d3684bf5e0c70d9437b68803c6ffe6f6ab6aaa3ef1fdddbd534ed77178950ce859010472937ee2b520e8dd08
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# Ruby CircleCI 2.0 configuration file
|
2
|
+
#
|
3
|
+
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
4
|
+
#
|
5
|
+
version: 2
|
6
|
+
jobs:
|
7
|
+
build:
|
8
|
+
docker:
|
9
|
+
# specify the version you desire here
|
10
|
+
- image: circleci/ruby:2.4.2-node-browsers
|
11
|
+
working_directory: ~/repo
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- checkout
|
15
|
+
|
16
|
+
- run:
|
17
|
+
name: install dependencies
|
18
|
+
command: |
|
19
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
20
|
+
|
21
|
+
# Build gem
|
22
|
+
- run:
|
23
|
+
name: build gem
|
24
|
+
command: |
|
25
|
+
bundle exec rake build
|
26
|
+
|
27
|
+
- save_cache:
|
28
|
+
paths:
|
29
|
+
- ./vendor/bundle
|
30
|
+
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
31
|
+
|
32
|
+
# run unit tests
|
33
|
+
- run:
|
34
|
+
name: run unit tests
|
35
|
+
command: |
|
36
|
+
bundle exec rspec --format documentation \
|
37
|
+
--format RspecJunitFormatter \
|
38
|
+
--out /tmp/test-results/rspec.xml
|
39
|
+
|
40
|
+
# run rubocop
|
41
|
+
- run: bundle exec rubocop -D
|
42
|
+
|
43
|
+
# collect reports
|
44
|
+
- store_test_results:
|
45
|
+
path: /tmp/test-results
|
46
|
+
- store_artifacts:
|
47
|
+
path: /tmp/test-results
|
48
|
+
destination: test-results
|
49
|
+
|
50
|
+
# pass workspace to next job
|
51
|
+
- persist_to_workspace:
|
52
|
+
root: .
|
53
|
+
paths:
|
54
|
+
- .
|
55
|
+
|
56
|
+
publish:
|
57
|
+
docker:
|
58
|
+
# specify the version you desire here
|
59
|
+
- image: circleci/ruby:2.4.2-node-browsers
|
60
|
+
working_directory: ~/repo
|
61
|
+
steps:
|
62
|
+
- attach_workspace:
|
63
|
+
at: .
|
64
|
+
# configure to publish
|
65
|
+
- run:
|
66
|
+
name: configure
|
67
|
+
command: |
|
68
|
+
mkdir ~/.gem && echo -e ":rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials && chmod 0600 /home/circleci/.gem/credentials
|
69
|
+
# publish to rubygems.org
|
70
|
+
- run:
|
71
|
+
name: publish
|
72
|
+
command: |
|
73
|
+
gem push pkg/fluent-plugin-time-filter-*.gem
|
74
|
+
|
75
|
+
workflows:
|
76
|
+
version: 2
|
77
|
+
test-and-deploy:
|
78
|
+
jobs:
|
79
|
+
- build:
|
80
|
+
filters:
|
81
|
+
tags:
|
82
|
+
only: /.*/
|
83
|
+
- publish:
|
84
|
+
requires:
|
85
|
+
- build
|
86
|
+
filters:
|
87
|
+
tags:
|
88
|
+
only: /^v[0-9]+(\.[0-9]+){2}.*/
|
89
|
+
branches:
|
90
|
+
ignore: /.*/
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.5
|
3
|
+
Exclude:
|
4
|
+
- bin/*
|
5
|
+
- config/**/*.rb
|
6
|
+
- db/migrate/*.rb
|
7
|
+
- db/schema.rb
|
8
|
+
- db/seeds.rb
|
9
|
+
- vendor/bundle/**/*
|
10
|
+
|
11
|
+
Metrics/LineLength:
|
12
|
+
Max: 120
|
13
|
+
|
14
|
+
Style/AsciiComments:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Style/BracesAroundHashParameters:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Style/ClassAndModuleChildren:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
Style/MutableConstant:
|
24
|
+
AutoCorrect: false
|
25
|
+
|
26
|
+
Layout/EndAlignment:
|
27
|
+
EnforcedStyleAlignWith: variable
|
28
|
+
|
29
|
+
Style/NegatedIf:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
Style/NegatedWhile:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
Style/DoubleNegation:
|
36
|
+
Enabled: false
|
37
|
+
|
38
|
+
Metrics/ParameterLists:
|
39
|
+
Exclude:
|
40
|
+
- spec/**/*
|
41
|
+
|
42
|
+
Metrics/MethodLength:
|
43
|
+
Max: 15
|
44
|
+
Exclude:
|
45
|
+
- apps/**/views/**/*.rb
|
46
|
+
|
47
|
+
Metrics/BlockLength:
|
48
|
+
Exclude:
|
49
|
+
- apps/**/views/**/*.rb
|
50
|
+
- spec/**/*.rb
|
51
|
+
|
52
|
+
Metrics/AbcSize:
|
53
|
+
Max: 20
|
54
|
+
|
55
|
+
Metrics/PerceivedComplexity:
|
56
|
+
Max: 8
|
57
|
+
|
58
|
+
Metrics/CyclomaticComplexity:
|
59
|
+
Max: 7
|
60
|
+
|
61
|
+
Performance/RedundantMerge:
|
62
|
+
Enabled: false
|
63
|
+
|
64
|
+
Style/FrozenStringLiteralComment:
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
Style/SingleLineBlockParams:
|
68
|
+
Enabled: false
|
69
|
+
|
70
|
+
Style/EmptyMethod:
|
71
|
+
Enabled: false
|
72
|
+
|
73
|
+
Style/NumericPredicate:
|
74
|
+
Enabled: false
|
75
|
+
|
76
|
+
Bundler/OrderedGems:
|
77
|
+
Enabled: false
|
78
|
+
|
79
|
+
Gemspec/OrderedDependencies:
|
80
|
+
Enabled: false
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (C) 2018 Akira Tanimura (@AuToPP)
|
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,57 @@
|
|
1
|
+
# fluent-plugin-time-filter
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'fluent-plugin-time-filter'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install fluent-plugin-time-filter
|
18
|
+
|
19
|
+
## Parameters
|
20
|
+
|
21
|
+
| name | type | required? | description |
|
22
|
+
|---|---|---|
|
23
|
+
| `@type` | string | yes | The value must be `time` |
|
24
|
+
| `threshold` | integer | yes | Threshold for filtering by timestamp. Events whose timestamp is older than `threshold` seconds ago are filtered out. |
|
25
|
+
|
26
|
+
## Example
|
27
|
+
|
28
|
+
Configuration:
|
29
|
+
|
30
|
+
```
|
31
|
+
<filter foo.bar>
|
32
|
+
@type time
|
33
|
+
threshold 60
|
34
|
+
</filter>
|
35
|
+
```
|
36
|
+
|
37
|
+
When the following events pass through this filter at `2018-08-19 22:00:00`:
|
38
|
+
|
39
|
+
```
|
40
|
+
["foo.bar", "2018-08-19 21:58:59 +0900", { number: 1 }]
|
41
|
+
["foo.bar", "2018-08-19 21:59:00 +0900", { number: 2 }]
|
42
|
+
["foo.bar", "2018-08-19 21:59:01 +0900", { number: 3 }]
|
43
|
+
```
|
44
|
+
|
45
|
+
only the last two are passed to the next step of the pipeline, the first one is discarded.
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/autopp/fluent-plugin-time-filter.
|
50
|
+
|
51
|
+
## License
|
52
|
+
|
53
|
+
[Apache License 2.0](LICENSE.txt)
|
54
|
+
|
55
|
+
## Author
|
56
|
+
|
57
|
+
[@AuToPP](https://twitter.com/AuToPP)
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'fluent/plugin/time/filter'
|
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(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = 'fluent-plugin-time-filter'
|
3
|
+
spec.version = '0.1.0'
|
4
|
+
spec.authors = ['autopp']
|
5
|
+
spec.email = ['autopp.inc@gmail.com']
|
6
|
+
|
7
|
+
spec.summary = 'Fluentd plugin to filter old records'
|
8
|
+
spec.description = spec.summary
|
9
|
+
spec.homepage = 'https://github.com/autopp/fluent-plugin-time-filter'
|
10
|
+
spec.license = 'Apache-2.0'
|
11
|
+
|
12
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
13
|
+
f.match(%r{^(test|spec|features)/})
|
14
|
+
end
|
15
|
+
spec.bindir = 'exe'
|
16
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
17
|
+
spec.require_paths = ['lib']
|
18
|
+
|
19
|
+
spec.add_runtime_dependency 'fluentd', '>= 0.12.0', '< 2'
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
24
|
+
spec.add_development_dependency 'timecop'
|
25
|
+
spec.add_development_dependency 'rspec_junit_formatter'
|
26
|
+
spec.add_development_dependency 'rubocop', '~> 0.58.2'
|
27
|
+
spec.add_development_dependency 'test-unit', '~> 3.2'
|
28
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#
|
2
|
+
# fluent-plugin-filter-time
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'fluent/filter'
|
18
|
+
|
19
|
+
module Fluent
|
20
|
+
# TimeFilter provides filter_time plugin for Fluentd
|
21
|
+
#
|
22
|
+
class TimeFilter < Filter
|
23
|
+
Fluent::Plugin.register_filter('time', self)
|
24
|
+
|
25
|
+
config_param :threshold, :integer, desc: <<~EODESC
|
26
|
+
Threshold for filtering by timestamp.
|
27
|
+
Events whose timestamp is older than `threshold` seconds ago are filtered out.
|
28
|
+
EODESC
|
29
|
+
|
30
|
+
def filter(_tag, time, record)
|
31
|
+
delay = Fluent::Engine.now - time
|
32
|
+
if delay <= threshold
|
33
|
+
record
|
34
|
+
else
|
35
|
+
log.debug('skipped record older than threshold',
|
36
|
+
time: Time.at(time), delay: delay, plugin_id: plugin_id)
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-time-filter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- autopp
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-08-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fluentd
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.12.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.12.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: bundler
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.16'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.16'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '10.0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '10.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rspec
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '3.0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '3.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: timecop
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rspec_junit_formatter
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: rubocop
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 0.58.2
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 0.58.2
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: test-unit
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '3.2'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '3.2'
|
131
|
+
description: Fluentd plugin to filter old records
|
132
|
+
email:
|
133
|
+
- autopp.inc@gmail.com
|
134
|
+
executables: []
|
135
|
+
extensions: []
|
136
|
+
extra_rdoc_files: []
|
137
|
+
files:
|
138
|
+
- ".circleci/config.yml"
|
139
|
+
- ".gitignore"
|
140
|
+
- ".rspec"
|
141
|
+
- ".rubocop.yml"
|
142
|
+
- CHANGELOG.md
|
143
|
+
- Gemfile
|
144
|
+
- LICENSE.txt
|
145
|
+
- README.md
|
146
|
+
- Rakefile
|
147
|
+
- bin/console
|
148
|
+
- bin/setup
|
149
|
+
- fluent-plugin-time-filter.gemspec
|
150
|
+
- lib/fluent/plugin/filter_time.rb
|
151
|
+
homepage: https://github.com/autopp/fluent-plugin-time-filter
|
152
|
+
licenses:
|
153
|
+
- Apache-2.0
|
154
|
+
metadata: {}
|
155
|
+
post_install_message:
|
156
|
+
rdoc_options: []
|
157
|
+
require_paths:
|
158
|
+
- lib
|
159
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
requirements: []
|
170
|
+
rubyforge_project:
|
171
|
+
rubygems_version: 2.7.3
|
172
|
+
signing_key:
|
173
|
+
specification_version: 4
|
174
|
+
summary: Fluentd plugin to filter old records
|
175
|
+
test_files: []
|