Refer to documentation below, it stated that:
You may encounter the following errors if your config file fails these checks:
Exiting: error loading config file: config file ("{beatname}.yml") must be owned by the beat user (uid=501) or root
To correct this problem you can use either
chown root {beatname}.yml
orchown 501 {beatname}.yml
to change the owner of the configuration file.