Skip to content

Commit

Permalink
in_tail: reintroduced the old ignore_older behavior as opt-in
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Alminana <[email protected]>
  • Loading branch information
leonardo-albertovich committed Dec 20, 2024
1 parent 44a2d0d commit 5167a30
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
6 changes: 6 additions & 0 deletions plugins/in_tail/tail.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,12 @@ static struct flb_config_map config_map[] = {
"only available when a Parser is specified and it can parse the time "
"of a record."
},
{
FLB_CONFIG_MAP_BOOL, "ignore_active_older_files", "false",
0, FLB_TRUE, offsetof(struct flb_tail_config, ignore_active_older_files),
"ignore files that are older than the value set in ignore_older even "
"if the file is being ingested."
},
{
FLB_CONFIG_MAP_SIZE, "buffer_chunk_size", FLB_TAIL_CHUNK,
0, FLB_TRUE, offsetof(struct flb_tail_config, buf_chunk_size),
Expand Down
5 changes: 4 additions & 1 deletion plugins/in_tail/tail_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ struct flb_tail_config {
int read_from_head; /* read new files from head */
int rotate_wait; /* sec to wait on rotated files */
int watcher_interval; /* watcher interval */
int ignore_older; /* ignore fields older than X seconds */
int ignore_older; /* ignore fields older than X seconds */
int ignore_active_older_files; /* ignore files that exceed the ignore
* older limit even if they are already
* being ingested */
time_t last_pending; /* last time a 'pending signal' was emitted' */
struct mk_list *path_list; /* list of paths to scan (glob) */
flb_sds_t path_key; /* key name of file path */
Expand Down
13 changes: 13 additions & 0 deletions plugins/in_tail/tail_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1914,6 +1914,7 @@ static int check_purge_deleted_file(struct flb_tail_config *ctx,
struct flb_tail_file *file, time_t ts)
{
int ret;
int64_t mtime;
struct stat st;

ret = fstat(file->fd, &st);
Expand All @@ -1937,6 +1938,18 @@ static int check_purge_deleted_file(struct flb_tail_config *ctx,
return FLB_TRUE;
}

if (ctx->ignore_older > 0 && ctx->ignore_active_older_files) {
mtime = flb_tail_stat_mtime(&st);
if (mtime > 0) {
if ((ts - ctx->ignore_older) > mtime) {
flb_plg_debug(ctx->ins, "purge: monitored file (ignore older): %s",
file->name);
flb_tail_file_remove(file);
return FLB_TRUE;
}
}
}

return FLB_FALSE;
}

Expand Down

0 comments on commit 5167a30

Please sign in to comment.