How to change the value of environment variable?

input {
stdin{
	type => "${log_type:unknown}"
}
}

tried these and does not work
ruby{
code =>"event.set('[@metadata][log_type]','Atype')"
}

ruby{
code =>"$log_type = 'Atype'"
}

using logstash 5.0.0-alpha4

Why do you want to change an environment variable from inside Logstash? What's the underlying problem you want to solve, i.e. what you are trying to accomplish in the end?

I am trying to archive auto detection on log type
using existing patterns to test first 100 logs, which determine the log type it should use
and then parse all the log

I doubt type => "${log_type:unknown}" is evaluated for each message so even if you'd be able to change the environment it might not work, but if you want to try it out the Ruby code would probably be ENV['log_type'] = 'Atype'.