Closed arashout closed 2 years ago
Note that I posted originally here: https://github.com/DataDog/datadog-serverless-functions/issues/498#issuecomment-922183863 and was re-directed to this repo
Hi @arashout. Sorry for the delayed response. We detect logs as errors by inspecting the contents of the log with a log pipeline https://docs.datadoghq.com/logs/log_configuration/pipelines/?tab=source . By default, you get a generic pipeline for lambda, (but you can customize it and add your own parsing rules to extract errors). Alternatively, you can do what you suggested, and swap to a JSON formatted payload. The default lambda pipeline will parse the JSON, and if they have an "error" field, will mark the entire log as an error.
I'm going to close this issue for now. But feel free to reopen if you run into any more issues.
Expected Behavior
Expected the error to be have a
level:error
field on the log message so Datadog correct intrepets the log.Actual Behavior
The Datadog Log Forwarder function doesn't seem to add an
level:error
to log messages that are actually errors that have bubbled up to the final lambda handler.So it's displayed as an INFO log in Datadog instead of ERROR log
Steps to Reproduce the Problem
Have a simple handler like this with an error:
If
processSQSEvent
returns anerr
you will see "error processing the SQS event" without a log level field being forwarded to datadog.How can I resolve this?
Do I need to format the error as a JSON log when returning it?
Specifications