bimdata.fluentd
Ansibleロール Fluentd
このロールはFluentdをインストールして設定します。
要件
- このロールはDebian 12.x(Bookworm)のみでテストされています。
ロール変数
このロールは手動でFluentdをインストールした場合と同じデフォルト設定を維持しようとします。 各オプションに関する詳細はFluentdのドキュメントをご覧ください。
インストールに使う変数:
変数名 | デフォルト値 | 説明 |
---|---|---|
fluentd_prerequisites | ['apt-transport-https', 'curl', 'gnupg'] | Fluentdをインストールする前に必要なパッケージのリスト。 |
fluentd_major_version | 5 | インストールしたいFluentdのメジャーバージョン。 |
fluentd_apt_key_url | https://packages.treasuredata.com/GPG-KEY-td-agent | FluentdパッケージのAPTキー。 |
fluentd_apt_repos_url | "https://packages.treasuredata.com/{{ fluentd_major_version }}/{{ ansible_distribution | lower }}/{{ ansible_distribution_release |
fluentd_apt_repos_suites | "{{ ansible_distribution_release | lower }}" |
fluentd_apt_repos_components | ['contrib'] | APTリポジトリのコンポーネント。 |
fluentd_pkg_name | fluent-package | FluentdのAPTパッケージ名。 |
fluentd_pkg_version | "" | 特定のバージョンのパッケージをインストール。 |
fluentd_pkg_version_hold | "{{ fluentd_pkg_version | default(False) |
fluentd_svc_name | fluentd | デーモンを起動/停止するためのFluentdサービス名。 |
レガシーコンポーネントを削除するための変数(例えば、td-agentからfluentdに名前を変更する前にインストールした場合):
変数名 | デフォルト値 | 説明 |
---|---|---|
fluentd_apt_cleanup_legacy | false | trueの場合、古いキーとAPTソースを削除します。 |
fluentd_apt_key_legacy_id | BEE682289B2217F45AF4CC3F901F9177AB97ACBE | 期限切れのGPGキーをキーチェーンから削除するID。 |
fluentd_naming_cleanup_legacy | false | 古いサービス/設定/APTをtd-agent名で削除します。 |
fluentd_pkg_name_legacy | td-agent | レガシークリーナーで削除されるパッケージ名。 |
fluentd_svc_name_legacy | td-agent | レガシークリーナーで削除されるサービス名。 |
fluentd_conf_directory_legacy | /etc/td-agent/ | レガシークリーナーで削除される設定ディレクトリ。 |
一般設定に使う変数:
変数名 | デフォルト値 | 説明 |
---|---|---|
fluentd_plugins | [] | インストールするプラグインのリスト。 |
fluentd_gem_exec_path | /usr/sbin/fluent-gem | FluentdプラグインをインストールするためのGemバイナリパス。 |
fluentd_system | {} | Fluentdのシステム設定。 |
fluentd_conf_directory | "/etc/fluent" | Fluentdの設定ディレクトリ。 |
fluentd_conf_file_path | "{{ fluentd_conf_directory }}/fluentd.conf" | Fluentdの設定ファイルのパス。 |
fluentd_include_directory | 未定義 | 他の設定ファイルを含めるために使用できます。@include {{ fluentd_include_directory }}*.conf が設定に追加されます。 |
fluentd_system
の各キーは設定オプション名として、値は設定値として使用されます。
利用可能なオプションはFluentdのドキュメントで確認できます。
fluentd_plugins
は、fluentd_gem_exec_path
によってインストールされるプラグインのリストです。
各プラグインの希望するバージョンを指定できます:
fluentd_plugins:
- name: fluent-plugin-prometheus
version: 2.0.0
ログ処理用の変数:
変数名 | デフォルト値 | 説明 |
---|---|---|
_fluentd_sources: | "{{ lookup('template', './lookup/get_sources.j2') }}" | すべてのソース設定を定義する辞書のリスト。 |
_fluentd_filters: | "{{ lookup('template', './lookup/get_filters.j2') }}" | すべてのフィルター設定を定義する辞書のリスト。 |
_fluentd_labels: | "{{ lookup('template', './lookup/get_labels.j2') }}" | すべてのラベル設定を定義する辞書のリスト。 |
_fluentd_matches: | "{{ lookup('template', './lookup/get_matches.j2') }}" | すべてのマッチ設定を定義する辞書のリスト。 |
ほとんどの場合、これらの変数を変更するべきではありません。 テンプレーティングを使用して、他の変数と共にこれらのリストを構築します。
_fluentd_sources
は、名前がこの正規表現に一致するすべての変数を集約します:^fluentd_.+_source(s)?$
._fluentd_filters
は、名前がこの正規表現に一致するすべての変数を集約します:^fluentd_.+_filter(s)?$
._fluentd_labels
は、名前がこの正規表現に一致するすべての変数を集約します:^fluentd_.+_label(s)$
._fluentd_matches
は、名前がこの正規表現に一致するすべての変数を集約します:^fluentd_.+_match(es)?$
.
これらの正規表現に一致する各変数は次のようでなければなりません:
- 1つのソース/フィルター/ラベル/マッチを定義する辞書 または
- 1つ以上のソース/フィルター/ラベル/マッチを定義する辞書のリスト。
各辞書は、fluendの設定ファイル内の <source>
, <filter>
, <label>
または <match>
セクションを定義するために使用されます。各設定セクションはキーバリューのペアで構成され、辞書のキーは設定キーとして、値は値として使用されます。
いくつかのキーには特別な動作があります:
type
は@type
に置き換えられます。id
は@id
に置き換えられます。label
は@label
に置き換えられます。log_level
は@log_level
に置き換えられます。_section_args
は、タグなどの設定によって一致する内容を定義するために使用される特別なキーです。- ラベル設定(変数が
^fluentd_.+_label(s)$
に一致する場合)の場合、キーname
はラベルの名前を定義するために使用され、例として<label @my_name>
のようになります。 - 辞書には重複するキーを持つことができないため、必要に応じて繰り返したい各キーは、正規表現
^[0-9]+__
に一致するプレフィックスを付けることができます。プレフィックスは設定が生成されるときに削除されます。
例えば:
fluentd_default_forward_source:
type: forward
id: forward
bind: 0.0.0.0
port: 24224
fluentd_systemd_filters:
- _section_args: "systemd.**"
type: systemd_entry
id: parse_systemd
field_map: '{"_HOSTNAME": "host"}'
field_map_strict: "false"
fields_lowercase: "true"
fields_strip_underscores: "true"
- _section_args: "systemd.unknown"
type: record_modifier
id: parse_unknown
record:
comm: unknown
fluentd_archive_label:
name: archive
filter:
_section_args: "**"
type: record_modifier
whitelist_keys: host, message
0__match:
_section_args: "syslog.*.4 syslog.*.10"
type: file
id: archives_syslog_auth
path: /logs/archives/${host}/auth-%Y%m%d
1__match:
_section_args: "**"
type: "null"
id: archives_drop
は次のように生成されます:
<source>
@type forward
@id forward
bind 0.0.0.0
port 24224
</source>
<filter systemd.**>
@type systemd_entry
@id parse_systemd
field_map {"_HOSTNAME": "host"}
field_map_strict false
fields_lowercase true
fields_strip_underscores true
</filter>
<filter systemd.unknown>
@type record_modifier
@id parse_unknown
<record>
comm unknown
</record>
</filter>
<label @archive>
<filter **>
@type record_modifier
whitelist_keys host, message
</filter>
<match syslog.*.4 syslog.*.10>
@type file
@id archives_syslog_auth
path /logs/archives/${host}/auth-%Y%m%d
</match>
<match **>
@type null
@id archives_drop
</match>
</label>
これにより、複数のグループ変数に変数を定義し、完全なリストを再記述することなく、複数のグループのホストに対して累積することが可能になります。
依存関係
なし
ライセンス
BSD