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

Example of how to retrieve all logs from a log group stream #8811

Open
2 tasks
kaihendry opened this issue Jul 22, 2024 · 7 comments
Open
2 tasks

Example of how to retrieve all logs from a log group stream #8811

kaihendry opened this issue Jul 22, 2024 · 7 comments
Assignees
Labels
feature-request A feature should be added or improved. logs p2 This is a standard priority issue response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@kaihendry
Copy link

Describe the feature

Say you wanted to retrieve all slow logs and any future new slow logs from:

aws logs get-log-events --log-group-name "/aws/rds/instance/$dbname/slowquery" --log-stream-name "$dbname" >> slow.log

Currently, by default if you re-run the command you will get duplicates and not all the old logs.

Use Case

I'm always frustrated when I don't get all the slow logs.

Proposed Solution

Have some example shell in the documentation at the very least to demonstrate how to use the nextForwardToken

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CLI version used

aws-cli/2.17.0

Environment details (OS name and version, etc.)

Python/3.11.9 Darwin/23.5.0 source/arm64

@kaihendry kaihendry added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jul 22, 2024
@tim-finnigan tim-finnigan self-assigned this Jul 26, 2024
@tim-finnigan tim-finnigan added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Jul 26, 2024
@tim-finnigan
Copy link
Contributor

Thanks for reaching out. As an alternative have you tried using the start-query command with dedup in the query syntax to avoid getting duplicate results? Or using subscriptions for real-time processing of the logs?

@tim-finnigan tim-finnigan added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. logs p2 This is a standard priority issue and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. needs-triage This issue or PR still needs to be triaged. labels Jul 26, 2024
@kaihendry
Copy link
Author

Be good if you had a fully-fledged example with start-query dedup 😬

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Aug 2, 2024
@tim-finnigan
Copy link
Contributor

@kaihendry have you tried something like this?

aws logs start-query \
  --log-group-name my-log-group \
  --query-string "fields @message | dedup @message" \
  --start-time 1596300000 \
  --end-time 1596400000

@tim-finnigan tim-finnigan added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Aug 2, 2024
@kaihendry
Copy link
Author

But that's not idempotent, in the sense I'd have to figure out the start/end time, right?

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Aug 5, 2024
@tim-finnigan
Copy link
Contributor

Yes the StartQuery API requires parameters for start and end times. But that's a way to remove duplicates. In terms of streaming logs you can try start-live-tail (See example in User Guide) or tail and use the --follow parameter to poll for new logs.

@tim-finnigan tim-finnigan added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Aug 5, 2024
@kaihendry
Copy link
Author

Tailing doesn't help me. I just want all the logs in the log group / stream on my disk. When the slow logs for example get appended to, I want my local disk to be in sync. This use case seems incredibly difficult with the AWS cli right now.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Aug 6, 2024
@tim-finnigan
Copy link
Contributor

Thanks for following up. I think the limitations here are with the CloudWatch Logs APIs that the AWS CLI commands use. Do you want to request an update to an existing API, propose a new API? Please specify your use case in full detail and we can bring it to the CloudWatch Logs team for consideration. What you're trying to do may be possible with a bash script like this and a cron job to keep your logs in sync.

@tim-finnigan tim-finnigan added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. logs p2 This is a standard priority issue response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants