We had given a task, for adding Tag but facing issue in it

We had given a task, but facing issue in it. Task is -

Try adding tag A if the data read is a.

a
b
a
c
d

Ensure that the input data is tagged with type as test , and write the output to the file output.txt in the path usr/share/logstash.

input { 
        stdin { 
                add_tag => ["A"]
                type => "test" 
                path => ["/usr/share/logstash/output.txt"]
                 } 
        } 

Please let us know our mistake

your input config will add tag [“A”] and type “test” to any events coming to that input.

if you need to do conditional tags, you need to use filter plugin

to write outputs , use file output plugin

We need dis

tag A if the data read is a.

a
b
a
c
d

you can use mutate filter

something like

filter { 
if [<field_name_>] == “A” { 
   mutate => { 
      add_tag => “A” }
   }
}

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