fluntd学習——tail(入力プラグイン)

7211 ワード

tail(プラグイン入力)
http://docs.fluentd.org/articles/in_tail
tail Input Plugin
The  in_tail Input plugin allows Freuentd to read events from the tail of text files.Its behavior is simiar to the  tail -F command.in_tail 入力プラグインは、テキストファイルの末尾からイベントを読むことを許可します。その挙動はtail-f命令に似ている。
Example Configrationin_tail is included in Flouentd’s core.No additional installation process is required.追加のインストールプロセスは必要ありません。

  type tail
  path /var/log/httpd-access.log
  pos_file /var/log/td-agent/httpd-access.log.pos
  tag apache.access
  format apache2

 
Please see the Config File articale for the baic structure and syntax of the configration file.
参照してください 
  Config File
 の基本構造と文章文法の構成ファイルです。
How it Works
  • When Flouentd is first configred with  in_tail、it will start reading from the tail of that logs,not the begging.
  • Once the logs is rotated,Flouentd starts reading the new file from the begging.It keeps troc of the current inode number.
  • If  td-agent resttats,it starts reading from the last position td-agent read before the reretart.This position is recoded in the position file specified by the posfile parameter.
  • Flouentdが最初にインチングを配置するときtailプラグインは、beginingではなく、最後のログから読み始める。

  • 一旦ログが動いたら、Flouentdはbeginingから新しいファイルを読み始めます。現在のinode番号を追跡します。

  • もし  td-agent 再起動時は、再起動前に  td-agent最後の位置から読書を開始します。この位置は指定された位置に記録されたファイルのposパラメータです。なぜposの重要性があるかを説明します。
  • パラメータ
    type(required)
    The value must be  tail.
    path(required)
    The paths to read.Multile paths can be specified,separated by','
    パス読みだし。複数のパスを指定できます。これで説明できます。複数のログログを同時に集めることができます。もう一つのsourceを起こす必要はありません。)
    (required)
    The. 事件
    format(required)ログのフォーマットを指定します。
    The format of the logs.Itis the name of a template or regexp surrounded by'.
    ログのフォーマット。テンプレートの名前または正規表現の「/」囲いです。
    The regexp must have at least one named capture (?PATTERN).If the regexp has a capture named‘time’,it is used as the time of the event.You can specify the time format the time me me me theformat parameter.If the regexp has a capture named‘’、the(parameter+the)captured(is used as the event)
    正規表現には少なくともキャプチャという名前が必要です。
    (パターン正規表現に「time」という名前のキャプチャがある場合は、イベントとしての時間です。時間書式パラメータで時間書式を指定できます。正規表現に「タグ」という名前がある場合、 パラメータ+キャプチャ マークとしてのイベントです。
    The follwing templates are supported:
    以下のテンプレートのサポート:
  • レゲックス
  • 正規表現
  • The regexp for the format parameter can be specified. Flouentular is a great website to test your regexp for Flouentd configration.
    書式パラメータの正規表現を指定できます。
      Flouentular は、偉大なウェブサイトです。あなたのregexp Flouentdプロファイルをテストします。
  • apache2
  • Reads apache’s log file for the follwing fields:host,user,time,method,path,code,size,referer and agent.This template is anlogous to the follwing congfigration:
    ログファイルのapacheを読み込むのは、ホスト、ユーザ、時間、方法、パス、コード、サイズ、推薦人、エージェントです。このテンプレートは以下の構成に似ています。
    format /^(?[^ ]*) [^ ]* (?[^ ]*) \[(?
  • syslog
  • Reads syslog s’s output file for the follwing fields:time,host,ident,and message.This template is anlogous to the follwing congfiration:
    sylogの出力ファイル(例えば、/var/log/syslogs)を読み、次のフィールド:時間、ホスト、識別、およびメッセージ。このテンプレートは以下の構成に似ています。
    format /^(?
  • tsv or  csv
  • If you use tsv or csv format,please also specify the  keys parameter.
    tsvまたはcsvフォーマットを使うなら、キーパラメータも指定してください。
    format tsv
    keys key1, key2, key3
    time_key key2
    
    If you specify the  time_key parameter、it will be used to identify the timestamp of the record.The timestamp when Flantd reads the record is used by default.
    もしあなたが指定したら  time_key 記録のタイムスタンプを決定するために使用されます。タイムスタンプは、Flouentdが記録を読み込み、デフォルトで使用します。
    format csv
    keys key1, key2, key3
    time_key key3
    
  • json
  • One JSON map,per line.This the most straigh forward format:)
    format json
    
    The  time_key parameter can also be specified.
    format json
    time_key key3
    
    pos_file(highly recommanded)
    posファイル(強く推奨)
    This parameter is highly recommanded.Flouentd will record the position it last read into this file.
    このパラメータは高いおすすめです。Flouentdはこのファイルの最後に読んだ位置を記録します。
    pos_file /var/log/td-agent/tmp/access.log.pos
    
    time_フォーマット 時間の書式
    The format of the time field.This parameter is required only if the format includes a‘time’capture and it cannot be parsed atomatially.Please see Time((zhi)striftme for additional information.
    時間フィールドの書式。このパラメータは必要です。ただし、フォーマットに「時間」が含まれていると、自動的に解析できません。見てください Time me(zhi striftme)はもっと多くの情報を理解します。
    rotate_wait ループ待ち rotating 翻訳したほうがいいと思います。
    同前tail actually does a bit more than  tail -F itself.When rotating a file,some data may still need to be ritten to the old file as opposed to the new one.
    同前taiは確かにtail-f自体を超えています。rotatingをする いくつかのファイルは、新しいデータではなく、古いファイルに書き込む必要があります。
    同前tailtaes care of this by keeping a reference to the old file for some befor trantime before tranitioning copletely to the new file.This helps prevent data degnant for Bold fited for Bold front deultime。
    同前テールは、新しいファイルに完全に変更する前のいくつかの時間について、参照を保持することによって、この古いファイルを保護します。これはデータが古いファイルを紛失するように指定されるのを防止するのに役立ちます。デフォルトでは、この時間間隔は5秒です。
    ザロテーテwait parameter accepts a single integer representing the number of seconds you want this time interval to be.
    これはrotateですwait パラメータは整数を受け入れます。間隔を指定する秒数を表します。
     
     
    正規表現については、自分で設定したマシンで収集します。ログファイルのログマッチングの法則:
    クライアントflouentdでファイルを設定します。
     
    logデータ——ソースデータ[2013-03-29 07:21:55.83292]router-pid=14615 tid=7 a 93 fid=5354  DEBUG--Request body:「"host":"api.vcap.me","stats"latency":0,"request_"tags":"BAh 7 BjoOY 29 tcG 9 uZW 50 SSIUQ 2 xvdRDb 250 cm 9 sbGVyBjoGRVQ="reponse_"codes:「{respnses}」2 xx「:2」、「レスポンス」samples':2}}
     
    マッチの法則:
    format/\(?.*)(?[]*)-(?[?[^]*)(?[^]*)  (?[^ ]*) -- (?[^ ].*)$/
     time_フォーマット%Y-%m-%d%H:%M:%S
     
    mongodbデータテーブルで結果を調べます。
    {u}id":ObjectId("516 d 31 c 415 b 53374 d 000004"),"name":"router","pid="14615","tid="7 a 93","fid":"fid="5354","level":"DEBUG",",",info"red\"latency\0、\request_tags\\\\"BAh 7 BjoOY 29 tcG 9 uZW 50 SSIUQ 2 xvdRDb 250 cm 9 sbGVyBjoGRVQ=\"reponse_"codes\:\\reponses_2 xx\":2"、\"レスリング"(株)samples\":2""","time":ISO Date("2013-04-23 T 11:21:55 Z"))}。