Skip to content

Exclude non parsed data points #26

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 6 additions & 2 deletions lib/logstash/outputs/influxdb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class LogStash::Outputs::InfluxDB < LogStash::Outputs::Base
# otherwise sprintf-filtered numeric values could get sent as strings
# format is `{'column_name' => 'datatype'}`
#
# currently supported datatypes are `integer` and `float`
# Currently supported datatypes are `integer` and `float`
# Supports sprintf-formatting in column names.
#
config :coerce_values, :validate => :hash, :default => {}

Expand Down Expand Up @@ -128,6 +129,8 @@ def receive(event)
event_hash['name'] = event.sprintf(@series)

sprintf_points = Hash[@data_points.map {|k,v| [event.sprintf(k), event.sprintf(v)]}]
sprintf_points.delete_if{|_, v| v[0] == "%"}

if sprintf_points.has_key?('time')
unless @allow_time_override
logger.error("Cannot override value of time without 'allow_time_override'. Using event timestamp")
Expand All @@ -138,6 +141,7 @@ def receive(event)
end

@coerce_values.each do |column, value_type|
column = event.sprintf(column)
if sprintf_points.has_key?(column)
begin
case value_type
Expand Down Expand Up @@ -176,7 +180,7 @@ def flush(events, teardown = false)
begin
if seen_series.has_key?(ev['name']) and (seen_series[ev['name']] == ev['columns'])
@logger.info("Existing series data found. Appending points to that series")
event_collection.select {|h| h['points'] << ev['points'][0] if h['name'] == ev['name']}
event_collection.select {|h| h['points'] << ev['points'][0] if h['columns'] == ev['columns']}
elsif seen_series.has_key?(ev['name']) and (seen_series[ev['name']] != ev['columns'])
@logger.warn("Series '#{ev['name']}' has been seen but columns are different or in a different order. Adding to batch but not under existing series")
@logger.warn("Existing series columns were: #{seen_series[ev['name']].join(",")} and event columns were: #{ev['columns'].join(",")}")
Expand Down