I try create the topic field of my log message from matching string
This is my script, it work when i test it on preview.
But it error when I use it on visualize or discover
if(doc['message.keyword'].size() !=0 ){
if(/(unexpected)/.matcher(doc['message.keyword'].value).find()){
return "Unexpected Error";
}
else if(/(memory)/.matcher(doc['message.keyword'].value).find()){
return "Memory Error";
}
else if(/(memories)/.matcher(doc['message.keyword'].value).find()){
return "Memory Error";
}
else if(/(equipment)/.matcher(doc['message.keyword'].value).find()){
return "Equipment Error";
}
else if(/(equipments)/.matcher(doc['message.keyword'].value).find()){
return "Equipment Error";
}
else if(/(parse default_repo)/.matcher(doc['message.keyword'].value).find()){
return " Parse default_repo Failed";
}
else if(/(agent failed)/.matcher(doc['message.keyword'].value).find()){
return "Agent Failed";
}
else if(/(process terminated)/.matcher(doc['message.keyword'].value).find()){
return "Process Terminated with Error";
}
else if(/(timeout while waiting for task)/.matcher(doc['message.keyword'].value).find()){
return "Task Startup Timeout";
}
else if(/(transition call error)/.matcher(doc['message.keyword'].value).find()){
return "Transition Call Error";
}
else if(/(attempted status update)/.matcher(doc['message.keyword'].value).find()){
return "Status Update of Task not in Roster";
}
else if(/(end task)/.matcher(doc['message.keyword'].value).find()){
return "End Task Error";
}
else if(/(environment)/.matcher(doc['message.keyword'].value).find()){
return "Environment Error";
}
else if(/(error receiving event)/.matcher(doc['message.keyword'].value).find()){
return "Receiving Event Error ";
}
else if(/(descriptor constraints)/.matcher(doc['message.keyword'].value).find()){
return "Descriptor Constraints not Satisfied";
}
else if(/(cannot parse template)/.matcher(doc['message.keyword'].value).find()){
return "Can't Parse Template";
}
else if(/(failed to capture)/.matcher(doc['message.keyword'].value).find()){
return "Capture stdout/stderr Error";
}
else {return "Not Defined";}
}
else return "Missing"
Can someone tell me how to fix this? or just point what I missing.