-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
log: Log File size limit and Log rotation for fluent-bit logs #1890
base: master
Are you sure you want to change the base?
Conversation
90b8135
to
8e96609
Compare
1c30efa
to
040815f
Compare
src/flb_log.c
Outdated
int ret = -1; | ||
|
||
if (log->max_history == 0) { | ||
//no backups. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use /* ... */ for comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
src/flb_log.c
Outdated
} | ||
|
||
//max 2 digits for backup name suffix and 1 each for '.' and '\0'. | ||
backup_file_name = flb_malloc(strlen(log->out) + 4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set the malloc size in a variable before malloc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
src/flb_log.c
Outdated
} | ||
src_file_name = flb_malloc(strlen(log->out) + 4); | ||
if (!src_file_name) { | ||
perror("malloc"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flb_errno();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
src/flb_log.c
Outdated
} | ||
|
||
for (int l = log->max_history; l > 1; l--) { | ||
sprintf(backup_file_name, "%s.%d", log->out, l); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use snprintf instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
157f164
to
b09402c
Compare
1cbd281
to
1b8bcc8
Compare
@edsiper , kindly let me know if you have any further suggestions. |
@edsiper , please let me know if this PR still makes sense and are there any plans to merge this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for this PR.
I added some minor change requests before to get this merged we need to sort out two things:
- rebase on top of GIT master
- all I/O functions must work on Linux and Windows, .eg: remove(3) is not valid on windows
1b8bcc8
to
bf6b108
Compare
Kindly let me know if the changes look fine now. If you have any more suggestions please do let me know. Also should I use "log" or "engine" in the commit message? |
You may need a rebase to solve the fuzzing failures but the unit tests also need resolving. There seems to be quite a few failures which will prevent merging. |
5bc5fb3
to
a202f2c
Compare
@patrick-stephens , I have rebased and fixed UT failures. Can you please let me know what should be the commit message? I guess the 1 failure is due to component missing in commit message. |
Yeah you need it in the format: |
Signed-off-by: Pradeep Hiremande <[email protected]>
@patrick-stephens both ideally |
@patrick-stephens When will this PR merge into the master branch? |
Apologies I've had little time to look at this so far but will endeavour to soon. |
Hi Team, |
Apologies, I've still not tested this yet. |
Hi team, |
Any update on this one, I think it would be very valuable to have predictable log sizes for fluent bit itself. |
Hey @phiremande, are you going to finish this PR? I can continue to work on it as I really need these changes. |
Hey everyone, I'm grateful for the work that has already been carried out on this issue. Is there an update as to when the changes will be merged? |
It needs rebasing and updating so if you pick it up @hcdmonitor it may speed things up. |
} | ||
|
||
/* max 2 digits for backup name suffix and 1 each for '.' and '\0' */ | ||
size_t filename_len = strlen(log->out) + 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this expected here?
size_t filename_len = strlen(log->out) + 4; | |
size_t filename_len = snprintf(NULL, 0, "%"PRIu64, log->out); |
} | ||
src_file_name = flb_malloc(filename_len); | ||
if (!src_file_name) { | ||
flb_errno(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this expected here?
flb_errno(); | |
flb_free(backup_file_name); | |
flb_errno(); |
Hello everyone, |
Hello, any news about this feature ? it is fundamental |
This is a very basic feature. We cannot go live with a component that will almost guarantee and outage eventually, due to filling the disk. Is there any progress? |
It may be easier with a new PR, you can generate the patch for this one by just adding a For everyone asking about log rotate, typically I would do this separately via |
Hello, any news about this feature? I really need that (on my Windows machines) :-) |
Currently fluent-bit logs can be redirected to a file using Log_File.
But there is no configuration option to limit the size of the file. Additionally, there is no log rotation that can be enabled for fluent-bit logs.
These might be useful when we want to collect fluent-bit process logs itself and also to debug.
Added new configuration parameters:
Log_File_Size - Size limit in MB for the file specified by Log_File.
Log_File_History - Max number of backups to be kept.
These backups are kept as <Log_File>.1, <Log_File>.2 etc.
Sample configuration.
[SERVICE]
Flush 1
Daemon Off
Log_Level debug
Log_File ./fb_log.log
Log_File_Size 1
Log_File_History 2
This PR has the corresponding changes.