CloudWatch Logs Insight queries

0

Hello, good evening.

I'm doing a query in CloudWatch Logs Insight to get two date fields, calculate the difference, and display all three fields on the same line.

I extract the two fields (startdate, enddate) with regular expressions. ¿Is it possible to do that operation in CloudWatch?

If you can help me I appreciate a lot.

Thank you so much

salidaConsulta

질문됨 일 년 전282회 조회
2개 답변
0

How about toMillis(startdate) - toMillis(enddate) to give you the difference?

This may work? You may have to put your regex into the fields line to output the result..

fields startdate,enddate,toMillis(startdate) - toMillis(enddate)
profile picture
전문가
답변함 일 년 전
0

Hello,

You can further parse the startdate and enddate to calculate the time difference. I've illustrated this with example log events.

Log event 1: 2023-03-16T23:24:38.973 2023-03-16T23:24:40.586 Log event 2: 2023-03-16T23:23:38.973 2023-03-16T23:24:40.000

Following query will parse the timestamps to 4 segments: date, hours, minutes, seconds

Difference between start and end time is calculated and multiplied to convert the difference to seconds.

PARSE @message "T:: T::" as startdate, s_hour, s_min, s_sec, enddate, e_hour, e_min, e_sec | fields (((e_hour - s_hour) * 3600) + ((e_min - s_min) * 60) + (e_sec - s_sec)) as TimeDifference | display @message, TimeDifference

답변함 일 년 전

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

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

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