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

Database name setting does not support sprintf formating #82

Open
gdolata opened this issue Oct 22, 2018 · 0 comments · May be fixed by #87
Open

Database name setting does not support sprintf formating #82

gdolata opened this issue Oct 22, 2018 · 0 comments · May be fixed by #87

Comments

@gdolata
Copy link

gdolata commented Oct 22, 2018

First db variable gets sprintf-ed in line 179.

buffer_receive(event_hash, event.sprintf(@db))
end # def receive
def flush(events, database, teardown = false)
@logger.debug? and @logger.debug("Flushing #{events.size} events to #{database} - Teardown? #{teardown}")
dowrite(events, database)
end # def flush

But then original "@db", rather than sprintf-ed "database" variable is used in line 190.

def dowrite(events, database)
begin
@influxdbClient.write_points(events, @time_precision, @retention_policy, @db )
rescue InfluxDB::AuthenticationError => ae
@logger.warn("Authentication Error while writing to InfluxDB", :exception => ae)
rescue InfluxDB::ConnectionError => ce
@logger.warn("Connection Error while writing to InfluxDB", :exception => ce)
rescue Exception => e
@logger.warn("Non recoverable exception while writing to InfluxDB", :exception => e)
end
end

Correct code should look like this.

  def dowrite(events, database)
    begin
        @influxdbClient.write_points(events, @time_precision, @retention_policy, database  )
    rescue InfluxDB::AuthenticationError => ae
        @logger.warn("Authentication Error while writing to InfluxDB", :exception => ae)
    rescue InfluxDB::ConnectionError => ce 
        @logger.warn("Connection Error while writing to InfluxDB", :exception => ce)
    rescue Exception => e
        @logger.warn("Non recoverable exception while writing to InfluxDB", :exception => e)
    end
  end
mlaradji added a commit to mlaradji/logstash-output-influxdb that referenced this issue Jan 30, 2020
This resolves logstash-plugins#82. This change basically implements @gdolata's suggested change, which I have verified to be working on my setup.
@mlaradji mlaradji linked a pull request Jan 30, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants