grafana / loki

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

Old logs, once written, cannot be queried. #13880

Open zerolincku opened 3 months ago

zerolincku commented 3 months ago

Describe the bug I am using the /loki/api/v1/push endpoint to write logs into Loki, and the version of Loki is 3.0. Due to a time issue with the machine that collects the data, which I am unable to adjust, the uploaded logs are always 8 hours behind the current time. The logs can be written into Loki, and the response returns a status code of 204. The logs can also be seen in real-time streams in Grafana. However, when using query_range, the logs cannot be queried. When I manually push data with Postman, if the time is set to the correct current time, this issue does not occur. Is there a way for Loki to resolve this problem?

To Reproduce Steps to reproduce the behavior:

  1. push log
    {
    "streams": [
        {
            "stream": {
                "clusterId": 596270048243351552,
                "clusterName": "aaa"
            },
            "values": [
                [
                    "1723592261000000000",
                    "2102311HMH10G3000545 sensor_alarm:  2024-08-14 07:21:07 WEB,admin@192.168.1.101,sensor_alarm,Set remote syslog dest1 test successfully"
                ]
            ]
        }
    ]
    }
  2. query_range

Expected behavior I expect that after the old logs are written, they can be immediately queried.

Environment:

Screenshots, Promtail config, or terminal output If applicable, add any output to help explain your problem.

axlev commented 2 months ago

I also have the same issue, have you found a workaround?

JStickler commented 3 weeks ago

Questions have a better chance of being answered if you ask them on the community forums.