however inspite of setting it as env variable getting following error
CRIT Exiting: error loading states for prospector 0: missing field accessing 'filebeat.prospectors.0.fields.clustername' (source:'/home/cloud-user/rohsing2/testfilebeat/filebeat-5.6.1-linux-x86_64/prospectors/audit-filebeat.yml')
Can you please be more detailed in describing how you have things setup and what commands you are running. Based on what you have described, I was not able to reproduce the issue. See below.
It's not the same. You used sudo which does not preserve the environment for security purposes.
When you get to the point of running Filebeat as a service you will be using systemd. When a service starts it receives a clean environment (just like when you used sudo). For systemd you need to configure an override file with the environment data for the service. You can let systemd create the override file for you by running:
systemctl edit filebeat.service
Then configure the overrides for the service.
[Service]
Environment=CLUSTER_NAME=lokitest
You can use EnvironmentFile= if you want to point to a file with the environment variables.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.