grafana / loki

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

Loki query: when a query contains more filters, more logs are returned in some cases #6910

Open ythsu opened 2 years ago

ythsu commented 2 years ago

Describe the bug In my dataset, when a query contains more filters, more logs are returned in some cases. For example, the query {container="my-container", namespace="my-ns"} |= " 401 " returned 78 logs; while the query with one more filter, like {container="my-container", namespace="my-ns"} |= " 401 " |= "1.2.3.4", returned 211 logs in the same time range. (The labels and IP in above queries are mocked to prevent information leak) However, not every query in this pattern results in incorrect outcome. I can get expected results in other cases.

To Reproduce Steps to reproduce the behavior:

  1. Query loki with expression X: {container="my-container", namespace="my-ns"} |= " 401 "
  2. Query loki with expression Y, which includes an additional filter: {container="my-container", namespace="my-ns"} |= " 401 " |= "1.2.3.4"

Expected behavior Since expr X has fewer filters, I expected the number of results from expr X is larger than or equal to the number of results from expr Y.

Environment:

Screenshots, Promtail config, or terminal output {container="my-container", namespace="my-ns"} |= " 401 " 401

{container="my-container", namespace="my-ns"} |= " 401 " |= "1.2.3.4" 401+IP

More Information

DylanGuedes commented 2 years ago

Out of curiosity: were you querying this from the frontend, right? If so, do you mind also querying it directly from a querier too? Trying to isolate that the issue is within the query-frontend and not in other parts.

mohamedmansour commented 1 year ago

The same thing for me in the frontend, I am basically doing {unit="prometheus.service"} in grafana, and when I change the time range, it doesn't respect the time range, this has happened recently. I cannot get the last 5 minutes of logs. When I inspect the log it says:

from:"1667167963719"
to:"1667168263719"

Is this related?