aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

Allow omitting timestamps for aws logs tail command

Open RobertoUa opened this issue 3 years ago • 6 comments

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

RobertoUa avatar Dec 28 '21 09:12 RobertoUa

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!

kdaily avatar Dec 28 '21 18:12 kdaily

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.

RobertoUa avatar Dec 29 '21 05:12 RobertoUa

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.

kdaily avatar Dec 29 '21 23:12 kdaily

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

arvindell avatar May 08 '23 21:05 arvindell

+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?

solarisn avatar Apr 17 '24 07:04 solarisn

+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.

mlorenc-sonnen avatar Aug 12 '24 18:08 mlorenc-sonnen