Skip to content

Commit

Permalink
log query compatiblity for source=deploy (#3073) (#3077)
Browse files Browse the repository at this point in the history
Co-authored-by: RecallSong <13607438+recallsong@users.noreply.github.com>
  • Loading branch information
erda-bot and recallsong authored Nov 16, 2021
1 parent 81a71d6 commit f486181
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions modules/core/monitor/log/storage/elasticsearch/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ func (p *provider) Iterator(ctx context.Context, sel *storage.Selector) (storeki
func getSearchSource(start, end int64, sel *storage.Selector) *elastic.SearchSource {
searchSource := elastic.NewSearchSource()
query := elastic.NewBoolQuery().Filter(elastic.NewRangeQuery("timestamp").Gte(start).Lt(end))

// compatiblity for source=deploy
isContainer := true
for _, filter := range sel.Filters {
if filter.Key != "source" {
continue
}
if val, ok := filter.Value.(string); ok && val != "container" {
isContainer = false
}
}

for _, filter := range sel.Filters {
val, ok := filter.Value.(string)
if !ok {
Expand All @@ -126,6 +138,10 @@ func getSearchSource(start, end int64, sel *storage.Selector) *elastic.SearchSou
continue
}
}
// compatiblity for source=deploy, ignore tags filters
if !isContainer && strings.HasPrefix(filter.Key, "tags.") {
continue
}
switch filter.Op {
case storage.EQ:
query = query.Filter(elastic.NewTermQuery(filter.Key, val))
Expand Down

0 comments on commit f486181

Please sign in to comment.