Logstash:複数の構成ファイル(CONF)

Logstash:複数の構成ファイル(CONF)

複数の構成を処理するための方法、治療の複数:

  • 複数のパイプライン
  • プロファイルpiplelineの複数の処理

それは、入力データを受信し、キューに渡し、そこから論理データストリームを含むパイプラインは、作業者は、出力への最終出力を処理しています。この出力はElasticsearchまたは他のことができます。両方のケースについては、以下の、個別に説明します。

複数のパイプライン

cat apache.conf
 

    input {
      file {
        path => "/Users/liuxg/data/multi-input/apache.log"
        start_position => "beginning"
        sincedb_path => "/dev/null"
        # ignore_older => 100000
        type => "apache"
      }
    }
     
    filter {
        grok {
            match => {
                "message" => '%{IPORHOST:clientip} %{USER:ident} %{USER:auth} \[%{HTTPDATE:timestamp}\] "%{WORD:verb} %{DATA:request} HTTP/%{NUMBER:httpversion}" %{NUMBER:response:int} (?:-|%{NUMBER:bytes:int}) %{QS:referrer} %{QS:agent}'
            }
        }
    }
     
     
    output {
        stdout {
            codec => rubydebug
        }
     
        elasticsearch {
            index => "apache_log"
            template => "/Users/liuxg/data/apache_template.json"
            template_name => "apache_elastic_example"
            template_overwrite => true
      } 
    }
# cat daily.conf

    input {
      file {
        path => "/Users/liuxg/data/multi-pipeline/apache-daily-access.log"
        start_position => "beginning"
        sincedb_path => "/dev/null"
        type => "daily"
      }
    }
     
    filter {
        grok {
            match => {
                "message" => '%{IPORHOST:clientip} %{USER:ident} %{USER:auth} \[%{HTTPDATE:timestamp}\] "%{WORD:verb} %{DATA:request} HTTP/%{NUMBER:httpversion}" %{NUMBER:response:int} (?:-|%{NUMBER:bytes:int}) %{QS:referrer} %{QS:agent}'
            }
        }
    }
     
     
    output {
        stdout {
            codec => rubydebug
        }
     
        elasticsearch {
            index => "apache_daily"
            template => "/Users/liuxg/data/apache_template.json"
            template_name => "apache_elastic_example"
            template_overwrite => true
      } 
    }

次に、pipelines.ymlファイルを変更します。インストールディレクトリのlogstash、変更pipelines.ymlファイルの下の設定ファイルディレクトリで。

- pipeline.id: daily
 pipeline.workers: 1
 pipeline.batch.size: 1
 path.config: "/Users/liuxg/data/multi-pipeline/daily.conf"
- pipeline.id: apache
 queue.type: persisted
 path.config: "/Users/liuxg/data/multi-pipeline/apache.conf"

上記構成において、daily.conf apache.conf 2つの異なるpiplelineに入れました。

この操作が完了している設定します。longstashのインストールディレクトリに。以下のコマンドを使用してみましょう実行します。

./bin/logstash

ターミナルでは、あなたが同時に実行している2つのpipleがある見ることができる、あなたはまた、GoogleのインデックスKibanaで結果を見ることができます。

パイプライン

インストールディレクトリの下のconfigサブディレクトリがpipleline.ymlファイルにLogstash位置して変更し、それを変更することができます同じ。

- pipeline.id: my_logs
 queue.type: persisted
 path.config: "/Users/liuxg/data/multi-pipeline/*.conf"

すべてのマルチパイプライン/下のすべて/ユーザに位置/ liuxg /データ/ confにファイルがパイプラインに配置されています。

同様に上記の私たちのアプリケーションを実行するには:

./bin/logstash

私たちは、実行中の二つの同一の出力の結果を参照してください。これはなぜでしょうか?我々はそれを実行するためにpiplelineに配置された2つの.confファイルを置くためです、我々は2つの.confファイルを設置している標準出力2つの出力を持っています。

私たちは、Kibanaにして私たちの最後のインデックスデータを見ることができます:

我々は、彼らがpiplelineているので、それがある、2つのログはすべてのイベントをファイルが含まれ、apache_log 20年のデータを見ることができます。同様に、我々はapache_daily 20で同じデータを見ることができます。

おすすめ

転載: www.cnblogs.com/sanduzxcvbnm/p/12076557.html