I am looking to see if there is a way to use regex and local.file_match to only send spefic logs to loki?
Basically, i have a folder that has many files in it of logs. each log would be DataFeeds_todays date.log
So, it would look something like this DataFeed_2025-05-16.log
There would be one for everyday but i am only interested in the current day’s logs. so tomorrow log I would be interested in tomorrow which would be called. DataFeed_2025-05-17.log and so forth. This this possible to do or am I SOL?
Something like this:
local.file_match "local" {
path_targets = [{__path__ ="D:/ServiceLogs/DataFeedsService/^DataFeeds_[0-9]*.log"},]
}
I am not sure you can do that. your options might be
- generate the alloy config file daily through an external process that will plugin today’s file name in the config file (oogly)
- have a today folder and point to that (cleaner but you might not have control of where files get dumped to)
D:/ServiceLogs/DataFeedsService/Today/DataFeed_2025-05-16.log
- archive older files to an archive folder
D:/ServiceLogs/DataFeedsService/Archives
only leaving today’s file untouched in root folder D:/ServiceLogs/DataFeedsService/DataFeed_2025-05-16.log
Thats a little upsetting. Ya my next option was to basically have the person who building this data to change it around a bit.
- change the current file to be named: DataFeed.log and the older files to be labeled with the date stamp.
- do as you suggested and have the old files archived out so only the current days file is in the folder
- just use a different system to accomplish this task
Thanks for the help and info.
1 Like
i was also trying to figure out is the argument older than ignore_older_than would work.
But whatever syntex i out in there doesn’t seem to work. Like 1d, 24hr, 24h, 5m, 5min etc.
local.file_match "local" {
path_targets = [{__path__ ="D:/ServiceLogs/DataFeedsService/*.log"},
ignore_older_than = "1d"]
}
1 Like
if you go with DataFeed.log
I don’t think you will need archives
ignore_older_than = "24h"