Skip to content

Commit f61c803

Browse files
Leonardo Alminanaedsiper
authored andcommitted
ain_tail: reintroduced the old ignore_older behavior as opt-in
Signed-off-by: Leonardo Alminana <[email protected]>
1 parent e2461d6 commit f61c803

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

plugins/in_tail/tail.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,12 @@ static struct flb_config_map config_map[] = {
655655
"only available when a Parser is specified and it can parse the time "
656656
"of a record."
657657
},
658+
{
659+
FLB_CONFIG_MAP_BOOL, "ignore_active_older_files", "false",
660+
0, FLB_TRUE, offsetof(struct flb_tail_config, ignore_active_older_files),
661+
"ignore files that are older than the value set in ignore_older even "
662+
"if the file is being ingested."
663+
},
658664
{
659665
FLB_CONFIG_MAP_SIZE, "buffer_chunk_size", FLB_TAIL_CHUNK,
660666
0, FLB_TRUE, offsetof(struct flb_tail_config, buf_chunk_size),

plugins/in_tail/tail_config.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ struct flb_tail_config {
8585
int read_from_head; /* read new files from head */
8686
int rotate_wait; /* sec to wait on rotated files */
8787
int watcher_interval; /* watcher interval */
88-
int ignore_older; /* ignore fields older than X seconds */
88+
int ignore_older; /* ignore fields older than X seconds */
89+
int ignore_active_older_files; /* ignore files that exceed the ignore
90+
* older limit even if they are already
91+
* being ingested */
8992
time_t last_pending; /* last time a 'pending signal' was emitted' */
9093
struct mk_list *path_list; /* list of paths to scan (glob) */
9194
flb_sds_t path_key; /* key name of file path */

plugins/in_tail/tail_file.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,6 +1914,7 @@ static int check_purge_deleted_file(struct flb_tail_config *ctx,
19141914
struct flb_tail_file *file, time_t ts)
19151915
{
19161916
int ret;
1917+
int64_t mtime;
19171918
struct stat st;
19181919

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

1941+
if (ctx->ignore_older > 0 && ctx->ignore_active_older_files) {
1942+
mtime = flb_tail_stat_mtime(&st);
1943+
if (mtime > 0) {
1944+
if ((ts - ctx->ignore_older) > mtime) {
1945+
flb_plg_debug(ctx->ins, "purge: monitored file (ignore older): %s",
1946+
file->name);
1947+
flb_tail_file_remove(file);
1948+
return FLB_TRUE;
1949+
}
1950+
}
1951+
}
1952+
19401953
return FLB_FALSE;
19411954
}
19421955

0 commit comments

Comments
 (0)