Describe the issue:
I have created a Painless script to extract data from specific log messages. The script is intended to apply only to logs containing certain messages. However, currently, it’s applying to all logs, assigning a default value (0
) when the relevant message is not found. I also tried to change the returned value to ‘false’ and ‘null’, but it still showed the field name without any value.
I want to know how can I hide the painless script calculated field in conditions where there is no data at all.
The script is attached below.
Configuration:
if (doc[‘msg.keyword’].size() != 0 && doc[‘msg.keyword’].value.equals(‘starts processing request headers’)) {
return 1;
} else {
return false;
}
Relevant Logs or Screenshots: