I'm tying to use logstash to perform a transform on json data that is being logged to a text file.
Logstash config snippet:
filter {
mutate {
gsub => [
# replace all '::~~' with '\r\n'
"alert.explanation.cnc-services.cnc-service.channel", "\:\:~~", "\\r\\n"
# "channel", "~~", "n"
]
}
}
Input json:
{
"alert": {
"explanation": {
"cnc-services": {
`enter code here`"cnc-service": {
"channel": "TEXT1 TEXT2::~~TEXT3::~~TEXT4::~~TEXT5::~~TEXT6::~~::~~"
}
}
}
}
}
Desired output:
{
"alert": {
"explanation": {
"cnc-services": {
"cnc-service": {
"channel": "TEXT1 TEXT2\r\nTEXT3\r\nTEXT4\r\nTEXT5\r\nTEXT6\r\n\r\n"
}
}
}
}
}
The input data is only a portion of the whole json document, there are may other fields but I only need to modify this one. This data is generated by another application and it can't be modified. None of the articles I've seen for logstash talk about doing something like this.
edit: Here is the input section of the logstash config
input {
# Read from log file
file {
codec => "json"
type => "fireeye"
path => ["/var/log/app/events.json"]
}
}