how to display timestamp in epoch format using boto3 cloudwatch query ?

0

Hi,

I'm tryin to display the log entry timestamp in epoch format using boto3 logs query function. Documentation instructs to use 'toMillis( @timestamp)' , however 'toMillis( ) displays an floating-point number. eg: '{'field': 'toMillis(@timestamp)', 'value': '1.701646365129E12}'

The cloudwatch insights web console does permit timestamp conversion to epoch format using syntax 'fields @timestampEpoch as @timestamp', however this syntax does not work for boto3 queries. Also, I cannot find any documentation on @timestampEpoch

Any suggestions besides converting the format using .time() python functions ?

thx

1개 답변
0

Hi,

I understand you have are trying to display the log entry timestamp in the epoch format using boto3 logs query function.

The following can be achieved by using the toMillis() function, however it would display the floating point number as you had shared.

The suitable method would be to use the .time() function in order to achieve this particular use case as I have not found any additional method of achieving this conversion. It was noted that the cloudwatch insights console does permit timestamp conversion to epoch format, however this similar syntax cannot be seen in the Boto3 documentation.

I am positive this helps. Let me know if you have any follow-up questions as we can keep this thread open for additional discussions with the community.

Kind regards, Muhammad

AWS
답변함 5달 전
profile picture
전문가
검토됨 한 달 전
  • Hi Muhammad,

    Thank you for your reply. Using the time() function takes an inordinate amount of time for conversions and other operations. It would be better if the boto3 query function would handle the conversion. After all, the console query function does already support the conversion operation. How can that happen ?

    B/R gary

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠