Skip to content
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

[logcli] tailing queries mixes wrong labels in #8617

Closed
phreaker0 opened this issue Feb 24, 2023 · 1 comment · Fixed by #14525
Closed

[logcli] tailing queries mixes wrong labels in #8617

phreaker0 opened this issue Feb 24, 2023 · 1 comment · Fixed by #14525

Comments

@phreaker0
Copy link

Describe the bug
Running tailing queries with logcli will append labels to log lines which are not present for this specific log line but from others which matches the query too.
Using the query without --tail (and adding --since) works correctly.

To Reproduce
Steps to reproduce the behavior:

  1. Started Loki 2.7.3
  2. Started LogCli 2.7.3 for tailing most logs logcli query --tail '{host=~ ".+"}'

Expected behavior
Each output line should contain the log line with the correct label set.

Environment:

  • Infrastructure: bare-metal
  • Deployment tool: n/a

Screenshots, Promtail config, or terminal output

The following log line is wrong:

2023-02-24T09:14:28+01:00 {filename="/var/log/apache2/gitlab.SECRET.com_ssl_access.log", host="gitlab.SECRET.com", job="varlogs", nodename="stats", syslog_identifier="systemd", systemd_unit="php7.4-fpm.service"} 192.168.1.1 - - [24/Feb/2023:09:14:28 +0100] "POST /api/v4/jobs/request HTTP/1.1" 204 459 "-" "gitlab-runner 15.9.0 (15-9-stable; go1.18.10; linux/amd64)"

The correct one would be:

2023-02-24T09:14:28+01:00 {filename="/var/log/apache2/gitlab.SECRET.com_ssl_access.log", host="gitlab.SECRET.com", job="varlogs"} 192.168.1.1 - - [24/Feb/2023:09:14:28 +0100] "POST /api/v4/jobs/request HTTP/1.1" 204 459 "-" "gitlab-runner 15.9.0 (15-9-stable; go1.18.10; linux/amd64)"

The additional labels which get mixed in are also only valid for the label/value pair host="stats.SECRET.com".

@rgroothuijsen
Copy link
Contributor

The cause is that somehow the same labels object keeps being appended to here. One way to solve the problem would be to start with an empty label set on each call, but I don't know if that has any side effects since this appears to be an intentional design decision.

ctrox added a commit to ctrox/loki that referenced this issue Oct 18, 2024
When tailing with logcli, the loghttp.TailResponse is created outside of
the loop, resulting in stale labels within the TailResponse LabelSet as
the unmarshal does not clear the map.

Fixes grafana#8617

Signed-off-by: Cyrill Troxler <[email protected]>
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

Successfully merging a pull request may close this issue.

2 participants