Skip to content

Commit

Permalink
add option
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkpc138 committed Oct 10, 2024
1 parent a9739df commit 5ae59f2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
31 changes: 17 additions & 14 deletions pkg/lobster/distributor/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ import (
)

type config struct {
StdstreamLogRootPath *string
EmptyDirLogRootPath *string
FileInspectInterval *time.Duration
FileInspectMaxStale *time.Duration
TailFileMaxStale *time.Duration
MatchLookbackMin *time.Duration
MetricsInterval *time.Duration
StdstreamLogRootPath *string
EmptyDirLogRootPath *string
FileInspectInterval *time.Duration
FileInspectMaxStale *time.Duration
TailFileMaxStale *time.Duration
MatchLookbackMin *time.Duration
MetricsInterval *time.Duration
ShouldUpdateLogMatcher *bool
}

func setup() config {
Expand All @@ -39,14 +40,16 @@ func setup() config {
tailFileMaxStale := flag.Duration("distributor.tailFileMaxStale", 5*time.Second, "Decide how old files to look up to tailing")
matchLookbackMin := flag.Duration("distributor.matchLookbackMin", 10*time.Second, "Determine how old the logs will be in metrics")
metricsInterval := flag.Duration("distributor.metricsInterval", 5*time.Second, "metrics production interval")
shouldUpdateLogMatcher := flag.Bool("distributor.shouldUpdateLogMatcher", false, "When using the log sink function, set it to true for periodic log sink rule update")

return config{
StdstreamLogRootPath: stdstreamLogRootPath,
EmptyDirLogRootPath: emptyDirLogRootPath,
FileInspectInterval: fileInspectInterval,
FileInspectMaxStale: fileInspectMaxStale,
TailFileMaxStale: tailFileMaxStale,
MatchLookbackMin: matchLookbackMin,
MetricsInterval: metricsInterval,
StdstreamLogRootPath: stdstreamLogRootPath,
EmptyDirLogRootPath: emptyDirLogRootPath,
FileInspectInterval: fileInspectInterval,
FileInspectMaxStale: fileInspectMaxStale,
TailFileMaxStale: tailFileMaxStale,
MatchLookbackMin: matchLookbackMin,
MetricsInterval: metricsInterval,
ShouldUpdateLogMatcher: shouldUpdateLogMatcher,
}
}
9 changes: 6 additions & 3 deletions pkg/lobster/distributor/distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,13 @@ func (d *Distributor) Run(stopChan chan struct{}) {
fileMap := d.extractFileMap(logfiles, *conf.FileInspectMaxStale)
tailList := d.extractTailList(fileMap, *conf.TailFileMaxStale)

now := time.Now()
if err := d.matcher.Update(helper.FilterChunksByExistingPods(d.store.GetChunks(), podMap), now.Add(-*conf.FileInspectInterval), now); err != nil {
glog.Error(err)
if *conf.ShouldUpdateLogMatcher {
now := time.Now()
if err := d.matcher.Update(helper.FilterChunksByExistingPods(d.store.GetChunks(), podMap), now.Add(-*conf.FileInspectInterval), now); err != nil {
glog.Error(err)
}
}

d.storeFiles(fileMap)
d.tailFiles(tailList, stopChan)

Expand Down

0 comments on commit 5ae59f2

Please sign in to comment.