Logstash translate filter for multiple fields


(BIJAY) #1

Hi,

I want to drop the logs based on multiple fields.

Below is the content of drop.yml

logstash : '{"info": "drop"}'

e.g. I want to drop the loglines which has contain the "component" : "logstash" and "severity": "info"

I want to do this dynamically.

    translate {
        field => "component"
        destination => "logstat"
        dictionary_path => "/tmp/drop.yml"
    }
    json {
        source => "logstat"
        target => "severity"
    }
    if [target] == "drop" {
        drop { }
    }

The input logline:

{"nodetype":"haproxy","ssinst":"001","component":"logstash","severity":"info","logsource":"log"}
{"nodetype":"haproxy","ssinst":"001","component":"logstash","severity":"debug","logsource":"log"}
{"nodetype":"haproxy","ssinst":"001","component":"logstash","severity":"error","logsource":"log"}
{"nodetype":"haproxy","ssinst":"001","component":"kafka","severity":"error","logsource":"log"}
{"nodetype":"haproxy","ssinst":"001","component":"logstash","logsource":"log"}


How to access the value in the logstash metadata
(BIJAY) #2

This can be done using two translate sections, but I want single source for comparison.


(BIJAY) #3

If I want to drop all the logs of a component want to drop based on the condition:

"component":"all":"drop"
or
"component":"info":"drop" 

(BIJAY) #4

Can anyone please suggest how to proceed?

Thanks
Bijay


(system) #5

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.