I have a JSON Cloudwatch log as below:
{"path": "folder1/folder2/file.txt"}
My aim is to parse this log so that I can create a new field parent from the path field such that its value is folder1. I basically need to get everything from the beginning till the first forward slash in the path field value.
This is what I am trying:
fields @timestamp, @message
| parse @message '"path": "*"' as @path
| parse @path /(^[^\/]+)/ as @parent
But it is giving me a syntax error on as on line 3 with the error: 'as' is not valid in this position, expecting EOF, '|', '|>'
I tested the regex expression that I am using at https://rubular.com/r/CXQS8auGY08K0M.
What am I missing? Thanks!