forked from elastic/logstash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
- Loading branch information
Showing
30 changed files
with
889 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
require "logstash/config/file" | ||
require "clamp" | ||
|
||
class LogStash::Agent2 < Clamp::Command | ||
option ["-f", "--config"], "CONFIG_PATH", | ||
"Load the logstash config from a specific file or directory. " \ | ||
"If a direcory is given, all files in that directory will " \ | ||
"be concatonated in lexicographical order and then parsed as " \ | ||
"a single config file. You can also specify wildcards (globs)" \ | ||
"and any matched files will be loaded in the order described above", | ||
:attribute_name => :config_path | ||
|
||
option "-e", "CONFIG_STRING", | ||
"Use the given string as the configuration data. Same syntax as " \ | ||
"the config file. If not input is specified, then " \ | ||
"'stdin { type => stdin }' is the default input. If no output is " \ | ||
"specified, then 'stdout { debug => true }}' is default output.", | ||
:attribute_name => :config_string | ||
|
||
option ["-w", "--filterworkers"], "COUNT", | ||
"Sets the number of filter workers to run.", | ||
:attribute_name => :filter_workers, :default => 1, &:to_i | ||
|
||
option "--watchdog-timeout", "SECONDS", | ||
"Set the filter watchdog timeout (in seconds). This timeout is used" \ | ||
" to detect stuck filters; stuck filters usually symptoms of bugs. " \ | ||
"When a filter takes longer than TIMEOUT seconds, it will cause " \ | ||
"logstash to abort.", :default => 10, &:to_f | ||
|
||
option ["-l", "--log"], "FILE", | ||
"Write logstash internal logs to the given file. Without this flag, " \ | ||
"logstash will emit logs to standard output." | ||
|
||
verbosity = 0 | ||
option "-v", :flag, "Increase verbosity of logstash internal logs. " \ | ||
"Specifying once will show 'informational' logs. Specifying twice " \ | ||
"will show 'debug' logs.", :attribute_name => :verbosity do | ||
verbosity += 1 | ||
end | ||
|
||
option ["-V", "--version"], :flag, | ||
"Emit the version of logstash and its friends" do | ||
# TODO(sissel): This should emit the version of JRuby and ElasticSearch as | ||
# well. Perhaps also the versions of all gems? | ||
require "logstash/version" | ||
puts "logstash #{LOGSTASH_VERSION}" | ||
exit(0) | ||
end | ||
|
||
plugin_paths = [] | ||
option ["-p", "--pluginpath"] , "PATH", | ||
"A colon-delimited path of where to find plugins. Plugins are expected " \ | ||
"to be in a specific directory hierarchy: PATH/logstash/TYPE/NAME.rb - " \ | ||
"where TYPE is 'input' 'filter' or 'output' and NAME is the name of the" \ | ||
"plugin.", :attribute_name => :plugin_path do |value| | ||
plugin_paths << value unless plugin_paths.include?(value) | ||
end | ||
|
||
def execute | ||
end # def execute | ||
end # class LogStash::Agent2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
require "logstash/filters/base" | ||
require "logstash/namespace" | ||
|
||
# Originally written to translate HTTP response codes | ||
# but turned into a general translation tool which uses | ||
# .yaml files as a dictionary. | ||
# response codes in default dictionary were scraped from | ||
# 'gem install cheat; cheat status_codes' | ||
|
||
class LogStash::Filters::Translate < LogStash::Filters::Base | ||
config_name "translate" | ||
plugin_status "experimental" | ||
|
||
|
||
# The field containing a response code If this field is an | ||
# array, only the first value will be used. | ||
config :field, :validate => :string, :required => true | ||
|
||
# name with full path of external dictionary file. | ||
# format of the table should be a YAML file. | ||
# make sure you encase any integer based keys in quotes. | ||
# For simple string search and replacements for just a few values | ||
# use the gsub function of the mutate filter. | ||
config :dictionary_path, :validate => :string, :required => true | ||
|
||
# The destination you wish to populate with the response code. | ||
# default is http_response_code. set to the same value as source | ||
# if you want to do a substitution. | ||
config :destination, :validate => :string, :default => "translation" | ||
|
||
# set to false if you want to match multiple terms. | ||
# a large dictionary could get expensive if set to false. | ||
config :exact, :validate => :boolean, :default => true | ||
|
||
|
||
|
||
public | ||
def register | ||
if File.exists?(@dictionary_path) | ||
begin | ||
@dictionary = YAML.load_file(@dictionary_path) | ||
rescue Exception => e | ||
raise "Bad Syntax in dictionary file" | ||
end | ||
end # if File.exists? | ||
@logger.info("Dictionary - ", :dictionary => @dictionary) | ||
if @exact | ||
@logger.info("Dictionary translation method - Exact") | ||
else | ||
@logger.info("Dictionary translation method - Fuzzy") | ||
end # if @exact | ||
end # def register | ||
|
||
public | ||
def filter(event) | ||
return unless filter?(event) | ||
begin | ||
source = event[@field] | ||
source = source.first if source.is_a? Array # if array, just use first value | ||
source = source.to_s # make sure its a string. Is this really needed? | ||
if @exact | ||
translation = @dictionary[source] if @dictionary.include?(source) | ||
else | ||
translation = source.gsub(Regexp.union(@dictionary.keys), @dictionary) | ||
end # if @exact | ||
rescue Exception => e | ||
@logger.error("Something went wrong when attempting to translate from dictionary", :exception => e, :field => @field, :event => event) | ||
end | ||
event[@destination] = translation | ||
end # def filter | ||
end # class LogStash::Filters::Translate |
Oops, something went wrong.