Filebeat config - USER system env variable

Hello, i am trying read logs from currently logged user folder. In filebeat config i have:
- /home/${USERNAME}/logs/foo.log, this does not even compile. But it work when i hardcode name like this:
- /home/${USERNAME:foo}/logs/foo.log, but i need this path to be dynamically allocated.

There are no logs in /var/log/filebeat/filebeat.log

Hi Johny,

Welcome to the discuss forum.
Now if you give out the environment variables on a linux system:

env | grep USER | sort

I think you should find out that the variable should be USER. Variable USERNAME only exists on Windows systems as far as I know.

- /home/${USER}/logs/foo.log

Apart from that I would like to know what exactly you are trying to accomplish.
Do you want to u read dynamically through all your user folders?
Something like


and if you add a new user userc it should start to read this one /home/userc/logs/foo.log as well?

If this what you want to do?

Because with that at the moment I assume it will log only one folder.

Hello and thank you for your reply.
Use case is... When userA start using program. It will creates:
Then second user loggin to the machine and it will creates new logs in:
I need filebeat config that automatically assign variables of currently logged users to the path:
/var/log/app-{USER}/foo.log, so I don't have to manualy set up and hardcode users to each machine.
I can tail path like this /var/log/app- * /*.log. But it's not look like the best practice. Besides this logs everything.

To find user variable I used env command and when i use it in cd path/to/{variable}/folder, it works fine.

Hi Johny,

maybe it is

Globbing depends on slashes like is documented here:

If you want you maybe could disable recursive globbing:

So basically it the actual best practice like that:

- type: log
  recursive_glob.enabled: false
    - /var/log/program-*/foo.log

Now apart from that let my try to tackle your last comment
If I understand you correctly you maybe have following paths like e.g.:


And what you want is automatically identify the first 2 paths as being paths from users john and Jessy and it should ingest these ones, but not the third one, which is not a user?

Is this exactly what you are trying to do?

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