My Suricata 6.0 is running in a Docker container. It works perfectly but i have a problem with the logrotate.
The first time, it works perfectly. The file eve.json-20201128 has been created and a new eve.json has
been created too and this new file is filled correctly
The second times, the file eve.json-20201129 has been created with a new eve.json.
The problem is that the eve.json remains at zero and the old file eve.json-2020112 is filled
I have tried a lot of configuration and it’s the same every time
Something else you can also do is start suricata with -vvv. Its not a good log message, but you should see this everytime suricatasc -c reopen-log-files is executed:
30/11/2020 -- 21:20:39 - <Info> - Unix socket: lost connection with client
which just means that the suricatasc client has disconnected.
Perhaps the problem occurs after a certain period of operation.
I will type your commands when it doesn’t work anymore and I will give you the results
This morning I have the problem.
What is strange is that the expected result is not that of my logrotate file
In my suricata file, i want to compress the files. When i force the logrotate, it works. This night, it didn’t work. There was no compression and in addition there is a date in the name of the file.
This night, new files have been created like eve.json, which does not fill and eve.json-20201201 which is filled. My old eve.json has become eve.json-20201201and keep filling up and the new eve.json remains at 0
I believe this removes a possible race condition between rotating the log file, and Suricata re-opening the log files, but it means the most recently rotated log file is not compressed until the next cycle. But its obviously a common enough scenario that logrotate supports this case.
I’m not sure to understand what you meant by : Are you mixing Suricata’s support for time based rotation with logrotate by any chance? Easy to see if you post that section of your config.
Currently, I wanted to manage the logrotate from my host machine.
By reading your answer, I may have understood that it was necessary to manage the logrotate in the container.
So, I added it in and we’ll see if it works better.
I don’t know if that’s what you meant ?
Suricata has the ability to encode the date in the filename of the eve log. When you do this, it will open new log files as the date changes. This is not the default, but I was just checking, as generally if you enable this feature, logrotate is not going to do well.
You should be able to logrotate from the host just fine. Make sure you volume mount the directory, and not just the filename and you should be good. The idea is that logrotate moves the files out of the way to their new name then sends the signal to Suricata somehow, in case of a container the command you used is probably the best.
Yeah, that should be fine. I have not run for extended periods of time in Docker recently and I don’t know of any issues myself. So best check the output when you see it in this state and report back.
After a few days of testing, I think I have found the solution to my problem. This is probably not the ideal solution but it seems to work fine.
I couldn’t get the logrotate to work on my host machine
I tried to install crond in my container under Alpine to run my logrotate in this one but I encountered a lot of problems.
Finally, I found a solution that currently works well after a few days of operation
I add logrotate in my docker image and I copied this suricata file in /etc/logrotate.d/ of my docker image.
This is a fine solution as well. I will be keeping my eye for your original attempt not working as well. But this does the rotate and the signal inside the container, so less chance of Docker getting in the way.