logstash-filter-cache 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 909dcb096518a55347b4391ccdbc8cb2eccb9339
4
+ data.tar.gz: dddb405a4a719286a63085b1852656ad58b06e8c
5
+ SHA512:
6
+ metadata.gz: fdabb6f0b88142013da4037b5f3a72393202f9cbcbf3a4a6c5d4663a10124104e87e7d12b6ba527746feefab5d2d7ac33eb21442c064d0270bc5365828a58241
7
+ data.tar.gz: 1085d4cb41ada8863af80770e9049d37e79d928f588632e014c9d3ef86144c389adc5d4738a6d60da4ff0b1c8db5474bb62b1fc8538f2ef282fbf411eb3cafea
@@ -0,0 +1,5 @@
1
+ ## 2.0.0
2
+ - Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
3
+ instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
4
+ - Dependency on logstash-core update to 2.0
5
+
@@ -0,0 +1,11 @@
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
+ * Aaron Mildenstein (untergeek)
6
+ * Pier-Hugues Pellerin (ph)
7
+
8
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
9
+ Logstash, and you aren't on the list above and want to be, please let us know
10
+ and we'll make sure you're here. Contributions from folks like you are what make
11
+ open source awesome.
@@ -0,0 +1,2 @@
1
+ # logstash-filter-example
2
+ Example filter plugin. This should help bootstrap your effort to write your own filter plugin!
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012–2015 Elasticsearch <http://www.elastic.co>
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.
@@ -0,0 +1,5 @@
1
+ Elasticsearch
2
+ Copyright 2012-2015 Elasticsearch
3
+
4
+ This product includes software developed by The Apache Software
5
+ Foundation (http://www.apache.org/).
@@ -0,0 +1,23 @@
1
+ # Logstash Filter Cache
2
+
3
+ This filter provide a cache where you can store data.
4
+
5
+ ## Installation
6
+ ```sh
7
+ bin/plugin install logstash-filter-cache
8
+ ```
9
+
10
+ ## Usage
11
+
12
+ ```javascript
13
+
14
+ ```
15
+
16
+ ## Example
17
+
18
+ ```sh
19
+ bin/logstash -e 'input { stdin {} } filter { sequence { field => "sequence" } } output {stdout { codec => rubydebug }}' -w 1
20
+ Default settings used: Filter workers: 1
21
+ Logstash startup completed
22
+
23
+ ```
@@ -0,0 +1,62 @@
1
+ # encoding: utf-8
2
+ require "logstash/filters/base"
3
+ require "logstash/namespace"
4
+
5
+ # This filter provide a cache where you can store data.
6
+ #
7
+ class LogStash::Filters::Cache < LogStash::Filters::Base
8
+
9
+ # The config looks like this:
10
+ #
11
+ # filter {
12
+ # cache {
13
+ # key => "YYYY"
14
+ # value => "XXXX"
15
+ # get => "boolean"
16
+ # field => "ZZZZZ"
17
+ # }
18
+ # }
19
+ #
20
+ # The `field` is the field you want added to the event.
21
+ config_name "cache"
22
+
23
+ # This filter needs to keep state.
24
+ @@cachetab = Hash.new
25
+
26
+ # The key for the data you want to store or retrieve
27
+ config :key, :validate => :string, :required => true
28
+
29
+ # The value for the data you want to store or retrieve
30
+ config :value, :validate => :string, :required => false
31
+
32
+ # Sets the action. If set to true, it will get the data from cache
33
+ config :get, :validate => :boolean, :default => false
34
+
35
+ # The field where the value be set for get => "true"
36
+ config :field, :validate => :string, :required => false, :default => "cache_value"
37
+
38
+ public
39
+ def register
40
+ # Nothing
41
+ @threadsafe = false
42
+ end # def register
43
+
44
+ public
45
+ def filter(event)
46
+ if @get
47
+ event[@field] = @@cachetab[@key]
48
+ if event[@field] == nil
49
+ event["tags"] ||= []
50
+ event["tags"] << "cache_miss" unless event["tags"].include?("cache_miss")
51
+ else
52
+ # filter_matched should go in the last line of our successful code
53
+ filter_matched(event)
54
+ end
55
+ else
56
+ @@cachetab[@key]= event.sprintf(@value)
57
+ # filter_matched should go in the last line of our successful code
58
+ filter_matched(event)
59
+ end
60
+
61
+ end # def filter
62
+ end # class LogStash::Filters::Cache
@@ -0,0 +1,23 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-filter-cache'
3
+ s.version = '0.1.0'
4
+ s.licenses = ['Apache License (2.0)']
5
+ s.summary = "This filter provide a cache where you can store data."
6
+ s.description = "This filter provide a cache where you can store data. 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"
7
+ s.authors = ["Elastic, apenvern"]
8
+ s.email = 'info@elastic.co'
9
+ s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
10
+ s.require_paths = ["lib"]
11
+
12
+ # Files
13
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
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" => "filter" }
19
+
20
+ # Gem dependencies
21
+ s.add_runtime_dependency "logstash-core", ">= 2.0.0", "< 3.0.0"
22
+ s.add_development_dependency 'logstash-devutils'
23
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require "logstash/filters/example"
4
+
5
+ describe LogStash::Filters::Cache do
6
+ describe "Add a sequence number to a log entry do"
7
+ let(:config) do <<-CONFIG
8
+ filter {
9
+ sequence {
10
+ field => "sequence"
11
+ }
12
+ }
13
+ CONFIG
14
+ end
15
+
16
+ sample("field" => "seq_field") do
17
+ expect(subject).to include("seq_field")
18
+ end
19
+ end
20
+ end
21
+
@@ -0,0 +1,2 @@
1
+ # encoding: utf-8
2
+ require "logstash/devutils/rspec/spec_helper"
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-filter-cache
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Elastic, apenvern
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-19 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.0.0
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.0.0
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: '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 filter provide a cache where you can store data. 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: info@elastic.co
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - CHANGELOG.md
54
+ - CONTRIBUTORS
55
+ - DEVELOPER.md
56
+ - Gemfile
57
+ - LICENSE
58
+ - NOTICE.TXT
59
+ - README.md
60
+ - lib/logstash/filters/cache.rb
61
+ - logstash-filter-cache.gemspec
62
+ - spec/filters/cache_spec.rb
63
+ - spec/spec_helper.rb
64
+ homepage: http://www.elastic.co/guide/en/logstash/current/index.html
65
+ licenses:
66
+ - Apache License (2.0)
67
+ metadata:
68
+ logstash_plugin: 'true'
69
+ logstash_group: filter
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.4.8
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: This filter provide a cache where you can store data.
90
+ test_files:
91
+ - spec/filters/cache_spec.rb
92
+ - spec/spec_helper.rb