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.