添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
0
0

More than 3 years have passed since last update.

Elasticsearch > Logstash > TSVを読む

Posted at

pipeline config file(logstash.conf)を以下のように設定する

columnsにカラム名を設定する

logstash.con
input {
  file {
    path => ["/usr/share/logstash/data-path/*"]
    start_position => "beginning"
filter {
    separator => "  " # tab文字をセット,`\t`をセットしてはいけない    
    columns => ["column1", "column1", "column3"] # ファイルの1行目と同じカラム名と列数にする必要あり
    skip_header => false
    skip_empty_rows => true
    skip_empty_columns => true
    remove_field => "message"
output {
  stdout {codec => rubydebug }

カラム名を設定せずにautodetect_column_namesをTrueにして自動検出する
※ ファイル内の行処理順が保証されないので、logstash.ymlに設定を追加する必要がある。

logstash.con
input {
  file {
    path => ["/usr/share/logstash/data-path/*"]
    start_position => "beginning"
filter {
    separator => "  " # tab文字をセット,`\t`をセットしてはいけない    
    autodetect_column_names => true
    skip_header => false
    skip_empty_rows => true
    skip_empty_columns => true
    remove_field => "message"
output {
  stdout {codec => rubydebug }

のはずが、実行する度に1行目が列名と認識したり、2行目が列名と認識されたりばらばらな挙動となった。

以下の情報で解決した。要はマルチパイプラインがファイルの1行単位で動作しているので処理順はファイルの行の通りにならないとの事。

Autodetect_column_names take header from second row · Issue #67 · logstash-plugins/logstash-filter-csv
autodetect_column_names does not work with multiple worker threads · Issue #65 · logstash-plugins/logstash-filter-csv

よく見たら以下の公式マニュアルにも書いてあった。(見過ごしていた)
パイプラインワーカーを1に設定せよとのこと。

Csv filter plugin | Logstash Reference [7.10] | Elastic

Logstash pipeline workers must be set to 1 for this option to work.

logstash.ymlに設定するか、素直にcolumnsを設定したほうがよさそうです。

logstash.yml
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0