Skip to content

Commit f21f374

Browse files
committed
Merge branch 'master' into 1.4.x
* master: correct email config hash options minor updates, submitting two PRs as one put the pencil to graphite touch up email doc
2 parents a1e7990 + b06679c commit f21f374

File tree

2 files changed

+69
-62
lines changed

2 files changed

+69
-62
lines changed

lib/logstash/outputs/email.rb

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,100 +2,104 @@
22
require "logstash/outputs/base"
33
require "logstash/namespace"
44

5-
# Send email when any event is received.
5+
# Send email when an output is received. Alternatively, you may include or
6+
# exclude the email output execution using conditionals.
67
class LogStash::Outputs::Email < LogStash::Outputs::Base
78

89
config_name "email"
910
milestone 1
1011

11-
# This setting is deprecated in favor of logstash's "conditionals" feature
12+
# This setting is deprecated in favor of Logstash's "conditionals" feature
1213
# If you were using this setting previously, please use conditionals instead.
1314
#
1415
# If you need help converting your older 'match' setting to a conditional,
1516
# I welcome you to join the #logstash irc channel on freenode or to email
1617
# the [email protected] mailling list and ask for help! :)
1718
config :match, :validate => :hash, :deprecated => true
1819

19-
# Who to send this email to?
20-
# A fully qualified email address to send to
20+
# The fully-qualified email address to send the email to.
2121
#
22-
# This field also accept a comma separated list of emails like
22+
# This field also accepts a comma-separated string of addresses, for example:
2323
2424
#
25-
# You can also use dynamic field from the event with the %{fieldname} syntax.
25+
# You can also use dynamic fields from the event with the %{fieldname} syntax.
2626
config :to, :validate => :string, :required => true
2727

28-
# The From setting for email - fully qualified email address for the From:
28+
# The fully-qualified email address for the From: field in the email.
2929
config :from, :validate => :string, :default => "[email protected]"
3030

31-
# The Reply-To setting for email - fully qualified email address is required
32-
# here.
31+
# The fully qualified email address for the Reply-To: field.
3332
config :replyto, :validate => :string
3433

35-
# Who to CC on this email?
34+
# The fully-qualified email address(es) to include as cc: address(es).
3635
#
37-
# See "to" setting for what is valid here.
36+
# This field also accepts a comma-separated string of addresses, for example:
37+
3838
config :cc, :validate => :string
3939

40-
# how to send email: either smtp or sendmail - default to 'smtp'
40+
# How Logstash should send the email, either via SMTP or by invoking sendmail.
4141
config :via, :validate => :string, :default => "smtp"
4242

43-
# the options to use:
44-
# smtp: address, port, enable_starttls_auto, user_name, password, authentication(bool), domain
45-
# sendmail: location, arguments
46-
# If you do not specify anything, you will get the following equivalent code set in
43+
# Specify the options to use:
44+
#
45+
# Via SMTP: smtpIporHost, port, domain, userName, password, authenticationType, starttls
46+
#
47+
# Via sendmail: location, arguments
48+
#
49+
# If you do not specify any `options`, you will get the following equivalent code set in
4750
# every new mail object:
4851
#
49-
# Mail.defaults do
50-
# delivery_method :smtp, { :address => "localhost",
51-
# :port => 25,
52-
# :domain => 'localhost.localdomain',
53-
# :user_name => nil,
54-
# :password => nil,
55-
# :authentication => nil,(plain, login and cram_md5)
56-
# :enable_starttls_auto => true }
52+
# Mail.defaults do
53+
# delivery_method :smtp, { :smtpIporHost => "localhost",
54+
# :port => 25,
55+
# :domain => 'localhost.localdomain',
56+
# :userName => nil,
57+
# :password => nil,
58+
# :authenticationType => nil,(plain, login and cram_md5)
59+
# :starttls => true }
5760
#
58-
# retriever_method :pop3, { :address => "localhost",
59-
# :port => 995,
60-
# :user_name => nil,
61-
# :password => nil,
62-
# :enable_ssl => true }
63-
# end
61+
# retriever_method :pop3, { :address => "localhost",
62+
# :port => 995,
63+
# :user_name => nil,
64+
# :password => nil,
65+
# :enable_ssl => true }
6466
#
65-
# Mail.delivery_method.new #=> Mail::SMTP instance
66-
# Mail.retriever_method.new #=> Mail::POP3 instance
67+
# Mail.delivery_method.new #=> Mail::SMTP instance
68+
# Mail.retriever_method.new #=> Mail::POP3 instance
69+
# end
6770
#
68-
# Each mail object inherits the default set in Mail.delivery_method, however, on
71+
# Each mail object inherits the defaults set in Mail.delivery_method. However, on
6972
# a per email basis, you can override the method:
7073
#
71-
# mail.delivery_method :sendmail
74+
# mail.delivery_method :sendmail
7275
#
7376
# Or you can override the method and pass in settings:
7477
#
75-
# mail.delivery_method :sendmail, { :address => 'some.host' }
78+
# mail.delivery_method :sendmail, { :address => 'some.host' }
7679
#
7780
# You can also just modify the settings:
7881
#
79-
# mail.delivery_settings = { :address => 'some.host' }
82+
# mail.delivery_settings = { :address => 'some.host' }
8083
#
81-
# The passed in hash is just merged against the defaults with +merge!+ and the result
82-
# assigned the mail object. So the above example will change only the :address value
83-
# of the global smtp_settings to be 'some.host', keeping all other values
84+
# The hash you supply is just merged against the defaults with "merge!" and the result
85+
# assigned to the mail object. For instance, the above example will change only the
86+
# `:address` value of the global `smtp_settings` to be 'some.host', retaining all other values.
8487
config :options, :validate => :hash, :default => {}
8588

86-
# subject for email
89+
# Subject: for the email.
8790
config :subject, :validate => :string, :default => ""
8891

89-
# body for email - just plain text
92+
# Body for the email - plain text only.
9093
config :body, :validate => :string, :default => ""
9194

92-
# body for email - can contain html markup
95+
# HTML Body for the email, which may contain HTML markup.
9396
config :htmlbody, :validate => :string, :default => ""
9497

95-
# attachments - has of name of file and file location
98+
# Attachments - specify the name(s) and location(s) of the files.
9699
config :attachments, :validate => :array, :default => []
97100

98-
# contenttype : for multipart messages, set the content type and/or charset of the html part
101+
# contenttype : for multipart messages, set the content-type and/or charset of the HTML part.
102+
# NOTE: this may not be functional (KH)
99103
config :contenttype, :validate => :string, :default => "text/html; charset=UTF-8"
100104

101105
public

lib/logstash/outputs/graphite.rb

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
require "socket"
55

66
# This output allows you to pull metrics from your logs and ship them to
7-
# graphite. Graphite is an open source tool for storing and graphing metrics.
7+
# Graphite. Graphite is an open source tool for storing and graphing metrics.
88
#
9-
# An example use case: At loggly, some of our applications emit aggregated
10-
# stats in the logs every 10 seconds. Using the grok filter and this output,
11-
# I can capture the metric values from the logs and emit them to graphite.
9+
# An example use case: Some applications emit aggregated stats in the logs
10+
# every 10 seconds. Using the grok filter and this output, it is possible to
11+
# capture the metric values from the logs and emit them to Graphite.
1212
class LogStash::Outputs::Graphite < LogStash::Outputs::Base
1313
config_name "graphite"
1414
milestone 2
@@ -18,46 +18,49 @@ class LogStash::Outputs::Graphite < LogStash::Outputs::Base
1818
DEFAULT_METRICS_FORMAT = "*"
1919
METRIC_PLACEHOLDER = "*"
2020

21-
# The address of the graphite server.
21+
# The hostname or IP address of the Graphite server.
2222
config :host, :validate => :string, :default => "localhost"
2323

24-
# The port to connect on your graphite server.
24+
# The port to connect to on the Graphite server.
2525
config :port, :validate => :number, :default => 2003
2626

27-
# Interval between reconnect attempts to Carbon
27+
# Interval between reconnect attempts to Carbon.
2828
config :reconnect_interval, :validate => :number, :default => 2
2929

30-
# Should metrics be resend on failure?
30+
# Should metrics be resent on failure?
3131
config :resend_on_failure, :validate => :boolean, :default => false
3232

3333
# The metric(s) to use. This supports dynamic strings like %{host}
3434
# for metric names and also for values. This is a hash field with key
35-
# of the metric name, value of the metric value. Example:
35+
# being the metric name, value being the metric value. Example:
3636
#
3737
# [ "%{host}/uptime", "%{uptime_1m}" ]
3838
#
3939
# The value will be coerced to a floating point value. Values which cannot be
40-
# coerced will zero (0)
40+
# coerced will be set to zero (0). You may use either `metrics` or `fields_are_metrics`,
41+
# but not both.
4142
config :metrics, :validate => :hash, :default => {}
4243

43-
# Indicate that the event @fields should be treated as metrics and will be sent as is to graphite
44+
# An array indicating that these event fields should be treated as metrics
45+
# and will be sent verbatim to Graphite. You may use either `fields_are_metrics`
46+
# or `metrics`, but not both.
4447
config :fields_are_metrics, :validate => :boolean, :default => false
4548

46-
# Include only regex matched metric names
49+
# Include only regex matched metric names.
4750
config :include_metrics, :validate => :array, :default => [ ".*" ]
4851

49-
# Exclude regex matched metric names, by default exclude unresolved %{field} strings
52+
# Exclude regex matched metric names, by default exclude unresolved %{field} strings.
5053
config :exclude_metrics, :validate => :array, :default => [ "%\{[^}]+\}" ]
5154

52-
# Enable debug output
55+
# Enable debug output.
5356
config :debug, :validate => :boolean, :default => false, :deprecated => "This setting was never used by this plugin. It will be removed soon."
5457

55-
# Defines format of the metric string. The placeholder '*' will be
58+
# Defines the format of the metric string. The placeholder '*' will be
5659
# replaced with the name of the actual metric.
5760
#
5861
# metrics_format => "foo.bar.*.sum"
5962
#
60-
# NOTE: If no metrics_format is defined the name of the metric will be used as fallback.
63+
# NOTE: If no metrics_format is defined, the name of the metric will be used as fallback.
6164
config :metrics_format, :validate => :string, :default => DEFAULT_METRICS_FORMAT
6265

6366
def register
@@ -74,7 +77,7 @@ def register
7477
end # def register
7578

7679
def connect
77-
# TODO(sissel): Test error cases. Catch exceptions. Find fortune and glory.
80+
# TODO(sissel): Test error cases. Catch exceptions. Find fortune and glory. Retire to yak farm.
7881
begin
7982
@socket = TCPSocket.new(@host, @port)
8083
rescue Errno::ECONNREFUSED => e
@@ -121,7 +124,7 @@ def receive(event)
121124
end
122125

123126
if messages.empty?
124-
@logger.debug("Message is empty, not sending anything to graphite", :messages => messages, :host => @host, :port => @port)
127+
@logger.debug("Message is empty, not sending anything to Graphite", :messages => messages, :host => @host, :port => @port)
125128
else
126129
message = messages.join("\n")
127130
@logger.debug("Sending carbon messages", :messages => messages, :host => @host, :port => @port)

0 commit comments

Comments
 (0)