logstash-plugins / logstash-output-influxdb

Apache License 2.0
58 stars 77 forks source link

Database name setting does not support sprintf formating #82

Open gdolata opened 6 years ago

gdolata commented 6 years ago

First db variable gets sprintf-ed in line 179. https://github.com/logstash-plugins/logstash-output-influxdb/blob/288a3b5f8a54f8f9c79629701f2af773569dc87a/lib/logstash/outputs/influxdb.rb#L179-L186

But then original "@db", rather than sprintf-ed "database" variable is used in line 190. https://github.com/logstash-plugins/logstash-output-influxdb/blob/288a3b5f8a54f8f9c79629701f2af773569dc87a/lib/logstash/outputs/influxdb.rb#L188-L198

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