无法在logstash中解析日期

时间:2016-08-05 15:50:51

标签: elasticsearch logstash kibana

我需要解析我的日期并且它给我一个错误。

[mu0, Sigma0] = mixgauss_init(Q*M, *data*, 'diag');

我在阅读本文时的data.csv是这样的:

import java.util.HashSet;
import java.util.Random;
import java.util.Set;

public class LotteryGenerator {

    public static void main(String[] args) {

        //declare specified list of numbers
        int[] lotteryBank = {3, 9, 25, 41, 43, 50, 68};
        //get lottery numbers
        int[] lottery = getLottery(lotteryBank);

        System.out.println("The two lottery numbers are : [" + lottery[0] + ", " + lottery[1] + "]");

    }

    public static int[] getLottery(int[] lotteryBank) {
        //find the total number of elements, so that random number generated is one among these
        int indexRange = lotteryBank.length;
        //create an array to hold two random numbers
        int[] lottery = new int[2];
        //create an instance of Random
        Random r = new Random();
        //create a set to hold two unique random numbers
        Set<Integer> randomSet = new HashSet<Integer>();

        //iterate till two unique random numbers are found
        while(randomSet.size() != 2) {
            //get a random index
            int randomIndex = r.nextInt(indexRange);
            //add the element at random index to the set
            randomSet.add(lotteryBank[randomIndex]);
        }

        //convert random set to random array
        int index = 0;
        for(int x : randomSet) {
            lottery[index++] = x;
        }
        return lottery;
    }
}

我错过了什么地方?提前谢谢。

我的logstash终端只说这个:

input {  
  file {
    path => "/home/osboxes/ELK/logstash/data/data.csv"
    start_position => "beginning"    
  }
}
filter {  
  csv {
      separator => ","
      columns => ["Date","Open","High","Low","Close","Volume","Adj Close"]
  }


  mutate {convert => ["High", "float"]}
  mutate {convert => ["Open", "float"]}
  mutate {convert => ["Low", "float"]}
  mutate {convert => ["Close", "float"]}
  mutate {convert => ["Volume", "float"]}
}

output {  
    elasticsearch {
        action => "index"
        hosts => "localhost:9200"
        index => "stock"
        workers => 1
    }
    stdout {}
}

1 个答案:

答案 0 :(得分:0)

向过滤器添加日期声明:

date {
    match => [ "Date", "YYYY-MM-dd" ]
}