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

Setting a database name from event fields doesn't work anymore #71

Open
reinhard-brandstaedter opened this issue Sep 8, 2017 · 2 comments

Comments

@reinhard-brandstaedter
Copy link

reinhard-brandstaedter commented Sep 8, 2017

Hi,

I was using a influxdb output configuration before I switched to 5.x where I configured the database name dynamically from a logstash event field:

output {
file {
	path => "/tmp/%{[project]}.logstash.out2"
}

influxdb {
	host => "influxdb"
	# to use a database that uses the project code
	db => "%{[project]}"
	allow_time_override => true
	measurement => "%{[businesstransaction]}"
	exclude_fields => [ "businesstransaction", "@timestamp", "@version", "sequence", "message", "type", "project", "location"]
	use_event_fields_for_data_points => true
}
}

This used to create a output file with the name of the field and also write to the database.
Now with 5.5. and the latest output plugin it seems that doesn't work anymore. The event field is present in the event and should be accessible, however it doesn't get resolved for setting the db property. The filename is still correct. I also tried with another filed (one that doesn't get excluded) - same story.

{"businesstransaction":"SOLR Requests","responseTime":"88.31740897893906","systemProfile":"y_Production","y_number_of_search_results":6.0,"serverName":"ip-192-168-111-200","project":"y_dyn","tags":["application","serverName","systemProfile"],"y_solr_query_invocation":2.0,"@timestamp":"2017-09-08T13:57:27.256Z","application":"B2C","y_solr_query_time":1.0,"time":"1504879047256"}

Not sure if that is a problem of logstash itself or of the output plugin. Logstash reports an error:

[WARN ][logstash.outputs.influxdb] Non recoverable exception while writing to InfluxDB {:exception=>#<InfluxDB::Error: {"error":"database not found: \"%{[project]}\""}

Any clue why this could happen?

@reinhard-brandstaedter
Copy link
Author

an here is the bug/reason for that:
@db needs to be database in the below code (will create a pull request)

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

@TheVastyDeep
Copy link

See also #79 and #82.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants