Filebeat input paths don't read environment variables

I've got a simple prospector setup:

filebeat.prospectors:
   - input_type: log
     paths: 
        - '${REGISTRY_LOG_FILE_PATH:/tmp/fake.log}'
       # - /var/tmp/registry/registry.log
     type: ${FILEBEAT_TYPE}  

The REGISTRY_LOG_FILE_PATH is not read in, so it defaults to the fake.log. However, environment variables are read in fine anywhere else in the file, such as FILEBEAT_TYPE. I haven't been able to find any examples of an input path specified via Env. Vars, is this supported?

The docs (Environment variables | Beats Platform Reference [8.11] | Elastic) mention:

Environment variables usage in namespace and setting names are not supported.

Is the path considered part of a setting name or a namespace? My initial impression was that it should work as its a value for the input?

Hi!

I've just tested this and it worked for me with the same exact settings, could you please give more details on your filebeat version, os version and how you launch filebeat (with the env variable)?

Best regards

I''m using Filebeat 5.3.2 on MacOS 10.12.4.

I have the REGISTRY_LOG_FILE_PATH and FILEBEAT_TYPE set in my terminals environment. I launch Filebeat with sudo ./filebeat -e -c boundless-registry.yml -d "publish"

I think you have to add -E parameter to sudo, env vars are not carried over to filebeat with your current command:

     -E, --preserve-env
             Indicates to the security policy that the user wishes to preserve their existing environment vari‐
             ables.  The security policy may return an error if the user does not have permission to preserve
             the environment.

The -E flag solved the issue. This might be worth mentioning as a note in the Stating Filebeat docs.

Thank you

1 Like

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