Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloudwatch: merging the result from 2 fields into one

fields @timestamp, @message
| parse durationMs /(?<duration>[\d]+ )/
| parse message /(GET \/[^\s]+ [\d]+ )(?<responseTime>[\d]+)/ 
| display @timestamp, duration, responseTime
| sort @timestamp desc

This query works for me and fetches the values. The query is currently parsing the durationMs field and getting the value into duration field. Also parsing message field and getting the value into responseTime field.

I am looking for a way to parse durationMs and message fields and get the value into only one field. Is this possible? Please help.

like image 665
sridhar249 Avatar asked Dec 06 '25 20:12

sridhar249


1 Answers

coalesce function did the job for me.

fields @timestamp, @message
| parse durationMs /(?<duration>[\d]+ )/
| parse message /(GET \/[^\s]+ [\d]+ )(?<responseTime>[\d]+)/ 
| display @timestamp, coalesce(duration, responseTime) as response_time
| sort @timestamp desc
like image 70
sridhar249 Avatar answered Dec 08 '25 10:12

sridhar249