Hello All,
I am trying to mask a sensitive information from a log message.
I have given the sample log file and the config file as below. i was trying to do this using gsub with no success. Please review and advise at the earliest.
Sample Log Message :
2018-01-10T16:58:16.925-0700 |[WebContainer : 0]| TRACE | sent | Sent response [<soapenv:Envelope xmlns:soapenv="http://xyz.mlsop.com//envelope/" FirstName>MOHAN1949-12-01
Output from Logstash :
"Type" => "TRACE",
"Task" => "sent",
"@timestamp" => 2018-02-20T16:21:35.948Z,
"Messsage" => " CO Region Expiry days not added to the expiration Date",
"@version" => "1",
"host" => "oc1008401175.ibm.com",
"message" => "2018-01-10T16:58:16.925-0700 |[WebContainer : 0]| TRACE | sent | Sent response [<soapenv:Envelope xmlns:soapenv="http://xyz.mlsop.com//envelope/" FirstName><MiddleName></MiddleName><LastName>MOHAN</LastName><DateOfBirth>1949-12-01</DateOfBirth>",
"Date" => "2018-01-10T16:58:16.925-0700",
"MsgSource" => "[WebContainer : 6]",
Config file:
input {
file {
path => "/home/mohank44/Data/6LogAnalysis/PSI/PSItest5.log"
#type => "LOG"
start_position => "beginning"
codec => multiline
{
pattern => "^\A%{TIMESTAMP_ISO8601}%{SPACE}|%{SYSLOG5424SD}|%{SPACE}%{WORD}"
negate => true
what => previous
} }
}
filter{
mutate
{
gsub => ["message", "\n", ""]
gsub => ["message", "\r", ""]
gsub => ["message", "\t", ""]
gsub => ["message", "(%[a-zA-z0-9-]+)", "yyyy-mm-dd"]
}
grok {
match => [ "message", "\A%{TIMESTAMP_ISO8601:Date}%{SPACE}|%{SYSLOG5424SD:MsgSource}|%{SPACE}%{WORD:Type}%{SPACE}|%{SPACE}%{WORD:Task}%{SPACE}|%{GREEDYDATA:Messsage}" ]
overwrite => [ "message" ]
}
date {
match => [ "Date","yyyy-MM-dd'T'HH:mm:ss.SSS-ZZZZ"]
target => "Date"
}
}
output
{
stdout {codec => rubydebug}
#stdout{}
elasticsearch
{
hosts => "localhost"
index => "log-psi-index3"
}
}
Expected Output :
"Message" => "2018-01-10T16:58:16.925-0700 |[WebContainer : 0]| TRACE | sent | Sent response [<soapenv:Envelope xmlns:soapenv="http://xyz.mlsop.com//envelope/" FirstName>MOHANyyyy-mm-dd"