logstash-filter-truncate 1.0.0 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68f37db86bda4de74978902b01f9dcd4628d7525
4
- data.tar.gz: 3ac1b4f08c99a5d167302fa828868c1a524925b2
3
+ metadata.gz: 7cf39e6a114d7a4009db9ecd95141f257ebe0b07
4
+ data.tar.gz: e52131367130d3af6a7ebf1e7922015a989047c6
5
5
  SHA512:
6
- metadata.gz: 5559123d9bcf737271ff90147864bafd0d97568bed99893253400aa219ee43262f204366d7a1e248d2f4c277f6754bd0bda35a0897649cc6fc889199216abef8
7
- data.tar.gz: b5ef11bb6b6be7aa2a2263b9af4ffe9cf0869fdf001b6581b0a9230d233578b17d6a7c534f33600941d47d62cfca00b0ec80b994ad333a30f08d74d599798d09
6
+ metadata.gz: 250aea4f5f329c99e402d9a9dc787e89dc2d89ce6aab956a028de67cb7e9420873f41a465b0cf01d9847c8f77cd5a02ecbea3985e04c9eb3f47f2fed059fe31c
7
+ data.tar.gz: 1c817cec96009a69ba17c787da917cc15778b32dcacfb87665cc6dd36d54940271854bee4ee252da6f8d6a1539ad64b22e7546c2c11f633bef2bd74919e339b5
data/CHANGELOG.md CHANGED
@@ -1 +1,6 @@
1
+ ## 1.0.1
2
+ - Method filter_matched wasn't being called after truncate #2
3
+
4
+ ## 1.0.0
5
+
1
6
  ## 0.0.1
data/Gemfile CHANGED
@@ -1,3 +1,11 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ logstash_path = ENV["LOGSTASH_PATH"] || "../../logstash"
6
+ use_logstash_source = ENV["LOGSTASH_SOURCE"] && ENV["LOGSTASH_SOURCE"].to_s == "1"
7
+
8
+ if Dir.exist?(logstash_path) && use_logstash_source
9
+ gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
10
+ gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
11
+ end
@@ -0,0 +1,84 @@
1
+ :plugin: truncate
2
+ :type: filter
3
+
4
+ ///////////////////////////////////////////
5
+ START - GENERATED VARIABLES, DO NOT EDIT!
6
+ ///////////////////////////////////////////
7
+ :version: %VERSION%
8
+ :release_date: %RELEASE_DATE%
9
+ :changelog_url: %CHANGELOG_URL%
10
+ :include_path: ../../../../logstash/docs/include
11
+ ///////////////////////////////////////////
12
+ END - GENERATED VARIABLES, DO NOT EDIT!
13
+ ///////////////////////////////////////////
14
+
15
+ [id="plugins-{type}-{plugin}"]
16
+
17
+ === Truncate filter plugin
18
+
19
+ include::{include_path}/plugin_header.asciidoc[]
20
+
21
+ ==== Description
22
+
23
+ Allows you to truncate fields longer than a given length.
24
+
25
+ This truncates on bytes values, not character count. In practice, this
26
+ should mean that the truncated length is somewhere between `length_bytes` and
27
+ `length_bytes - 6` (UTF-8 supports up to 6-byte characters).
28
+
29
+ [id="plugins-{type}s-{plugin}-options"]
30
+ ==== Truncate Filter Configuration Options
31
+
32
+ This plugin supports the following configuration options plus the <<plugins-{type}s-{plugin}-common-options>> described later.
33
+
34
+ [cols="<,<,<",options="header",]
35
+ |=======================================================================
36
+ |Setting |Input type|Required
37
+ | <<plugins-{type}s-{plugin}-fields>> |<<string,string>>|No
38
+ | <<plugins-{type}s-{plugin}-length_bytes>> |<<number,number>>|Yes
39
+ |=======================================================================
40
+
41
+ Also see <<plugins-{type}s-{plugin}-common-options>> for a list of options supported by all
42
+ filter plugins.
43
+
44
+ &nbsp;
45
+
46
+ [id="plugins-{type}s-{plugin}-fields"]
47
+ ===== `fields`
48
+
49
+ * Value type is <<string,string>>
50
+ * There is no default value for this setting.
51
+
52
+ A list of fieldrefs to truncate if they are too long.
53
+
54
+ If not specified, the default behavior will be to attempt truncation on all
55
+ strings in the event. This default behavior could be computationally
56
+ expensive, so if you know exactly which fields you wish to truncate, it is
57
+ advised that you be specific and configure the fields you want truncated.
58
+
59
+ Special behaviors for non-string fields:
60
+
61
+ * Numbers: No action
62
+ * Array: this plugin will attempt truncation on all elements of that array.
63
+ * Hash: truncate will try all values of the hash (recursively, if this hash
64
+ contains other hashes).
65
+
66
+ [id="plugins-{type}s-{plugin}-length_bytes"]
67
+ ===== `length_bytes`
68
+
69
+ * This is a required setting.
70
+ * Value type is <<number,number>>
71
+ * There is no default value for this setting.
72
+
73
+ Fields over this length will be truncated to this length.
74
+
75
+ Truncation happens from the end of the text (the start will be kept).
76
+
77
+ As an example, if you set `length_bytes => 10` and a field contains "hello
78
+ world, how are you?", then this field will be truncated and have this value:
79
+ "hello worl"
80
+
81
+
82
+
83
+ [id="plugins-{type}s-{plugin}-common-options"]
84
+ include::{include_path}/{type}.asciidoc[]
@@ -46,6 +46,7 @@ class LogStash::Filters::Truncate < LogStash::Filters::Base
46
46
  else
47
47
  Truncator.truncate_all(event, @length_bytes)
48
48
  end
49
+ filter_matched(event)
49
50
  end
50
51
 
51
52
  module Truncator
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-truncate'
4
- s.version = '1.0.0'
4
+ s.version = '1.0.2'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "This filter allows you to truncate fields to a given length."
7
7
  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"
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.require_paths = ["lib"]
12
12
 
13
13
  # Files
14
- s.files = Dir['lib/**/*','spec/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
14
+ s.files = Dir["lib/**/*","spec/**/*","*.gemspec","*.md","CONTRIBUTORS","Gemfile","LICENSE","NOTICE.TXT", "vendor/jar-dependencies/**/*.jar", "vendor/jar-dependencies/**/*.rb", "VERSION", "docs/**/*"]
15
15
 
16
16
  # Tests
17
17
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
@@ -84,6 +84,14 @@ describe LogStash::Filters::Truncate do
84
84
  end
85
85
  end
86
86
  end
87
- end
88
87
 
88
+ describe "calling of filter_matched" do
89
+ subject { described_class.new("length_bytes" => 1, "fields" => [ "example" ]) }
90
+ let(:event) { LogStash::Event.new("example" => 1000) }
89
91
 
92
+ it "should be called" do
93
+ expect(subject).to receive(:filter_matched).once
94
+ subject.filter(event)
95
+ end
96
+ end
97
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-truncate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-29 00:00:00.000000000 Z
11
+ date: 2017-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -70,6 +70,7 @@ files:
70
70
  - LICENSE
71
71
  - NOTICE.TXT
72
72
  - README.md
73
+ - docs/index.asciidoc
73
74
  - lib/logstash/filters/truncate.rb
74
75
  - logstash-filter-truncate.gemspec
75
76
  - spec/filters/truncate_spec.rb