aws-cli
aws-cli copied to clipboard
Allow omitting timestamps for aws logs tail command
Add a new format, just like --format short
but without timestamps.
My logs already have timestamps, and on a small screen it takes up precious space. Moreover, timestamps are added even to multiline messages, which makes it hard for copying data from aws logs tail
Hi @RobertoUa,
Thanks for the post. Just to clarify, you're asking for omitting timestamps specifically from the aws logs tail
command?
This command is a convenience wrapper around the aws logs filter-log-events
command, so any multiline messages are coming back from CloudWatch as is. You wouldn't be able to use the tail
command to filter on your own timestamps, and there's no expectation that other users would be providing their own timestamps, so that might be confusing.
Can you provide some more details about how this would work and what your use case is? Thanks!
Just to clarify, you're asking for omitting timestamps specifically from the
aws logs tail
command
Yeah, I'm asking for adding a parameter to aws logs tail
for omitting timestamps. Probably --format none
.
My current workaround is piping to a cut
command, like this aws logs tail <log> --follow --format short | cut -d\ -f2-
Compare logs
with cut
2021-12-28T11:32:23,38 [io-compute-1] ERROR software.amazon.awssdk.http.crt.internal.AwsCrtAsyncHttpStreamAdapter - Response Encountered an Error.
Caused by: software.amazon.awssdk.crt.http.HttpException: The connection has closed or is closing.
software.amazon.awssdk.http.crt.internal.AwsCrtAsyncHttpStreamAdapter.onResponseComplete(AwsCrtAsyncHttpStreamAdapter.java:116)
software.amazon.awssdk.crt.http.HttpStreamResponseHandlerNativeAdapter.onResponseComplete(HttpStreamResponseHandlerNativeAdapter.java:33)
vs current aws logs tail --format short
2021-12-29T05:44:43 2021-12-29T05:44:43,714 [io-compute-0] ERROR software.amazon.awssdk.http.crt.internal.AwsCrtResponseBodyPublisher - Error processing Response Body - task: 43310b8fade840d8843a7c4129ede64b, instance: 1d392c06193f44eea31ffe7996423499, ec2: i-0ed77c9972cf974eb
2021-12-29T05:44:43 Caused by: software.amazon.awssdk.crt.http.HttpException: The connection has closed or is closing.
2021-12-29T05:44:43 software.amazon.awssdk.http.crt.internal.AwsCrtAsyncHttpStreamAdapter.onResponseComplete(AwsCrtAsyncHttpStreamAdapter.java:116)
2021-12-29T05:44:43 software.amazon.awssdk.crt.http.HttpStreamResponseHandlerNativeAdapter.onResponseComplete(HttpStreamResponseHandlerNativeAdapter.java:33)
2021-12-29T05:44:43
As you can see, copying is hard when timestamps are added to each and every line. And since most java loggers have timestamps by default option for disabling timestamps would be useful for many.
Thanks for the details and the example, @RobertoUa. I'm going to edit the title of your issue to clarify that it applies to that specific command. I'll leave it open for other community upvotes, which can be given by adding a 👍🏻 to the initial comment.
My use case is using a custom pretty-print cli like pino-pretty. The timestamps prevents my tool from parsing the logs as JSON. An option none
for --format
would greatly help
+1 for this. Also trying to use pino-pretty to tail my logs from production. Anyone have an elegant way to get around it for now?
+1 for --format none
. Most applications already have the timestamp as part of the log format or use structured logging, so it would be great to be able to tail the logs without anything extra added to them.