mtail icon indicating copy to clipboard operation
mtail copied to clipboard

'??' glob pattern not working in recent versions for --logs argument

Open alecz20 opened this issue 2 years ago • 1 comments

'??' glob pattern for --logs argument used to work (in v3.0.0-rc36) but stopped working in recent versions.

I have the following log files:

/var/log/my_prog/my_prog.log.20220419_14
/var/log/my_prog/my_prog.log.20220419_15

I am starting the latest build of mtail with the following arguments: /tmp/mtail.rc48 -port 12345 -progs /etc/mtail/my-progs/ -logtostderr -disable_fsnotify -logs '/var/log/my_prog/my_prog.log.*_??'

Mtail does not tail the files:

runtime.go:188] Loaded program sockets.mtail
runtime.go:84] unmarking sockets.mtail
mtail.go:126] Listening on [::]:12345

If I start it with: /tmp/mtail.rc48 -port 12345 -progs /etc/mtail/my-progs/ -logtostderr -disable_fsnotify -logs '/var/log/my_prog/my_prog.log.*_[0-9][0-9]' It tails the files:

runtime.go:188] Loaded program sockets.mtail
runtime.go:84] unmarking sockets.mtail
logstream.go:61] Parsed url as /var/log/my_prog/my_prog.log.20220419_14
tail.go:287] Tailing /var/log/my_prog/my_prog.log.20220419_14
logstream.go:61] Parsed url as /var/log/my_prog/my_prog.log.20220419_15
tail.go:287] Tailing /var/log/my_prog/my_prog.log.20220419_15
mtail.go:126] Listening on [::]:12345

the -logs '/var/log/my_prog/my_prog.log.*_??' argument works in version v3.0.0-rc36, so I think this bug was introduced in a new version.

Moreover, according to https://google.github.io/mtail/Deploying.html,

--logs is a comma separated list of filenames to extract from, but can also be used multiple times, and each filename can be a glob pattern.

And the glob pattern documentation says:

'?' matches any single non-Separator character

So I expect the glob pattern matching to work as it used to in v3.0.0-rc36

alecz20 avatar Apr 19 '22 20:04 alecz20

Thanks for the report! Looks like there was a regression; IIRC the log discovery code was rewritten after rc36 and this feature got lost. I'll add a test for the specific behaviour and get it back.

jaqx0r avatar Jan 01 '23 06:01 jaqx0r

Unit Test Results

    1 files     27 suites   9m 10s :stopwatch:   649 tests   648 :white_check_mark: 1 :zzz: 0 :x: 1 920 runs  1 917 :white_check_mark: 3 :zzz: 0 :x:

Results for commit 1a2dd042.

github-actions[bot] avatar Apr 23 '24 05:04 github-actions[bot]