Skip to content

Commit

Permalink
[FileMetricsCollector]skip line which doesn't contain any metrics key…
Browse files Browse the repository at this point in the history
…words (#1018)
  • Loading branch information
sperlingxx authored and k8s-ci-robot committed Jan 17, 2020
1 parent 92759fd commit cfbd851
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,18 @@ func (d *FileMetricsCollector) parseLogs(logs []string, metrics []string, filter
metricRegList := getFilterRegexpList(filters)

for _, logline := range logs {
if logline == "" {
// skip line which doesn't contain any metrics keywords, avoiding unnecessary pattern match
isObjLine := false
for _, m := range metrics {
if strings.Contains(logline, m) {
isObjLine = true
break
}
}
if !isObjLine {
continue
}

timestamp := time.Time{}.UTC().Format(time.RFC3339)
ls := strings.SplitN(logline, " ", 2)
if len(ls) != 2 {
Expand Down

0 comments on commit cfbd851

Please sign in to comment.