logstash-filter-languagedetect 0.0.1.pre.alpha.pre.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +6 -0
- data/.travis.yml +16 -0
- data/CHANGELOG.md +0 -0
- data/CONTRIBUTORS +11 -0
- data/DEVELOPER.md +2 -0
- data/Gemfile +4 -0
- data/LICENSE +13 -0
- data/README.md +86 -0
- data/Rakefile +1 -0
- data/lib/logstash/filters/languagedetect.rb +54 -0
- data/logstash-filter-languagedetect.gemspec +25 -0
- data/spec/filters/languagedetect_spec.rb +66 -0
- data/spec/spec_helper.rb +1 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MzdmZWM0OTlhZThlY2Q5MmQ2YmUyNzM1OTcwNWZkMzRkMzg2NTVjNQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OTc2NTRlM2Q5NjlkMTVkZTBiZGRkYmM2NWM4YWRkZjZkMWIzMmIwMg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ODQ5MGYzNTBkZmVmMmRlMjhkMzFjYmJlZWVjYTk4YmM0ZjUyMmEyOTk0NTk3
|
10
|
+
ZjMyYzRlNWEyMWQ3OGViYjViMzUzYjk5NTliMWYzMzliYTljZTE1MjZmMzYw
|
11
|
+
NDRhMGQyMDZmMGI2ZGQ2MzYxYzk1OTRiMTMwN2E4NTQzMjYxYjI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YzJhMzc1MDMyYjE5NDJjMDhkNjQ4ZDIzODgyMDYyNTg3OTc3MTcxYzUxNzkx
|
14
|
+
MmYwNWZlOTE4Y2QyZjQ0NzgyZmU2ZjBmNTQ2ZGMyN2EzYTk5MWI1Zjc4NjQw
|
15
|
+
MzBmNTNlYzQ5NDJjYTU1MGQ3NGFmZmFmZmViZDAzNTNmMDcwNDg=
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- jruby-1.7.20
|
4
|
+
# - jruby-19mode
|
5
|
+
# - jruby-head
|
6
|
+
#jdk:
|
7
|
+
# - openjdk7
|
8
|
+
# - oraclejdk7
|
9
|
+
# - oraclejdk8
|
10
|
+
before_install:
|
11
|
+
- gem install bundler -v 1.10.1
|
12
|
+
script: bundle exec rspec
|
13
|
+
deploy:
|
14
|
+
provider: rubygems
|
15
|
+
api_key:
|
16
|
+
secure: J3/E3dTIv1ZkCLLbDj0EJVh5toxHOACsqjTuoUjwnV0dc6GQsqhlgxxOebtOU+LMyO7WaXncPH9Yy3zYpI2G7hulOczGiF+9JG1SqysMg0RS5LX0lyZlE8UPb/C3ILKPAbMfyrp/dMhS+9M36p6ZOjtS2PMXVgAi/tUUvFEgXLmoi1yzfbG1Dy0JLOURPgLdKgXdV54VxxPb/V3YZXq2S0XVu5MTDQOJoblYJ6RyBfkFVcDoSFI3qBUD6m2xmw1qpv0rfiKEZmiImpTi1/jOIxBEIIARBi0X1RWM1p/mOcXxiWMpJ925crYftibd39acuAO2bIMiYyeevB76QhM4va+OlQ1/yHe85EibixH+kRL7Xd99j+Ouwdpa6m14M8NWFo2Lx3Rr99MjAYeDNMV++OBS3KBMmyAZIqA/sosAjnzMeZHFKRxRMdkZW1/AFHkXVcOFYIIGn83l0ciLBFpjRnDimBN2KVA6Alslu7+qPGEuQKTSEpVZF1uNui+tF1z/MgnllX1IMnNN4RODNbYKAUc+drL2nRit1QCnUAR7BYZ7Q4LcmcSmnGX2dPD1ovUSbiCNDbWCDecZAd2TFqbMn9Bgx9jHyNgfo4yEednDgrYmk1OGNExIunWJckirYBhYGDQN4Lv39Kb4Xyqe4jV35HvYVZIKBwnSyHIfwJykFeA=
|
data/CHANGELOG.md
ADDED
File without changes
|
data/CONTRIBUTORS
ADDED
@@ -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.
|
data/DEVELOPER.md
ADDED
data/Gemfile
ADDED
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.
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# Logstash Plugin
|
2
|
+
|
3
|
+
This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
|
4
|
+
|
5
|
+
It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
|
6
|
+
|
7
|
+
## Documentation
|
8
|
+
|
9
|
+
Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elasticsearch.org/guide/en/logstash/current/).
|
10
|
+
|
11
|
+
- For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
|
12
|
+
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elasticsearch/docs#asciidoc-guide
|
13
|
+
|
14
|
+
## Need Help?
|
15
|
+
|
16
|
+
Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
|
17
|
+
|
18
|
+
## Developing
|
19
|
+
|
20
|
+
### 1. Plugin Developement and Testing
|
21
|
+
|
22
|
+
#### Code
|
23
|
+
- To get started, you'll need JRuby with the Bundler gem installed.
|
24
|
+
|
25
|
+
- Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
|
26
|
+
|
27
|
+
- Install dependencies
|
28
|
+
```sh
|
29
|
+
bundle install
|
30
|
+
```
|
31
|
+
|
32
|
+
#### Test
|
33
|
+
|
34
|
+
- Update your dependencies
|
35
|
+
|
36
|
+
```sh
|
37
|
+
bundle install
|
38
|
+
```
|
39
|
+
|
40
|
+
- Run tests
|
41
|
+
|
42
|
+
```sh
|
43
|
+
bundle exec rspec
|
44
|
+
```
|
45
|
+
|
46
|
+
### 2. Running your unpublished Plugin in Logstash
|
47
|
+
|
48
|
+
#### 2.1 Run in a local Logstash clone
|
49
|
+
|
50
|
+
- Edit Logstash `Gemfile` and add the local plugin path, for example:
|
51
|
+
```ruby
|
52
|
+
gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
53
|
+
```
|
54
|
+
- Install plugin
|
55
|
+
```sh
|
56
|
+
bin/plugin install --no-verify
|
57
|
+
```
|
58
|
+
- Run Logstash with your plugin
|
59
|
+
```sh
|
60
|
+
bin/logstash -e 'filter {awesome {}}'
|
61
|
+
```
|
62
|
+
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
|
63
|
+
|
64
|
+
#### 2.2 Run in an installed Logstash
|
65
|
+
|
66
|
+
You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
|
67
|
+
|
68
|
+
- Build your plugin gem
|
69
|
+
```sh
|
70
|
+
gem build logstash-filter-awesome.gemspec
|
71
|
+
```
|
72
|
+
- Install the plugin from the Logstash home
|
73
|
+
```sh
|
74
|
+
bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
|
75
|
+
```
|
76
|
+
- Start Logstash and proceed to test the plugin
|
77
|
+
|
78
|
+
## Contributing
|
79
|
+
|
80
|
+
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
|
81
|
+
|
82
|
+
Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
|
83
|
+
|
84
|
+
It is more important to the community that you are able to contribute.
|
85
|
+
|
86
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "logstash/devutils/rake"
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/filters/base"
|
3
|
+
require "logstash/namespace"
|
4
|
+
require 'whatlanguage'
|
5
|
+
# require 'whatlanguage/string'
|
6
|
+
|
7
|
+
# This example filter will replace the contents of the default
|
8
|
+
# message field with whatever you specify in the configuration.
|
9
|
+
#
|
10
|
+
# It is only intended to be used as an example.
|
11
|
+
class LogStash::Filters::Languagedetect < LogStash::Filters::Base
|
12
|
+
|
13
|
+
# Setting the config_name here is required. This is how you
|
14
|
+
# configure this filter from your Logstash config.
|
15
|
+
#
|
16
|
+
# filter {
|
17
|
+
# example {
|
18
|
+
# message => "My message..."
|
19
|
+
# }
|
20
|
+
# }
|
21
|
+
#
|
22
|
+
config_name "languagedetect"
|
23
|
+
|
24
|
+
# Replace the message with this value.
|
25
|
+
config :source, :validate => :string, :default => "message"
|
26
|
+
|
27
|
+
config :target, :validate => :string, :default => "lang"
|
28
|
+
|
29
|
+
config :useiso, :validate => :boolean, :default => false
|
30
|
+
|
31
|
+
|
32
|
+
public
|
33
|
+
def register
|
34
|
+
@wl = WhatLanguage.new(:all)
|
35
|
+
end # def register
|
36
|
+
|
37
|
+
public
|
38
|
+
def filter(event)
|
39
|
+
|
40
|
+
text_to_detect = event[@source]
|
41
|
+
if @useiso
|
42
|
+
lang_found = @wl.language_iso(text_to_detect)
|
43
|
+
# lang_found = text_to_detect.language_iso
|
44
|
+
else
|
45
|
+
lang_found = @wl.language(text_to_detect)
|
46
|
+
# lang_found = text_to_detect.language
|
47
|
+
end
|
48
|
+
|
49
|
+
event[@target] = lang_found
|
50
|
+
|
51
|
+
# filter_matched should go in the last line of our successful code
|
52
|
+
filter_matched(event)
|
53
|
+
end # def filter
|
54
|
+
end # class LogStash::Filters::Languagedetect
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'logstash-filter-languagedetect'
|
3
|
+
s.version = '0.0.1'
|
4
|
+
s.version = "#{s.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS']
|
5
|
+
s.licenses = ['Apache License (2.0)']
|
6
|
+
s.summary = "This example filter replaces the contents of the message field with the specified value."
|
7
|
+
s.description = "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"
|
8
|
+
s.authors = ["Torsten Feld"]
|
9
|
+
s.email = 'logstash@torsten-feld.de'
|
10
|
+
s.homepage = "https://github.com/torstenfeld/logstash-filter-languagedetect"
|
11
|
+
s.require_paths = ["lib"]
|
12
|
+
|
13
|
+
# Files
|
14
|
+
s.files = `git ls-files`.split($\)
|
15
|
+
# Tests
|
16
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
17
|
+
|
18
|
+
# Special flag to let us know this is actually a logstash plugin
|
19
|
+
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
|
20
|
+
|
21
|
+
# Gem dependencies
|
22
|
+
s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
|
23
|
+
s.add_runtime_dependency "whatlanguage", '>= 1.0.6'
|
24
|
+
s.add_development_dependency 'logstash-devutils'
|
25
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.absolute_path(File.join(File.dirname(__FILE__), '../../spec/spec_helper'))
|
3
|
+
require File.absolute_path(File.join(File.dirname(__FILE__), '../../lib/logstash/filters/languagedetect'))
|
4
|
+
# require "lib/logstash/filters/languagedetect"
|
5
|
+
|
6
|
+
describe LogStash::Filters::Languagedetect do
|
7
|
+
describe "with defaults and non iso languages" do
|
8
|
+
let(:config) do <<-CONFIG
|
9
|
+
filter {
|
10
|
+
languagedetect {}
|
11
|
+
}
|
12
|
+
CONFIG
|
13
|
+
end
|
14
|
+
|
15
|
+
sample("message" => "The links between the attempted car bombings in Glasgow and London are becoming clearer") do
|
16
|
+
expect(subject).to include('lang')
|
17
|
+
expect(subject['lang']).to eq(:english)
|
18
|
+
end
|
19
|
+
|
20
|
+
sample("message" => "dies ist ein deutscher Text") do
|
21
|
+
expect(subject).to include('lang')
|
22
|
+
expect(subject['lang']).to eq(:german)
|
23
|
+
end
|
24
|
+
|
25
|
+
sample("message" => "Deux autres personnes ont été arrêtées durant la nuit") do
|
26
|
+
expect(subject).to include('lang')
|
27
|
+
expect(subject['lang']).to eq(:french)
|
28
|
+
end
|
29
|
+
|
30
|
+
sample("message" => "En estado de máxima alertaen su nivel de crítico") do
|
31
|
+
expect(subject).to include('lang')
|
32
|
+
expect(subject['lang']).to eq(:spanish)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "with iso languages" do
|
37
|
+
let(:config) do <<-CONFIG
|
38
|
+
filter {
|
39
|
+
languagedetect {
|
40
|
+
useiso => true
|
41
|
+
}
|
42
|
+
}
|
43
|
+
CONFIG
|
44
|
+
end
|
45
|
+
|
46
|
+
sample("message" => "The links between the attempted car bombings in Glasgow and London are becoming clearer") do
|
47
|
+
expect(subject).to include('lang')
|
48
|
+
expect(subject['lang']).to eq(:en)
|
49
|
+
end
|
50
|
+
|
51
|
+
sample("message" => "dies ist ein deutscher Text") do
|
52
|
+
expect(subject).to include('lang')
|
53
|
+
expect(subject['lang']).to eq(:de)
|
54
|
+
end
|
55
|
+
|
56
|
+
sample("message" => "Deux autres personnes ont été arrêtées durant la nuit") do
|
57
|
+
expect(subject).to include('lang')
|
58
|
+
expect(subject['lang']).to eq(:fr)
|
59
|
+
end
|
60
|
+
|
61
|
+
sample("message" => "En estado de máxima alertaen su nivel de crítico") do
|
62
|
+
expect(subject).to include('lang')
|
63
|
+
expect(subject['lang']).to eq(:es)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "logstash/devutils/rspec/spec_helper"
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-filter-languagedetect
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.pre.alpha.pre.12
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Torsten Feld
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: logstash-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.4.0
|
20
|
+
- - <
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.0.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.4.0
|
30
|
+
- - <
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.0.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: whatlanguage
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 1.0.6
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.0.6
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: logstash-devutils
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
description: This gem is a logstash plugin required to be installed on top of the
|
62
|
+
Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not
|
63
|
+
a stand-alone program
|
64
|
+
email: logstash@torsten-feld.de
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- .travis.yml
|
71
|
+
- CHANGELOG.md
|
72
|
+
- CONTRIBUTORS
|
73
|
+
- DEVELOPER.md
|
74
|
+
- Gemfile
|
75
|
+
- LICENSE
|
76
|
+
- README.md
|
77
|
+
- Rakefile
|
78
|
+
- lib/logstash/filters/languagedetect.rb
|
79
|
+
- logstash-filter-languagedetect.gemspec
|
80
|
+
- spec/filters/languagedetect_spec.rb
|
81
|
+
- spec/spec_helper.rb
|
82
|
+
homepage: https://github.com/torstenfeld/logstash-filter-languagedetect
|
83
|
+
licenses:
|
84
|
+
- Apache License (2.0)
|
85
|
+
metadata:
|
86
|
+
logstash_plugin: 'true'
|
87
|
+
logstash_group: filter
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ! '>'
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.3.1
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.4.5
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: This example filter replaces the contents of the message field with the specified
|
108
|
+
value.
|
109
|
+
test_files:
|
110
|
+
- spec/filters/languagedetect_spec.rb
|
111
|
+
- spec/spec_helper.rb
|