I have installed Syslog-ng 3.25, the server is working and I can save data in mongo db without a problem, but I want to customize the destination of data depending on some properties, like source IP, and date, so for every day the server will save logs in a new location.
I defined the destination like this
destination d_pppoedb {
mongodb(
uri("mongodb://localhost:27017/syslog")
collection("${HOST}${YEAR}${MONTH}${DAY}")
persist-name(d_pppoedb)
);
};
but it seems the macros are not working, as no new collection has been created in my MongoDB then I tried with save logs to file using this
destination d_file {
file("/var/log/${YEAR}.${MONTH}.${DAY}/${HOST}.log");
};
but it same, no new file has been created, why macros are not working. when I set the destination as a static value, it is working and save logs without any problem but it does not want to work with macros
The mongodb()
destination currently does not support macros in its collection()
option. You can open a feature request on GitHub, if you want to see that in a future release.
Your second example, however, should work as expected. In case ${YEAR}.${MONTH}.${DAY}
directories do not exist, you should add the create-dirs(yes)
option as well.