Logstash“插件的不可恢复”错误如何解决?

时间:2019-04-26 09:27:58

标签: elasticsearch apache-kafka logstash

我正在尝试将数据推入来自带有Logstash的kafka主题的elasticsearch中,但是当我启动自己的logstash时遇到了这个问题

错误代码:插件出现不可恢复的错误

该如何解决?配置文件如下。

 `input{
   kafka{
bootstrap_servers =>"localhosts:9092"
topics => ["cars"]
       }
  }
 filter{
   csv {
       separator =>","

    columns => [ "maker", "model", "mileage", "manufacture_year", "engine_displacement", "engine_power", "body_type", "color_slug", "stk_year", "transmission", "door_count", "seat_count", "fuel_type", "date_created", "date_last_seen", "price_eur" ]

      } 
   mutate {convert => ["mileage", "integer"] }
   mutate {convert => ["price_eur", "float"] }
   mutate {convert => ["engine_power", "integer"] }
   mutate {convert => ["door_power", "integer"] }
   mutate {convert => ["seat_count", "integer"] }
   }
  output{
      elasticsearch {
      hosts => ["localhost:9200"]
      index => "cars1"
      document_type=>"sold_cars"
      }
         stdout{}
      }`

1 个答案:

答案 0 :(得分:0)

convert突变过滤器是一个哈希,而不是一个数组:https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-convert

像这样尝试:

input {
    kafka {
        bootstrap_servers => "localhost:9092"
        topics => ["cars"]
    }
}

filter {
    csv {
        separator => ","
        columns => ["maker", "model", "mileage", "manufacture_year", "engine_displacement", "engine_power", "body_type", "color_slug", "stk_year", "transmission", "door_count", "seat_count", "fuel_type", "date_created", "date_last_seen", "price_eur"]
    }
    mutate {
        convert => {
            "mileage" => "integer"
            "price_eur" => "float"
            "engine_power" => "integer"
            "door_power" => "integer"
            "seat_count" => "integer"
        }
    }
}
output {
    elasticsearch {
        hosts => ["localhost:9200"]
        index => "cars1"
        document_type => "sold_cars"
    }
    stdout {}
}

您还可以在csv过滤器本身内部使用convert,如下所示:

csv {
    separator => ","
    columns => ["maker", "model", "mileage", "manufacture_year", "engine_displacement", "engine_power", "body_type", "color_slug", "stk_year", "transmission", "door_count", "seat_count", "fuel_type", "date_created", "date_last_seen", "price_eur"]
    convert => {
        "mileage" => "integer"
        "price_eur" => "float"
        "engine_power" => "integer"
        "door_power" => "integer"
        "seat_count" => "integer"
    }
}