grafana / loki

Like Prometheus, but for logs.
https://grafana.com/loki
GNU Affero General Public License v3.0
23.96k stars 3.46k forks source link

Range operator position is too strict #1429

Closed davkal closed 4 years ago

davkal commented 4 years ago

I'd like to write queries like

count_over_time({job="cortex-ops/ingester"}[5m] |= "error" )

which produces a syntax error: syntax error: unexpected |=, expecting ) Instead I have to write them like

count_over_time({job="cortex-ops/ingester"} |= "error" [5m])
cyriltovena commented 4 years ago

This is actually tricky because the engine is calling {job="cortex-ops/ingester"} |= "error" a log expression.

Not sure how we could refactor our yacc file.

@codesome you looked at this already what do you think ?

This is happening here:

https://github.com/grafana/loki/blob/master/pkg/logql/expr.y#L69

codesome commented 4 years ago

Looking at the above examples, {job="cortex-ops/ingester"}[5m] looks more like a range selector (and better), {job="cortex-ops/ingester"} |= "error" [5m] looks like a selector on a query.

I guess we cannot (or don't want to) get rid of the current approach as it will be a breaking change. I will take a look at the yacc file to see how it can be done, should be possible.

codesome commented 4 years ago

Got a way to do it, will open a PR tomorrow

cyriltovena commented 4 years ago

This is more a syntax sugar, I’m not sure we want to advertise it too much, what’s the rationale @davkal ?

roidelapluie commented 4 years ago

Because it feels more natural for Prometheus users