geerlingguy.fluentd

Ansibleロール: Fluentd

CI

Ansibleロールで、RedHat/CentOSまたはDebian/UbuntuにFluentdをインストールします。このロールは、Rubyを別にインストールする必要がない独立型のバージョンであるtd-agentをインストールします。td-agentとFluentdの違いはこちらで確認できます。

依存関係

特になし

ロール変数

利用可能な変数は以下にリストされており、デフォルト値も示しています(defaults/main.ymlを参照):

fluentd_version: 3

インストールするtd-agentのバージョン。v2、v3、v4の違いについてはこちらで詳細を確認できます。

fluentd_package_state: present

td-agentの状態; latestに設定すると、アップグレードまたはバージョンを変更します。

fluentd_service_name: td-agent
fluentd_service_state: started
fluentd_service_enabled: true

Fluentdサービスのオプションを制御します。

fluentd_plugins:
  - fluent-plugin-elasticsearch

# 代替形式:
fluentd_plugins:
  - name: fluent-plugin-elasticsearch
    version: '4.0.6'
    state: present

インストールするFluentdプラグインのリストです。

fluentd_conf_sources: |
  [デフォルト内容はdefaults/main.ymlを参照]

fluentd_conf_filters: |
  [デフォルト内容はdefaults/main.ymlを参照]

fluentd_conf_matches: |
  [デフォルト内容はdefaults/main.ymlを参照]

Fluentdがログデータを受信、フィルタリング、ルーティングする方法を制御するtd-agent.confファイルに配置される設定です。デフォルトでは基本的なオプションが設定されており、Treasure Dataにデータを送ることができますが、適切な値に上書きする必要があります。

たとえば、Apache HTTPサーバーのアクセスログを監視したい場合は、以下のようにソースを追加します:

fluentd_conf_sources: |
  <source>
    @type tail
    @id input_tail
    <parse>
      @type apache2
    </parse>
    path /var/log/httpd-access.log
    tag apache.access
  </source>

次に、apacheログエントリをElasticsearchにルーティングするには、以下のようにします:

fluentd_conf_matches: |
  <match apache.**>
    @type elasticsearch
    host log.example.com
    port 9200
    user myuser
    password mypassword
    logstash_format true
  </match>

Elasticsearchを使用するためには、fluent-plugin-elasticsearchプラグインをインストールする必要があります。

依存関係

特になし

サンプルプレイブック

- hosts: search

  vars:
    fluentd_conf_sources: |
      <source>
        @type tail
        @id input_tail
        <parse>
          @type apache2
        </parse>
        path /var/log/httpd-access.log
        tag apache.access
      </source>

  roles:
    - geerlingguy.fluentd

ライセンス

MIT / BSD

作者情報

このロールは2020年にJeff Geerlingによって作成されました。彼はAnsible for DevOpsの著者です。

インストール
ansible-galaxy install geerlingguy.fluentd
ライセンス
mit
ダウンロード
123.9k
所有者
Father, author, developer, maker. Sometimes called "an inflammatory enigma". #stl #drupal #ansible #k8s #raspberrypi #crohns