Repository navigation
T-7532 Take the log level from a JSON message - #13
Merged
Merged
Conversation
Pins that a CloudWatch log event whose message is a JSON object with a string `level` (Lambda's JSON log format, or a structured logger writing JSON through console.log) gets that level, including when the text-format prefix says INFO. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
CloudWatch log events whose message is a JSON object with a string `level` (Lambda's JSON log format, or a structured logger writing JSON through console.log) kept the Lambda's default `info` level, or the level from the text-format prefix, so errors logged as JSON showed up as info in Better Stack. The JSON level now overrides both. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CloudWatch log events whose message is a JSON object carry their level inside the JSON as
level: Lambda's JSON log format writes{"timestamp":…,"level":"ERROR","requestId":…,"message":…}, and structured loggers such as winston or pino write JSON throughconsole.log. The forwarder only read the level from a[LEVEL]bracket or aLEVELprefix and otherwise sentinfo, so an error logged as JSON showed up as info in Better Stack.The parser now parses a message that is a JSON object and, when it has a non-empty string
level, sends that level lowercased.It overrides the level from the text-format prefix too: in Lambda's text format a JSON logger's line arrives as
<timestamp>\t<request id>\tINFO\t{"level":"error",…}, where the prefix only reflects which console method was called. The message itself is sent unchanged, so Better Stack still expands the JSON into fields.Not covered:
"level":50are ignored.timestampandrequestIdinside a JSON-format message are not extracted intodtandcontext.request_id. The text-format prefix still is.The first commit holds only the tests and is expected to fail CI. The second commit makes them pass.