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

updating to truncate only on message #119

Merged
merged 1 commit into from
Nov 25, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jobs/ingestor_syslog/spec
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ properties:
default: false
logstash_parser.message_max_size:
description: "Maximum log message length. Anything larger is truncated (TODO: move this to ingestor?)"
default: 32765
default: 1048576
logstash_parser.filters:
description: "The configuration to embed into the logstash filters section. Can either be a set of parsing rules as a string or a list of hashes in the form of [{name: path_to_parsing_rules.conf}]"
default: ""
Expand Down
16 changes: 4 additions & 12 deletions jobs/ingestor_syslog/templates/config/filters_pre.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,10 @@
#
# trim excessively long messages
#

ruby {
code => '
max_line_length = <%= p("logstash_parser.message_max_size") %>
message = event.get("@message")
if message && message.length > max_line_length
event.set("@message", message[0, max_line_length])
tags = event.get("tags")
tags ||= [] << "_groktrimmed"
event.set("tags", tags)
end
'
truncate {
fields => ["@message"]
add_tag => [ "_logtrimmed" ]
length_bytes => <%= p("logstash_parser.message_max_size") %>
}

#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,43 @@ if [@source][type] =~ /APP(|\/.*)$/ {

## ---- Format 1: JSON
if [@message] =~ /^\s*{".*}\s*$/ { # if it looks like JSON

json {
source => "@message"
target => "app"
id => "cloudfoundry/app-message/json"
truncate {
fields => ["@message"]
add_tag => [ "_messagetrimmed" ]
length_bytes => 32765
}
if !("_messagetrimmed" in [tags]) {
json {
source => "@message"
target => "app"
id => "cloudfoundry/app-message/json"
}

if !("_jsonparsefailure" in [tags]) {
if !("_jsonparsefailure" in [tags]) {

mutate {
rename => { "[app][message]" => "@message" } # @message
}
# concat message and exception
if [app][exception] {
mutate {
## NOTE: keep line break and new line spacing (new line is inserted in logstash in such a way)
replace => { "@message" => "%{@message}
%{[app][exception]}" }
remove_field => [ "[app][exception]" ]
}
}
rename => { "[app][message]" => "@message" } # @message
}
# concat message and exception
if [app][exception] {
mutate {
## NOTE: keep line break and new line spacing (new line is inserted in logstash in such a way)
replace => { "@message" => "%{@message}
%{[app][exception]}" }
remove_field => [ "[app][exception]" ]
}
}

mutate {
rename => { "[app][level]" => "@level" } # @level
}
mutate {
rename => { "[app][level]" => "@level" } # @level
}

} else {
} else {

mutate {
add_tag => [ "unknown_msg_format" ]
remove_tag => ["_jsonparsefailure"]
mutate {
add_tag => [ "unknown_msg_format" ]
remove_tag => ["_jsonparsefailure"]
}
}
}

Expand Down