Windows Environment Variables not accessible when Logstash is run as a service

I have used Windows environment variables in Logstash config file. Following command was used to create env variable:
$env:MW_Index = 'mw-test-index-temp'

In my config file, I have called this index.
mutate { add_field => { "[@metadata][target_index]" => "${MW_INDEX}" } }

Now, when I run the Logstash from command line, it works fine but running it as a service does not ingest data. Following command is being used to run it as a service:
Start-Service -name logstash

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