How to logstash if field equals value assign other field value?

I have a logstash conf
field A : Value A
field B : Value B

———————————————————————————

I would like to become

The value of field A is equal to N/A, i will use the value of field B, as follows:
field A : N/A -> field A : Value B

Can someone provide an approach?

Does this look like what you need?

Test Conf

input { generator { lines => ['[{"fielda": "N/A", "fieldb": "valueb"},{"fielda": "valuea", "fieldb": "valueb"}]'] count => 1 codec => "json" } }
filter {
  if [fielda] == "N/A" {
    mutate {
      update => { "fielda" => "%{fieldb}" }
    }
  }
}
output { stdout { codec => json } }
1 Like

Thanks a lot! it work

1 Like

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