-
Notifications
You must be signed in to change notification settings - Fork 111
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
[APP-6612] Add Filters for Downloading Logs #4673
Conversation
…gs to text or json file
…ng the logs, instead of retrieving all of the logs and then writing them all to the file
…ck when writing to file
…t arguments to be paired - either both are provided, or an error will be displated
…ds called on the *viamClient
… logs cli command
There was a problem hiding this 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
&cli.StringFlag{ | ||
Name: logsFlagOutputFile, | ||
Usage: "path to output file", | ||
}, | ||
&cli.StringFlag{ | ||
Name: logsFlagFormat, | ||
Usage: "file format (text or json)", | ||
}, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 :)
There was a problem hiding this 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
logsFlagFormat = "format" | ||
logsFlagOutputFile = "output" | ||
logsFlagKeyword = "keyword" | ||
logsFlagLevels = "levels" | ||
logsFlagStartTime = "start" | ||
logsFlagEndTime = "end" | ||
logsFlagErrors = "errors" | ||
logsFlagTail = "tail" | ||
logsFlagCount = "count" |
There was a problem hiding this comment.
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
logsFlagStartTime = "start" | ||
logsFlagEndTime = "end" |
There was a problem hiding this comment.
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?
…s-For-Downloading-Logs
…Time to generalFlagStart and generalFlagEnd
0b85f4e
to
b8a5d77
Compare
cli/client.go
Outdated
if remainingLogsNeeded < len(resp.Logs) { | ||
resp.Logs = resp.Logs[:remainingLogsNeeded] | ||
} | ||
|
||
// Write the logs to the output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove this comment and the one below
cli/app.go
Outdated
}, | ||
&cli.StringFlag{ | ||
Name: generalFlagStart, | ||
Usage: "ISO-8601 timestamp in RFC3339 format indicating the start of the interval filter", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: may be nice to give an example of what that is for both this and the one below
@@ -758,6 +761,16 @@ func RobotsLogsAction(c *cli.Context, args robotsLogsArgs) error { | |||
return err | |||
} | |||
|
|||
// Check if both start time and count are provided | |||
if args.Start != "" && args.Count > 0 && args.End == "" { | |||
return errors.New("unsupported functionality: specifying both a start time and a count without an end time is not supported. " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this? i feel like this is explaining weirdness in our code to our users which we shouldn't do.
May make more sense to make this a comment rather than something user facing and just say this is unsupported to the user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I know this is out of scope, but this behaviour is also counter-intuitive to me). Other logs api's support this: https://docs.aws.amazon.com/ja_jp/AmazonCloudWatchLogs/latest/APIReference/API_StartQuery.html
so why don't we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this functionality is something we really need to support but it will require changing the app's api to support sorting the order of the logs (currently we default to descending order for time)
even though I would love to implement the sorting functionality now, it's out of the scope of the pr and I am not sure we want to prioritize more resources to this now. I think we wanted to leave this comment so that it screams out to us that it needs to be addressed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you make a ticket to add this in as something in the backloig? and link this code?
I agree that theres nothing to change here as part of the ticket, but wondered if there was something we could do without having to change the API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! I have a ticket cut, I will add it to the code
…omment regarding why a limit is not passed to the APP GetRobotPartLogs call
b892bb9
to
21d27c6
Compare
// We do not request the exact limit specified by the user in the `count` argument because the API enforces a maximum | ||
// limit of 100 logs per batch fetch. To keep the RDK independent of specific limits imposed by the app API, | ||
// we always request the next full batch of logs as allowed by the API (currently 100). This approach | ||
// ensures that if the API limit changes in the future, only the app API logic needs to be updated without requiring |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼 much better
This PR implements additional filters to the machines logs CLI command, specifically:
keyword
,start time
,end time
andlog level
. Below are the details and test cases for the command:See ticket here
Invalid: Without any arguments
With Keyword Filter
With Error Level
Start Time
Start from after the last log
The most recent few logs
Logs from a slightly earlier start time
Invalid: Cannot use start and count without end.
End Time
Notice how in the second screenshot, we skip the logs passed 15:16.
Start & End Time
Start + Count + End Time
Edge Case
Do we not want to output something prettier if there are no logs to display?
Without providing
count
, defaults to 100 logscount
of 10,000 workscount
of 10,001 does not work@jr22 - I personally do not love that when surpassing the maxLogs we still display the following: