diff --git a/lib/logstorage/pipe_stats.go b/lib/logstorage/pipe_stats.go index bcf499d0e..e58d569c7 100644 --- a/lib/logstorage/pipe_stats.go +++ b/lib/logstorage/pipe_stats.go @@ -18,7 +18,7 @@ import ( // See https://docs.victoriametrics.com/victorialogs/logsql/#stats-pipe type pipeStats struct { // byFields contains field names with optional buckets from 'by(...)' clause. - byFields []*byField + byFields []*byStatsField // resultNames contains names of output results generated by funcs. resultNames []string @@ -407,7 +407,7 @@ func parsePipeStats(lex *lexer) (*pipeStats, error) { var ps pipeStats if lex.isKeyword("by") { lex.nextToken() - bfs, err := parseByFields(lex) + bfs, err := parseByStatsFields(lex) if err != nil { return nil, fmt.Errorf("cannot parse 'by' clause: %w", err) } @@ -508,12 +508,12 @@ func parseResultName(lex *lexer) (string, error) { return resultName, nil } -// byField represents by(...) field. +// byStatsField represents 'by (...)' part of the pipeStats. // -// It can have either `name` representation of `name:bucket` representation, -// where `bucket` can contain duration, size or numeric value for creating different buckets +// It can have either 'name' representation or 'name:bucket' or 'name:buket offset off' representation, +// where `bucket` and `off` can contain duration, size or numeric value for creating different buckets // for 'value/bucket'. -type byField struct { +type byStatsField struct { name string // bucketSizeStr is string representation of the bucket size @@ -529,7 +529,7 @@ type byField struct { bucketOffset float64 } -func (bf *byField) String() string { +func (bf *byStatsField) String() string { s := quoteTokenIfNeeded(bf.name) if bf.bucketSizeStr != "" { s += ":" + bf.bucketSizeStr @@ -540,11 +540,11 @@ func (bf *byField) String() string { return s } -func parseByFields(lex *lexer) ([]*byField, error) { +func parseByStatsFields(lex *lexer) ([]*byStatsField, error) { if !lex.isKeyword("(") { return nil, fmt.Errorf("missing `(`") } - var bfs []*byField + var bfs []*byStatsField for { lex.nextToken() if lex.isKeyword(")") { @@ -555,7 +555,7 @@ func parseByFields(lex *lexer) ([]*byField, error) { if err != nil { return nil, fmt.Errorf("cannot parse field name: %w", err) } - bf := &byField{ + bf := &byStatsField{ name: fieldName, } if lex.isKeyword(":") {