Skip to content

Commit

Permalink
feat: move detected field logic to query frontend (#14212)
Browse files Browse the repository at this point in the history
(cherry picked from commit 36ace66)
  • Loading branch information
trevorwhitney authored and grafana-delivery-bot[bot] committed Sep 24, 2024
1 parent 7e7172f commit 071b04a
Show file tree
Hide file tree
Showing 5 changed files with 1,653 additions and 1,049 deletions.
28 changes: 1 addition & 27 deletions pkg/querier/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,7 @@ func containsAllIDTypes(values []string) bool {
return true
}

// TODO(twhitney): Delete this method and the GRPC service signature. This is now handled in the query frontend.
func (q *SingleTenantQuerier) DetectedFields(ctx context.Context, req *logproto.DetectedFieldsRequest) (*logproto.DetectedFieldsResponse, error) {
expr, err := syntax.ParseLogSelector(req.Query, true)
if err != nil {
Expand Down Expand Up @@ -1134,33 +1135,6 @@ func (q *SingleTenantQuerier) DetectedFields(ctx context.Context, req *logproto.
}, nil
}

func getParsersFromExpr(expr syntax.LogSelectorExpr) []string {
parsers := make([]string, 0)
expr.Walk(func(e syntax.Expr) {
switch concrete := e.(type) {
case *syntax.LogfmtParserExpr, *syntax.LogfmtExpressionParser:
if !slices.Contains(parsers, "logfmt") {
parsers = append(parsers, "logfmt")
}
case *syntax.JSONExpressionParser:
if !slices.Contains(parsers, "json") {
parsers = append(parsers, "json")
}
case *syntax.LabelParserExpr:
if concrete.Op == syntax.OpParserTypeJSON {
if !slices.Contains(parsers, "json") {
parsers = append(parsers, "json")
}
}
}
// bail if we found both parsers
if len(parsers) == 2 {
return
}
})
return parsers
}

type parsedFields struct {
sketch *hyperloglog.Sketch
fieldType logproto.DetectedFieldType
Expand Down
Loading

0 comments on commit 071b04a

Please sign in to comment.