Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions plugins/in_tail/tail.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,11 @@ static struct flb_config_map config_map[] = {
"Set one or multiple shell patterns separated by commas to exclude "
"files matching a certain criteria, e.g: 'exclude_path *.gz,*.zip'"
},
{
FLB_CONFIG_MAP_BOOL, "ignore_unavailable", "false",
0, FLB_TRUE, offsetof(struct flb_tail_config, ignore_unavailable),
"Do not search directories that do not exist for files."
},
{
FLB_CONFIG_MAP_STR, "key", "log",
0, FLB_TRUE, offsetof(struct flb_tail_config, key),
Expand Down
1 change: 1 addition & 0 deletions plugins/in_tail/tail_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ struct flb_tail_config {
long refresh_interval_nsec;/* nanoseconds to re-scan */
int read_newly_discovered_files_from_head; /* read new files from head after startup */
int read_from_head; /* read new files from head */
int ignore_unavailable; /* ignore unavailable paths during scanning */
int rotate_wait; /* sec to wait on rotated files */
int watcher_interval; /* watcher interval */
int ignore_older; /* ignore fields older than X seconds */
Expand Down
8 changes: 4 additions & 4 deletions plugins/in_tail/tail_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ int flb_tail_scan(struct mk_list *path_list, struct flb_tail_config *ctx)
mk_list_foreach(head, path_list) {
pattern = mk_list_entry(head, struct flb_slist_entry, _head);
ret = tail_scan_path(pattern->str, ctx);
if (ret == -1) {
flb_plg_warn(ctx->ins, "error scanning path: %s", pattern->str);
}
else {
if (ret != -1) {
flb_plg_debug(ctx->ins, "%i new files found on path '%s'",
ret, pattern->str);
}
else if (!ctx->ignore_unavailable) {
flb_plg_warn(ctx->ins, "error scanning path: %s", pattern->str);
}
}

return 0;
Expand Down
20 changes: 17 additions & 3 deletions plugins/in_tail/tail_scan_glob.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ static inline int do_glob(const char *pattern, int flags,
return ret;
}


/* Scan a path, register the entries and return how many */
static int tail_scan_path(const char *path, struct flb_tail_config *ctx)
{
Expand Down Expand Up @@ -212,12 +211,27 @@ static int tail_scan_path(const char *path, struct flb_tail_config *ctx)
flb_plg_error(ctx->ins, "no memory space available");
return -1;
case GLOB_ABORTED:
flb_plg_error(ctx->ins, "read error, check permissions: %s", path);
if (errno == EACCES) {
flb_plg_error(ctx->ins, "No read access for path: %s", path);
} else if (errno == ENOENT || errno == ENOTDIR) {
if (!ctx->ignore_unavailable) {
flb_plg_error(ctx->ins, "%s at path: %s",
(errno == ENOENT) ? "No such file" : "Not a directory",
path);
}
} else {
flb_plg_error(ctx->ins, "Unable to scan path (system error: %s): %s",
strerror(errno), path);
}
return -1;
case GLOB_NOMATCH:
ret = stat(path, &st);
if (ret == -1) {
flb_plg_debug(ctx->ins, "cannot read info from: %s", path);
if (errno == ENOTDIR && !ctx->ignore_unavailable) {
flb_plg_error(ctx->ins, "Not a directory at path: %s", path);
} else {
flb_plg_debug(ctx->ins, "cannot read info from: %s", path);
}
}
else {
ret = access(path, R_OK);
Expand Down