【问题标题】:Failed to parse @UNIX_MS from Logstash to Elasticsearch无法将 @UNIX_MS 从 Logstash 解析到 Elasticsearch
【发布时间】:2016-10-15 04:44:08
【问题描述】:

所以我想存储在 Elasticsearch 中的数据是一个 csv 文件。它包含以下内容:

1465309033156,84,http://test.com/purchase.php,200,OK,ThreadGroup 1-3,true,6,6,84,testPC,0
1465309033469,176,http://test.com/,200,OK,ThreadGroup 1-7,true,7,7,176,testPC,91

请注意,第一行等于 UNIX_MS 中的时间。

我正在尝试使用 logstash 发送数据。这是我的配置文件:

input {
    file {
        sincedb_path => "NUL"
        ignore_older => 0
        type => "csv"
        path => ["C:/result/piet.jtl"]
        start_position => "beginning"
    }
}
filter {
    csv {
        columns => ["@jmeter_timestamp", ...]
        separator => ","
    }
    date {
        locale => "en"
        match => ["@jmeter_timestamp", "UNIX_MS"]
        remove_field => ["@jmeter_timestamp"]
        target => "@timestamp"
        timezone => "Europe/Amsterdam"
    }
}
output {
    elasticsearch {
        template => "c:/result/piet.json"
        template_name => "piet"
        hosts => ["192.168.43.51:9200"]
        index => "piet-%{+YYYY.MM.dd}"
    }
}

这是 piet.json 的一部分:

"mappings": {
    "logs": {
        "properties": {
            "@timestamp": {
                "type": "date"
            },

现在我在运行配置文件时遇到错误。

"error"=>{
  "type"=>"mapper_parsing_exception",
  "reason"=>"failed to parse [@timestamp]",
  "caused_by"=>{
    "type"=>"illegal_argument_exception", 
    "reason"=>"Invalid format: \"2016-06-07T14:17:34.611Z\" is malformed at \"-06-07T14:17:34.611Z\""
  }}}}, :level=>:warn}

我的标准输出如下所示:

我只是迷路了。如何在 Elasticsearch 中插入 csv 文件中的数据..

【问题讨论】:

    标签: ruby json templates elasticsearch logstash


    【解决方案1】:

    自己解决了。 Elasticsearch 抱怨日期,因为它不能正确识别日期。 因此,我通过 Kopf 插件从 Elasticsearch 中完全删除了映射。

    我重新添加了 .json,包括以下详细信息。 (注意格式)

    "mappings": {
           "logs": {
           "properties": {
               "@timestamp": {
                   "type": "date",
                 "format" : "strict_date_optional_time||epoch_millis"
    

    它现在正在工作。万岁

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-21
      相关资源
      最近更新 更多