How to match data in logstash one data input from API and second from csv file on server

Viewed 41

I have tried all possible case but unable to match data between API and CSV file. my ultimate goal is read host key from REST API and matching with CSV file and print respective OS. Please suggest, Configuration as below -

    input{
  http{
      host => "*****"
      port => "****"
      type => "api_input"
     }
  file {
     path => "/etc/logstash/conf.d/Event.csv"
     start_position => "beginning"
     sincedb_path => "/dev/null"
  }
}
filter {
  csv {
      separator => ","
      skip_header => "true"
      columns => ["server", "os"]
      }
if [server] == [result][host] {
         mutate { add_field => { "OS_Name" => "%{[os]}" } }
           }

else{drop {}}
}
output {
  stdout {
    codec => rubydebug
    }
}

csv file data :- server_1,Windows server_2,Linux server_3,Unix server_4,Windows

API data :- {"result":[{"host":"server_4","parameter":"22"}]}

1 Answers

The translate filter can do a lookup of a field in a two column CSV file.

Related