Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ingesting non-JSON messages #159

Merged
merged 3 commits into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ tmp
*.o
*.a
mkmf.log
.idea
*.iml
9 changes: 7 additions & 2 deletions lib/fluent/plugin/in_cloudwatch_logs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,13 @@ def emit(stream, event)
}
else
time = (event.timestamp / 1000).floor
record = @json_handler.load(event.message)
router.emit(@tag, time, record)
begin
record = @json_handler.load(event.message)
router.emit(@tag, time, record)
rescue JSON::ParserError, Yajl::ParseError => error # Catch parser errors
log.error "Invalid JSON encountered while parsing event.message"
router.emit_error_event(@tag, time, { message: event.message }, error)
end
end
end

Expand Down