简体   繁体   中英

Failed to parse @UNIX_MS from Logstash to Elasticsearch

So the data I want to store in Elasticsearch is an csv file. It contains the following:

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

Note that the first line equals the time in UNIX_MS.

I'm trying to send the data with logstash. Here is my config file:

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}"
    }
}

Here is part of piet.json:

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

Now i'm getting an error running the config file.

"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}

My stdout looks like this:

控制台输出

I'm just lost. How can I insert data from the csv file in Elasticsearch..

Solved it myself. Elasticsearch is complaining about the date, because it doesn't recognize the date correctly. So, I removed the mapping completely from Elasticsearch via the Kopf plugin.

I re-added the .json, including the following details. (Note the format)

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

It is working now. Huray

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM