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

[APP-6612] Add Filters for Downloading Logs #4673

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

JosephBorodach
Copy link
Contributor

@JosephBorodach JosephBorodach commented Jan 3, 2025

This PR implements additional filters to the machines logs CLI command, specifically: keyword, start time, end time and log level. Below are the details and test cases for the command:

See ticket here

Invalid: Without any arguments

go run cli/viam/main.go machines logs

Screenshot 2025-01-08 at 1 55 28 PM




With Keyword Filter

go run cli/viam/main.go machines logs -machine="1" --organization="viam-dev" --location="office temp" --keyword="stack"

Screenshot 2025-01-08 at 1 31 09 PM




With Error Level

go run cli/viam/main.go machines logs -machine="1" --organization="viam-dev" --location="office temp" --levels="error"

Screenshot 2025-01-08 at 1 34 51 PM




Start Time

Start from after the last log

go run cli/viam/main.go machines logs --machine="1" --organization="viam-dev" --location="office temp" --start="2025-01-10T21:30:00Z"

Screenshot 2025-01-09 at 9 29 32 AM

Start from a time with only a few logs

go run cli/viam/main.go machines logs --machine="1" --organization="viam-dev" --location="office temp" --start="2025-01-10T21:30:00Z"




End Time

Notice how in the second screenshot, we skip the logs passed 15:16.
Screenshot 2025-01-09 at 10 19 46 AM




Start & End Time




End Case

Do we not want to output something prettier if their are no logs to display?
Screenshot 2025-01-09 at 10 56 03 AM

@JosephBorodach JosephBorodach requested a review from a team as a code owner January 3, 2025 17:57
@JosephBorodach JosephBorodach requested review from stuqdog and purplenicole730 and removed request for a team January 3, 2025 17:57
Base automatically changed from APP-6612-Support-Downloading-Logs to main January 7, 2025 14:17
Copy link
Member

@purplenicole730 purplenicole730 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! There were some changes in flag names that were recently merged in, but I don't suspect it should affect your PR too much

cli/app.go Outdated
Comment on lines 1557 to 1564
&cli.StringFlag{
Name: logsFlagOutputFile,
Usage: "path to output file",
},
&cli.StringFlag{
Name: logsFlagFormat,
Usage: "file format (text or json)",
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe mention needs format flag, needs output flag for the users in the usage text? Not sure if necessary, but a suggestion, since I feel like I would read that as being able to format it when printing to console as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can decide the format when printing to the console! The command will default to text if the format flag is not included. Are you suggesting something else?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you can also format it for the console! Ignore me then :)

Copy link
Member

@stuqdog stuqdog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple small things but generally lgtm

cli/app.go Outdated
Comment on lines 32 to 40
logsFlagFormat = "format"
logsFlagOutputFile = "output"
logsFlagKeyword = "keyword"
logsFlagLevels = "levels"
logsFlagStartTime = "start"
logsFlagEndTime = "end"
logsFlagErrors = "errors"
logsFlagTail = "tail"
logsFlagCount = "count"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like some of these were added in a separate PR already. Would you mind pulling down main so we can get a more up-to-date look at what the diff is precisely?

cli/app.go Outdated
Comment on lines 36 to 37
logsFlagStartTime = "start"
logsFlagEndTime = "end"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(minor) I'm gonna ask you to do a bit of bookkeeping for us here if you don't mind! We already have a "start" flag and an "end" flag (dataFlagStart and dataFlagEnd). Would you be willing to rename those to generalFlagStart and generalFlagEnd and then update call sites so that there's only the single instance of a --start or --end flag?

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Jan 8, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 8, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 8, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 8, 2025
@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Jan 8, 2025
@JosephBorodach JosephBorodach force-pushed the APP-6612-Add-Filters-For-Downloading-Logs branch from e627f4b to b292477 Compare January 8, 2025 18:53
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 8, 2025
@JosephBorodach JosephBorodach force-pushed the APP-6612-Add-Filters-For-Downloading-Logs branch from cb55d25 to 0d65512 Compare January 9, 2025 15:59
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants