如何在logstash中加载CSV文件

Lov*_*ika 5 logstash

我正在尝试在logstash中加载CSV文件,但它没有读取文件而没有在elasticsearch中创建索引我需要读取elasticsearch中的CSV文件.在配置文件中尝试了一些更改.

我的配置文件

input {
    file {
        type => "csv"
        path => "/root/installables/*.csv"
        start_position => beginning
    }
}

filter {
    grok {
        match => { "message" => "%{COMBINEDAPACHELOG}" }
    }
}

output {
    elasticsearch {
        hosts => localhost
        index => "client"
    }
}
Run Code Online (Sandbox Code Playgroud)

有谁可以告诉如何在logstash中加载CSV文件?

rhe*_*ndo 10

我认为你应该放一个"csv"过滤器.我让它像这样工作:

input {
  file {
    path => "/filepath..."
    start_position => beginning
    # to read from the beginning of file
    sincedb_path => "/dev/null"
  }
}

filter {
    csv {
        columns => ["COL1", "COL2"]
    }
}

output {
    stdout { codec => rubydebug }
    elasticsearch {
        host => "localhost"
        index => "csv_index"
    }
}
Run Code Online (Sandbox Code Playgroud)

此外,添加stdout作为输出可帮助您调试并知道文件是否正在加载