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 --quiet flag misleading #1676

Closed
Dieterbe opened this issue Feb 11, 2020 · 9 comments · Fixed by #1682 or #1712
Closed

logcli --quiet flag misleading #1676

Dieterbe opened this issue Feb 11, 2020 · 9 comments · Fixed by #1682 or #1712
Assignees

Comments

@Dieterbe
Copy link
Contributor

latest logcli.
--quiet flag promises to "only show log lines".
but this is not true. it still shows all kinds of extra json data I don't want.
the only way i can get "just the log lines" is by adding -o raw
cc @owen-d

@adityacs
Copy link
Contributor

@Dieterbe You see this behaviour just when tailing logs or both in tail and query?

@Dieterbe
Copy link
Contributor Author

i used logcli query. did not try tail.

@adityacs
Copy link
Contributor

adityacs commented Feb 12, 2020

Yeah, something wrong. Was trying some debugging. Somehow, --quiet is not getting parsed correctly

$./logcli query --quiet --since=1h '{filename="/var/log/system.log"}'
Quiet is false
http://localhost:3100/loki/api/v1/query_range?direction=BACKWARD&end=1581505857881302000&limit=30&query=%7Bfilename%3D%22%2Fvar%2Flog%2Fsystem.log%22%7D&start=1581502257881302000
Common labels: {filename="/var/log/system.log", job="varlogs"}
2020-02-12T16:40:29+05:30 {} Feb 12 16:40:29 syslogd[38]:  Sender Statistics

@adityacs
Copy link
Contributor

Bug is likely in this line https://github.com/grafana/loki/blob/master/cmd/logcli/main.go#L66
rangeQuery doesn't parse quiet value as rangeQuery is only defined with newQuery() https://github.com/grafana/loki/blob/master/cmd/logcli/main.go#L30

If we print the value of *quiet, it's returning correct value
Will create a PR to fix this.

@owen-d
Copy link
Member

owen-d commented Feb 12, 2020

Great @adityacs , thanks!

@Dieterbe
Copy link
Contributor Author

Dieterbe commented Feb 13, 2020

this is still not fixed.

~ ❯❯❯ go get -u github.com/grafana/loki/cmd/logcli
~ ❯❯❯ logcli query --since=1h --limit=2 --quiet '{app="metrictank",role="query",instance=~".*ops.*"} |="render"'
2020-02-13T19:35:46+02:00 {} 2020-02-13 17:35:46.304 [INFO] ts=2020-02-13T17:35:46.304724519Z traceID=502666e157091f53 msg="POST /render/?format=msgpack&from=1581527145&now=1581615345&targblah2&until=1581615345 (200) 70.783712ms" orgID=12574 sourceIP="10.56.34.31"
2020-02-13T19:35:45+02:00 {} 2020-02-13 17:35:45.738 [INFO] ts=2020-02-13T17:35:45.73855417Z traceID=502666e157091f53 msg="POST /render/?format=msgpack&from=blah&until=1581615345 (200) 7.710247ms" orgID=12574 sourceIP="10.56.34.31"

for both these lines, the first two columns (i.e. up until {}) is not part of the loglines that my app emits.

Am I misinterpreting what "Log line" means? does it not mean the lines emitted by my app?

@rfratto
Copy link
Member

rfratto commented Feb 13, 2020

@Dieterbe I think in this case, when the help says log line, it's instead referring to the log entry from Loki's perspective (i.e., the combination of the timestamp, the label set, and the raw log line). Given that, --quiet seems to be doing the right thing now: it's only showing log entries and not printing the URL used to query Loki and any common labels.

A combination of --quiet and -oraw might be what you're looking for here: is there anything we can do to help make that experience smoother for you?

@Dieterbe
Copy link
Contributor Author

Dieterbe commented Feb 13, 2020

yes --quiet and -o raw combined works well.

is there anything we can do to help make that experience smoother for you?

i guess throughout the docs and help menus it should be clearer what the different kinds of "log lines" are.

@stale
Copy link

stale bot commented Mar 14, 2020

This issue has been automatically marked as stale because it has not had any activity in the past 30 days. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale A stale issue or PR that will automatically be closed. label Mar 14, 2020
@stale stale bot closed this as completed Mar 21, 2020
@Dieterbe Dieterbe reopened this Mar 21, 2020
@stale stale bot removed the stale A stale issue or PR that will automatically be closed. label Mar 21, 2020
rfratto added a commit to rfratto/loki that referenced this issue Mar 30, 2020
This commit attempts to do two things:

1. Differentiate between log entries and raw log lines, where the latter
   is what is produced by `-oraw`.
2. Explain the difference between `logcli query` and
   `logcli instant-query`.

Fixes grafana#1676.
rfratto added a commit that referenced this issue Mar 30, 2020
* clarify logcli commands and output

This commit attempts to do two things:

1. Differentiate between log entries and raw log lines, where the latter
   is what is produced by `-oraw`.
2. Explain the difference between `logcli query` and
   `logcli instant-query`.

Fixes #1676.

* address feedback

* address more feedback

* explain that instant-query is not useful for log lines

* address review feedback

This commit leaves logcli.md unmodified; that will be done in a later
commit if the changes are approved.

* sync logcli.md with command output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants