Logstash Keystore not working when running logstash as a service

Hi, I'm trying to store the hosts and the logstash_user password in a keystore in my logstash conf.d output. I have a Ubuntu 22 system. The keystore works perfectly fine with my testconfig when I run logstash like this, as root:

sudo /usr/share/logstash/bin/logstash --path.settings /etc/logstash -f /etc/logstash/test.conf

It also works like this:

sudo -u logstash /usr/share/logstash/bin/logstash --path.settings /etc/logstash -f /etc/logstash/test.conf

But when I run it as a service, I get the following error in the logstash-plain.log:

[2024-09-09T10:21:32,077][ERROR][logstash.agent ] Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:xxxxxxxxxx, :exception=>"Java::OrgLogstashSecretStore::SecretStoreException::LoadException", :message=>"Found a file at /etc/logstash/logstash.keystore, but it is not a valid Logstash keystore."

I stored my logstash keystore password in /etc/environment. I've tried creating the keystore as root and as the logstash user, both did work for running it manually, both didn't work for running it as a service. What am I missing?

1 Like

I realize 22 is not 14, but this might be worth looking at.

Thank you! It worked.