geerlingguy.fluentd
Ansible 角色: Fluentd
这是一个安装 Fluentd 的 Ansible 角色,支持 RedHat/CentOS 或 Debian/Ubuntu 系统。该角色安装 td-agent
,它是一个独立版本,不需要单独安装 Ruby。详情请见 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 获取默认内容]
将放入 td-agent.conf
文件中的配置,该文件控制 Fluentd 如何监听、过滤和路由日志数据。默认设置了基本选项,可以将数据直接导向 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 需要安装 Fluentd 插件 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
作者信息
该角色由 Jeff Geerling 于 2020 年创建,他是 Ansible for DevOps 一书的作者。
关于项目
Fluentd for Linux.
安装
ansible-galaxy install geerlingguy.fluentd
许可证
mit
下载
123.9k
拥有者
Father, author, developer, maker. Sometimes called "an inflammatory enigma". #stl #drupal #ansible #k8s #raspberrypi #crohns