mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
Merge pull request #625 from jdve/date-overwrite
filters: date: add target option
This commit is contained in:
commit
bb6a4f9a7e
1 changed files with 7 additions and 2 deletions
|
@ -79,6 +79,10 @@ class LogStash::Filters::Date < LogStash::Filters::Base
|
|||
#
|
||||
config :match, :validate => :array, :default => []
|
||||
|
||||
# Store the matching timestamp into the given target field. If not provided,
|
||||
# default to updating the @timestamp field of the event.
|
||||
config :target, :validate => :string, :default => "@timestamp"
|
||||
|
||||
# LOGSTASH-34
|
||||
DATEPATTERNS = %w{ y d H m s S }
|
||||
|
||||
|
@ -208,12 +212,13 @@ class LogStash::Filters::Date < LogStash::Filters::Base
|
|||
|
||||
time = time.withZone(UTC)
|
||||
# Convert joda DateTime to a ruby Time
|
||||
event["@timestamp"] = Time.utc(
|
||||
event[@target] = Time.utc(
|
||||
time.getYear, time.getMonthOfYear, time.getDayOfMonth,
|
||||
time.getHourOfDay, time.getMinuteOfHour, time.getSecondOfMinute,
|
||||
time.getMillisOfSecond * 1000
|
||||
)
|
||||
@logger.debug? && @logger.debug("Date parsing done", :value => value, :timestamp => event["@timestamp"])
|
||||
|
||||
@logger.debug? && @logger.debug("Date parsing done", :value => value, :timestamp => event[@target])
|
||||
rescue StandardError, JavaException => e
|
||||
@logger.warn("Failed parsing date from field", :field => field,
|
||||
:value => value, :exception => e)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue