fluent-plugin-elasticsearch-timestamp-check 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 +35 -0
- data/LICENSE +22 -0
- data/README.md +31 -0
- data/fluent-plugin-elasticsearch-timestamp-check.gemspec +17 -0
- data/lib/fluent/plugin/filter_elasticsearch_timestamp_check.rb +36 -0
- metadata +64 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bb8c1a29b0cbdc0a68aafa7782f4d672901c56d9
|
4
|
+
data.tar.gz: 9e068e18fdc67aa75d6e707def4689c4ce94b172
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 75c3383b35daa7209627aa9af373a5a0c423b92fd3a80f20c0cf54fbed7f118e03259b0983aed76f0443a2c8532edd5dd8013e17eed5e1de40f27f1bd2edf0b0
|
7
|
+
data.tar.gz: 306a7441a55e6d397c7bf7a29b25e8e4865e6027e0ae248971255e39c2830ed2914fc3f68c63c5da16d1cf44ce467cfa55cf9d29c0cc2277e283348cff97a899
|
data/.gitignore
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/vendor/bundle
|
26
|
+
/lib/bundler/man/
|
27
|
+
|
28
|
+
# for a library or gem, you might want to ignore these files since the code is
|
29
|
+
# intended to run in multiple environments; otherwise, check them in:
|
30
|
+
# Gemfile.lock
|
31
|
+
# .ruby-version
|
32
|
+
# .ruby-gemset
|
33
|
+
|
34
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
35
|
+
.rvmrc
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Richard Li
|
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,31 @@
|
|
1
|
+
# fluent-plugin-elasticsearch-timestamp-check
|
2
|
+
Fluent plugin to ensure @timestamp is in correct format for elasticsearch
|
3
|
+
|
4
|
+
## Install
|
5
|
+
|
6
|
+
```bash
|
7
|
+
gem install fluent-plugin-elasticsearch-timestamp-check
|
8
|
+
```
|
9
|
+
|
10
|
+
## Description
|
11
|
+
|
12
|
+
The purpose of this filter is to make sure the @timestamp field exists in the
|
13
|
+
record which is necessary for the record to be indexed properly by
|
14
|
+
elasticsearch.
|
15
|
+
|
16
|
+
* If *@timestamp* field already exists, it will ensure the format is correct
|
17
|
+
by parse and convert to format '%Y-%m-%dT%H:%M:%S%z'.
|
18
|
+
|
19
|
+
* If a field named *timestamp* exists, it will parse that field and conver it to
|
20
|
+
format '%Y-%m-%dT%H:%M:%S%z' then store it in *@timestamp* field.
|
21
|
+
|
22
|
+
* If neither of the above field exists, it will insert current time in
|
23
|
+
'%Y-%m-%dT%H:%M:%S%z' format as the *@timestamp* field.
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
```
|
28
|
+
<filter **>
|
29
|
+
type elasticsearch_timestamp_check
|
30
|
+
</filter>
|
31
|
+
```
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "fluent-plugin-elasticsearch-timestamp-check"
|
3
|
+
spec.version = "0.1.0"
|
4
|
+
spec.authors = ["Richard Li"]
|
5
|
+
spec.email = ["evilcat@wisewolfsolutions.com"]
|
6
|
+
spec.description = %q{fluent filter plugin to ensure @timestamp is in proper format}
|
7
|
+
spec.summary = %q{fluent timestamp checker filter}
|
8
|
+
spec.homepage = "https://github.com/ecwws/fluent-plugin-elasticsearch-timestamp-check"
|
9
|
+
spec.license = "MIT"
|
10
|
+
|
11
|
+
spec.files = `git ls-files`.split($/)
|
12
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
13
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
|
16
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
17
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Fluent
|
2
|
+
class ElasticsearchTimestampCheckFilter < Filter
|
3
|
+
Fluent::Plugin.register_filter('elasticsearch_timestamp_check', self)
|
4
|
+
|
5
|
+
def configure(conf)
|
6
|
+
super
|
7
|
+
require 'date'
|
8
|
+
end
|
9
|
+
|
10
|
+
def start
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def shutdown
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
def filter(tag, time, record)
|
19
|
+
existing = record['timestamp'] || record['@timestamp']
|
20
|
+
if existing
|
21
|
+
record['@timestamp'] =
|
22
|
+
DateTime.parse(existing).strftime('%Y-%m-%dT%H:%M:%S%z')
|
23
|
+
record['fluent_converted_timestamp'] =
|
24
|
+
DateTime.parse(existing).strftime('%Y-%m-%dT%H:%M:%S%z')
|
25
|
+
$log.debug("Timestamp parsed: #{record['@timestamp']}")
|
26
|
+
else
|
27
|
+
record['@timestamp'] = Time.now.strftime('%Y-%m-%dT%H:%M:%S%z')
|
28
|
+
record['fluent_added_timestamp'] =
|
29
|
+
Time.now.strftime('%Y-%m-%dT%H:%M:%S%z')
|
30
|
+
$log.debug("Timestamp added: #{record['@timestamp']}")
|
31
|
+
end
|
32
|
+
record
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-elasticsearch-timestamp-check
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Richard Li
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
description: fluent filter plugin to ensure @timestamp is in proper format
|
28
|
+
email:
|
29
|
+
- evilcat@wisewolfsolutions.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- LICENSE
|
36
|
+
- README.md
|
37
|
+
- fluent-plugin-elasticsearch-timestamp-check.gemspec
|
38
|
+
- lib/fluent/plugin/filter_elasticsearch_timestamp_check.rb
|
39
|
+
homepage: https://github.com/ecwws/fluent-plugin-elasticsearch-timestamp-check
|
40
|
+
licenses:
|
41
|
+
- MIT
|
42
|
+
metadata: {}
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
requirements: []
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 2.2.2
|
60
|
+
signing_key:
|
61
|
+
specification_version: 4
|
62
|
+
summary: fluent timestamp checker filter
|
63
|
+
test_files: []
|
64
|
+
has_rdoc:
|