Skip to content

logcli gives different results depending on --batch size #17270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
JonathanLennox opened this issue Apr 16, 2025 · 0 comments
Open

logcli gives different results depending on --batch size #17270

JonathanLennox opened this issue Apr 16, 2025 · 0 comments

Comments

@JonathanLennox
Copy link

JonathanLennox commented Apr 16, 2025

Describe the bug
I run two logcli queries with --limit 0, with different values of --batch; queries with smaller values of --batch are missing output that is in the output of queries with larger values of --batch.

The query I am making has multiple series; it looks like logcli starts the next batch query based on the latest timestamp of any result in any series, which means that intermediate entries from a busier series get lost.

To Reproduce
Steps to reproduce the behavior:
Running Loki 3.2.1 on https://prod-us-ashburn-1-loki.example.

$ logcli query --forward --addr=https://prod-us-ashburn-1-loki.example --timezone=UTC --from='2025-04-09T16:40:00.000Z' --to='2025-04-09T16:50:00.000Z' '{node="prod-example-us-ashburn-1-s50", task="task1"}' --limit=0 > no-batch

$ logcli query --forward --addr=https://prod-us-ashburn-1-loki.example --timezone=UTC --from='2025-04-09T16:40:00.000Z' --to='2025-04-09T16:50:00.000Z' '{node="prod-example-us-ashburn-1-s50", task="task1"}' --limit=0 --batch=2000 > batch-2000

$ wc -l no-batch
    1496 no-batch

$ wc -l batch-2000 
    1993 batch-2000

Expected behavior
With --limit=0, logcli output should be the same regardless of batch size.

Environment:
Server is Loki 3.2.1 running in Nomad. Client is logcli 3.4.3 on Darwin-arm64. (Also tried logcli 3.2.1, 3.0.0, 2.9.14, with the same results.)

Screenshots, Promtail config, or terminal output
Internal hostnames and service names have been redacted in this output.

$ logcli query --forward --addr=https://prod-us-ashburn-1-loki.example --timezone=UTC --from='2025-04-09T16:40:00.000Z' --to='2025-04-09T16:50:00.000Z' '{node="prod-example-us-ashburn-1-s50", task="task1"}' --limit=0 > no-batch
2025/04/16 18:32:24 https://prod-us-ashburn-1-loki.example/loki/api/v1/query_range?direction=FORWARD&end=1744217400000000000&limit=1000&query=%7Bnode%3D%22prod-example-us-ashburn-1-s50%22%2C+task%3D%22task1%22%7D&start=1744216800000000000
2025-04-16 18:32:24.867 logcli[6210:36611466] CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 1. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug.
2025-04-16 18:32:24.868 logcli[6210:36611466] CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 1. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug.
2025/04/16 18:32:26 Common labels: {group="signal", job="shard-prod-example-us-ashburn-1-s50", namespace="default", node="prod-example-us-ashburn-1-s50", region="us-ashburn-1", service_name="shard-prod-example-us-ashburn-1-s50", task="task1"}
2025/04/16 18:32:26 https://prod-us-ashburn-1-loki.example/loki/api/v1/query_range?direction=FORWARD&end=1744217400000000000&limit=1000&query=%7Bnode%3D%22prod-example-us-ashburn-1-s50%22%2C+task%3D%22task1%22%7D&start=1744217303337037898
2025/04/16 18:32:27 Common labels: {group="signal", job="shard-prod-example-us-ashburn-1-s50", namespace="default", node="prod-example-us-ashburn-1-s50", region="us-ashburn-1", service_name="shard-prod-example-us-ashburn-1-s50", task="task1"}
2025/04/16 18:32:27 https://prod-us-ashburn-1-loki.example/loki/api/v1/query_range?direction=FORWARD&end=1744217400000000000&limit=1000&query=%7Bnode%3D%22prod-example-us-ashburn-1-s50%22%2C+task%3D%22task1%22%7D&start=1744217399998085688
2025/04/16 18:32:28 Common labels: {detected_level="INFO", group="signal", job="shard-prod-example-us-ashburn-1-s50", level="INFO", namespace="default", node="prod-example-us-ashburn-1-s50", region="us-ashburn-1", service_name="shard-prod-example-us-ashburn-1-s50", task="task1"}

$ logcli query --forward --addr=https://prod-us-ashburn-1-loki.example --timezone=UTC --from='2025-04-09T16:40:00.000Z' --to='2025-04-09T16:50:00.000Z' '{node="prod-example-us-ashburn-1-s50", task="task1"}' --limit=0 --batch=2000 > batch-2000
2025/04/16 18:32:35 https://prod-us-ashburn-1-loki.example/loki/api/v1/query_range?direction=FORWARD&end=1744217400000000000&limit=2000&query=%7Bnode%3D%22prod-example-us-ashburn-1-s50%22%2C+task%3D%22task1%22%7D&start=1744216800000000000
2025-04-16 18:32:36.256 logcli[6624:36612784] CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 1. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug.
2025-04-16 18:32:36.257 logcli[6624:36612784] CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 1. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug.
2025/04/16 18:32:39 Common labels: {group="signal", job="shard-prod-example-us-ashburn-1-s50", namespace="default", node="prod-example-us-ashburn-1-s50", region="us-ashburn-1", service_name="shard-prod-example-us-ashburn-1-s50", task="task1"}
2025/04/16 18:32:39 https://prod-us-ashburn-1-loki.example/loki/api/v1/query_range?direction=FORWARD&end=1744217400000000000&limit=2000&query=%7Bnode%3D%22prod-example-us-ashburn-1-s50%22%2C+task%3D%22task1%22%7D&start=1744217399998085688
2025/04/16 18:32:39 Common labels: {detected_level="INFO", group="signal", job="shard-prod-example-us-ashburn-1-s50", level="INFO", namespace="default", node="prod-example-us-ashburn-1-s50", region="us-ashburn-1", service_name="shard-prod-example-us-ashburn-1-s50", task="task1"}

$ wc -l no-batch
    1496 no-batch

$ wc -l batch-2000 
    1993 batch-2000

$ logcli series --addr=https://prod-us-ashburn-1-loki.example --timezone=UTC --from='2025-04-09T16:40:00.000Z' --to='2025-04-09T16:50:00.000Z' '{node="prod-example-us-ashburn-1-s50", task="task1"}'
2025/04/16 18:33:18 https://prod-us-ashburn-1-loki.example/loki/api/v1/series?end=1744217400000000000&match=%7Bnode%3D%22prod-example-us-ashburn-1-s50%22%2C+task%3D%22task1%22%7D&start=1744216800000000000
2025-04-16 18:33:19.350 logcli[7230:36614880] CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 1. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug.
2025-04-16 18:33:19.352 logcli[7230:36614880] CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 1. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug.
{group="signal", job="shard-prod-example-us-ashburn-1-s50", level="WARNING", namespace="default", node="prod-example-us-ashburn-1-s50", region="us-ashburn-1", service_name="shard-prod-example-us-ashburn-1-s50", task="task1"}
{group="signal", job="shard-prod-example-us-ashburn-1-s50", level="INFO", namespace="default", node="prod-example-us-ashburn-1-s50", region="us-ashburn-1", service_name="shard-prod-example-us-ashburn-1-s50", task="task1"}

$ curl -o no-batch-job1.json 'https://prod-us-ashburn-1-loki.example/loki/api/v1/query_range?direction=FORWARD&end=1744217400000000000&limit=1000&query=%7Bnode%3D%22prod-example-us-ashburn-1-s50%22%2C+task%3D%22task1%22%7D&start=1744216800000000000'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  518k    0  518k    0     0   251k      0 --:--:--  0:00:02 --:--:--  252k

$ jq '.data.result[].values | length' no-batch-1.json 
972
28

$ jq '.data.result[].values[-1][0]' no-batch-1.json 
"1744217199091890806"
"1744217303337037898"

Notice that the second URL in the "no-batch" case has the query parameter start=1744217303337037898, which is the later of the two final timestamp values in the first batch's results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant