【问题标题】:load array data mysql to ElasticSearch using logstash jdbc使用 logstash jdbc 将数组数据 mysql 加载到 ElasticSearch
【发布时间】:2016-05-14 01:41:07
【问题描述】:

您好,我是 ES 新手,我正在尝试将数据从“MYSQL”加载到“Elasticsearch”

尝试以数组格式加载数据时出现以下错误,请帮助

这里是mysql数据,需要新的&十六进制值列的数组数据

cid  color      new     hex      create            modified
1    100 euro   abcd   #86c67c  5/5/2016 15:48   5/13/2016 14:15
1    100 euro    1234   #fdf8ff  5/5/2016 15:48   5/13/2016 14:15

这里是logstash配置

input {
 jdbc {
   jdbc_driver_library => "/etc/logstash/mysql/mysql-connector-java-5.1.39-bin.jar"
   jdbc_driver_class => "com.mysql.jdbc.Driver"
   jdbc_connection_string => "jdbc:mysql://127.0.0.1:3306/test"
   jdbc_user => "root"
   jdbc_password => "*****"
   schedule => "* * * * *"

   statement => "select cid,color, new as 'cvalue.new',hexa_value as 'cvalue.hexa',created,modified from colors_hex_test order by cid"
   jdbc_paging_enabled => "true"
   jdbc_page_size => "50000"
}
}

output {
    elasticsearch {
        index => "colors_hexa"
        document_type => "colors"
        document_id => "%{cid}"
        hosts => "localhost:9200"

需要 cvalue (new, hexa) 之类的数组数据

{
  "_index": "colors_hexa",
  "_type": "colors",
  "_id": "1",
  "_version": 218,
  "found": true,
  "_source": {
    "cid": 1,
    "color": "100 euro",
    "cvalue" : {
            "new": "1234",
            "hexa_value": "#fdf8ff",
        }
    "created": "2016-05-05T10:18:51.000Z",
    "modified": "2016-05-13T08:45:30.000Z",
    "@version": "1",
    "@timestamp": "2016-05-14T01:30:00.059Z"
  }
}

这是我在运行 logstash 时遇到的错误

 "status"=>400, "error"=>{"type"=>"mapper_parsing_exception",
 "reason"=>"Field name [cvalue.hexa] cannot contain '.'"}}}, :level=>:warn}

【问题讨论】:

  • 是 mysql 中的 吗?或将数据作为输出包装在其中
  • 没有收到您的问题,抱歉

标签: elasticsearch logstash kibana-4 logstash-configuration


【解决方案1】:

您不能使用. 提供字段名称。但是你可以尝试添加:

filter {
  mutate {
    rename => { "new" => "[cvalue][new]" }
    rename => { "hexa" => "[cvalue][hexa]" }
  }
}

【讨论】:

    猜你喜欢
    相关资源
    最近更新 更多
    热门标签