loki icon indicating copy to clipboard operation
loki copied to clipboard

Loki should allow empty selector queries

Open simonswine opened this issue 3 years ago • 3 comments

Describe the solution you'd like

Currently loki requires having at least a single non empty selector (queries require at least one regexp or equality matcher that does not have an empty-compatible value. For instance, app=~".*" does not meet this requirement, but app=~".+" will).

I think this is an unnecessary hurdle for new user and I think we rather should:

  • Provide some extra help how a user can add labels to process a query quicker. (E.g. when the UI takes longer than 5 seconds suggest to shring down the result set by label x, y,z
  • Workarounds do exists today to get {} (by using a label that all streams have like {namespace=~'.+'})

Describe alternatives you've considered

Leave it as it is, while improving error message (like in #6936 )

simonswine avatar Nov 30 '22 14:11 simonswine

Can you please explain how the workaround should be implemented?

Currently I'm getting the same error on this query {project="$Project", commit="$Commit", container="$Container"} |= ""

I tried with {namespace=~".+", project="$Project", commit="$Commit", container="$Container"} |= "" as you suggested but the error is still present.

I also tried to pass a static selector like {namespace="default", project="$Project", commit="$Commit", container="$Container"} |= "" but no improvements.

robertomanfreda avatar Aug 03 '23 14:08 robertomanfreda

@robertomanfreda your issue seems to be with |= "" not in the labels.

gtirloni avatar Sep 06 '23 16:09 gtirloni

Any news ?

voidquark avatar Aug 20 '24 20:08 voidquark

When first using loki the refusal to give back all results for an empty query was very surprising and annoying, especially since there are many examples on the internet and I believe even in the Loki docs where "{}" is used to retrieve all entries.

Anyone coming from practically any other query language will assume that query is equivalent to something like a where clause and assume that omitting the constraint will give back everything.

johann-petrak avatar Feb 11 '25 16:02 johann-petrak

I agree. It should be a configuration option if there's some performance reason for this. As a new user testing out Grafana and Loki locally, I want to view all the data it has so I can see if any of my application's messages are being sent successfully. It's very confusing to determine if I can't see messages because there's no data in Loki or because my query doesn't return results.

dan-passaro-dc avatar Oct 01 '25 16:10 dan-passaro-dc