I'm using structured logging to store logs in cloudwatch and faced the problem where I want to create a metric for errors but AWS management console does not allow me to use "@" symbol in queries. I can't figure out what's wrong.
Here is sample of log entry I have
{
"@t": "2023-03-10T16:48:09.5022940Z",
"@m": "An error occurred while processing job 35b09378-7216-4115-aaa8-b0513e58e33f.",
"@i": "9007e084",
"@l": "Error",
"@x": "System.InvalidOperationException: Nullable object must have a value.",
"SourceContext": "AWSJobWorker fd59f4ff-d7a4-4c05-a903-0438b5ff6122",
"JobId": "35b09378-7216-4115-aaa8-b0513e58e33f",
"UserId": "7a97a41c-ad9e-4b9b-b2f0-9314a227d863",
"ClientId": "65f13bea-18b8-490c-aba8-87059533ab53",
"CorrelationId": "dfa3b3e8-3bae-48b8-aedf-65374b43ba3a"
}
How can I make a filter pattern for "@l" property where it does have equal to "Error"?
This is how it looks like now when I'm trying to use this property.
You'll have to escape the quotes:
"\"@l\": \"Error\""