Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can now retrieve fields from event #104

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions lib/logstash/outputs/influxdb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ class LogStash::Outputs::InfluxDB < LogStash::Outputs::Base
#
# Events for the same series will be batched together where possible
# Both keys and values support sprintf formatting
config :data_points, :validate => :hash, :default => {}, :required => true
config :data_points, :validate => :hash, :default => {}

# Do not use data_points. Use keys / values found in event instead.
config :columns_from_event_fields, :validate => :boolean, :default => true

# Ignore some columns if they are setted
config :ignore_columns, :validate => :array, :default => []

# Allow the override of the `time` column in the event?
#
Expand Down Expand Up @@ -126,12 +132,21 @@ def receive(event)
# ]
event_hash = {}
event_hash['name'] = event.sprintf(@series)
sprintf_points = Hash[@data_points.map {|k,v| [event.sprintf(k), event.sprintf(v)]}]
if !@columns_from_event_fields
sprintf_points = Hash[@data_points.map {|k,v| [event.sprintf(k), event.sprintf(v)]}]
else
sprintf_points = event.to_hash
end
if sprintf_points.has_key?('time')
@logger.error("Cannot override value of time without 'allow_override_time'. Using event timestamp") unless @allow_override_time
else
sprintf_points['time'] = to_epoch(event.timestamp)
end
@ignore_columns.each do |field|
if sprintf_points.has_key?(field)
sprintf_points.delete(field)
end
end
@coerce_values.each do |column, value_type|
if sprintf_points.has_key?(column)
begin
Expand Down