clockwork icon indicating copy to clipboard operation
clockwork copied to clipboard

Collecting json with filebeat, missing end of line

Open JConseil opened this issue 2 years ago • 1 comments

Hello, We are collecting all Clockwork's json files thanks to filebeat and we push them to ElasticSearch. It allows us to use Graylog for consulting all what we have collected with Clockwork.

As Clockwork is writting a new file for every request instead of writting a new line in the same and unique log file (like monolog), filebeat wasn't able to understand that the file content is ready to be collected and pushed to ElasticSearch.

Filebeat requires an "end of line" to detect that the line is written and won't change. Then only will filebeat collect the line and keeps watching the new line. (It works well with multineline logs like with monolog).

The system works fine only when we override the method store from \Clockwork\Storage\FileStorage.

$this->compress
			? file_put_contents("{$path}.gz", gzcompress($data))
			: file_put_contents($path, $data);

becomes

$this->compress
			? file_put_contents("{$path}.gz", gzcompress($data))
			: file_put_contents($path, $data . "\n");

Could it be possible to permanently add it to the original class ?

Julien

JConseil avatar Oct 09 '23 12:10 JConseil

Hey, sure, I don't see why not. Would you like to make a PR?

itsgoingd avatar Oct 09 '23 22:10 itsgoingd

Included in Clockwork 5.2.

itsgoingd avatar Feb 21 '24 20:02 itsgoingd