Skip to content

Commit

Permalink
Naïve fix for optimize bug with line_format and json expression p…
Browse files Browse the repository at this point in the history
…arser (#6375)

* Naïve fix

Signed-off-by: Danny Kopping <danny.kopping@grafana.com>

* CHANGELOG

Signed-off-by: Danny Kopping <danny.kopping@grafana.com>

* Update CHANGELOG.md

Co-authored-by: Christian Haudum <christian.haudum@gmail.com>

Co-authored-by: Christian Haudum <christian.haudum@gmail.com>
  • Loading branch information
dannykopping and chaudum authored Jun 13, 2022
1 parent 771e218 commit a649e0d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
* [6358](https://github.com/grafana/loki/pull/6358) **taharah**: Fixes sigv4 authentication for the Ruler's remote write configuration by allowing both a global and per tenant configuration.
* [6152](https://github.com/grafana/loki/pull/6152) **slim-bean**: Fixes unbounded ingester memory growth when live tailing under specific circumstances.
* [5685](https://github.com/grafana/loki/pull/5685) **chaudum**: Assert that push values tuples consist of string values
* [6375](https://github.com/grafana/loki/pull/6375) **dannykopping**: Fix bug that prevented users from using the `json` parser after a `line_format` pipeline stage.
##### Changes
* [6042](https://github.com/grafana/loki/pull/6042) **slim-bean**: Add a new configuration to allow fudging of ingested timestamps to guarantee sort order of duplicate timestamps at query time.
* [6120](https://github.com/grafana/loki/pull/6120) **KMiller-Grafana**: Rename configuration parameter fudge_duplicate_timestamp to be increment_duplicate_timestamp.
Expand Down
4 changes: 4 additions & 0 deletions pkg/logql/optimize.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ func removeLineformat(expr syntax.SampleExpr) {
found = true
break
}
if _, ok := pipelineExpr.MultiStages[j].(*syntax.JSONExpressionParser); ok {
found = true
break
}
}
if found {
// we cannot remove safely the linefmtExpr.
Expand Down
1 change: 1 addition & 0 deletions pkg/logql/optimize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func Test_optimizeSampleExpr(t *testing.T) {
{`sum by(name)(bytes_over_time({region="us-east1"} | line_format "something else"[5m]))`, `sum by(name)(bytes_over_time({region="us-east1"} | line_format "something else"[5m]))`},
{`sum by(name)(rate({region="us-east1"} | json | line_format "something else" |= "something"[5m]))`, `sum by(name)(rate({region="us-east1"} | json | line_format "something else" |= "something"[5m]))`},
{`sum by(name)(rate({region="us-east1"} | json | line_format "something else" | logfmt[5m]))`, `sum by(name)(rate({region="us-east1"} | json | line_format "something else" | logfmt[5m]))`},
{`sum by(name)(count_over_time({region="us-east1"} | line_format "{{ .message }}" | json foo="bar"[5m]))`, `sum by(name)(count_over_time({region="us-east1"} | line_format "{{ .message }}" | json foo="bar"[5m]))`},

// remove line_format that is not required.
{`sum by(name)(rate({region="us-east1"} | line_format "something else"[5m]))`, `sum by(name)(rate({region="us-east1"}[5m]))`},
Expand Down

0 comments on commit a649e0d

Please sign in to comment.