'AWS json cloudwatch logs metric value

I have json logs on cloudwatch like this:

{
    "Id": "12345678",
    "level": "debug",
    "message": "POST http://my.domain/parse 200 6",
    "timestamp": "2022-03-23 09:38:30.626"
}

and I want to create metric filter with metric value which send duration value of '6' to metrics. I created filter:

{ $.level = "debug" && $.message = "POST http://my.domain/parse 200*" }

Is this possible in cloudwatch to get that duration value from json? Or I need to have another json line in logs?

For example "duration" : "6"

Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source