I have many rows in my CloudWatch logs that are JSON objects like this:
{
"friends": [
{ "name": "bob"},
{ "name": "steve"},
{ "name": "joe" }
]
}
Using CloudWatch Regex expressions, I would like to extract all the names. I already have a regex that returns the values that I want to:
/"name":[ ]*"([^"]*)"/g
As you can see running in this link: https://regex101.com/r/Bb28Pg/2
Using the CloudWatch grammar, that regex becomes this command:
fields @message
| filter @message like /"friends":/
| parse @message /"name":[ ]*"(?<@name>[^"]*)"/
But this expression only returns the first name, "bob" in the example. I want to get them all. I have tried adding the /g
at the end of the expression, but that did not help. I try to find some information in the official docs https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html, but I could not find anything related to this subject.
There is a similar question of this in the Cloudwatch Insights search in multiline logs, but that one is not using parse command and also has no answer.