diff --git a/lib/logstash/outputs/influxdb.rb b/lib/logstash/outputs/influxdb.rb index 183997c3..e5ff9e1f 100644 --- a/lib/logstash/outputs/influxdb.rb +++ b/lib/logstash/outputs/influxdb.rb @@ -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? # @@ -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