Set variable in configuration file

Hi all !

Simply, is there some method in Logstash news versions to code a variable which can be used in input, filter and output sections ?
if so, how to code it ?



input {
 ... some code...
  add_field => {"yourvariable" => "values"} 

Another option is environment variables.

Thanks, but...

in my simple example below, it doesn't quite work! :frowning:

look at this :

input {
	file {
		 add_field => {"dbfile" => "reffile"}
		 sincedb_path => "D:/db_logstash/%{dbfile}.db"

After logstash exec, the file D:/db_logstash/%{dbfile}.db has been created !?

And not D:/db_logstash/reffile.db, as I wanted!
Maybe a syntax error? :thinking:

I think this is not support what you want.

Too bad :frowning:
Thanks for the heads up!

You cannot use a sprintf reference in an input configuration because at the time that the input configuration is compiled and processed there are no events, so there are no fields to reference.

The add_field option only takes effect one the input is configured and starts generating events.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.