Skip to content

Commit 60fda55

Browse files
committed
Added cleanup datastore module , which periodically cleans the datastore for log lines so that the process
doesn't run out of space
1 parent 234d079 commit 60fda55

File tree

114 files changed

+22296
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+22296
-3
lines changed

Gopkg.lock

Lines changed: 67 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/parser.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
"github.com/Songmu/axslogparser"
88
"github.com/hpcloud/tail"
9+
"github.com/prometheus/common/log"
910
)
1011

1112
type LogLine struct {
@@ -180,5 +181,27 @@ func sendStatsToAlerts(alertsCh chan AggregatedStats, aggregatedStats chan Aggre
180181
}
181182

182183
func cleanDataStore() {
183-
// TODO
184+
// lock datastore before cleaning
185+
dataStore.mutex.Lock()
186+
defer dataStore.mutex.Unlock()
187+
188+
// current epoch since expired
189+
now := time.Now()
190+
secs := now.Unix()
191+
192+
log.Infof("Starting to clean datastore .....")
193+
194+
// clean entries from the datastore whose time difference is greater than 2 minutes (130 seconds some extra buffer)
195+
// which is maximum duration data we need right now for alert
196+
for i, e := range dataStore.TimeStampsSorted {
197+
if secs-e <= 130 {
198+
break
199+
} else {
200+
delete(dataStore.RequestStatusStats, e)
201+
delete(dataStore.EndPointStats, e)
202+
delete(dataStore.TimeStampsDict, e)
203+
dataStore.TimeStampsSorted = append(dataStore.TimeStampsSorted[:i], dataStore.TimeStampsSorted[i+1])
204+
}
205+
}
206+
log.Info("Cleaning datastore done ....")
184207
}

vendor/github.com/alecthomas/template/LICENSE

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/alecthomas/template/README.md

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)