4、fluentd之配置文件的格式
文章目录
- source
- match
- filter
- label
- system
- include
- 通配符
- 配置文件中的参数类型
- 多个match之间的顺序
- 检查配置文件是否可用
source
"source": where all the data come from
source:就是输入源(input),比较常用的有两个插件一个是http,一个是forward(tcp)
其它的插件,可以去官网查找
# Receive events from 24224/tcp
# This is used by log forwarding and the fluent-cat command
<source>@type forward # 这个就是表示插件port 24224
</source># http://this.host:9880/myapp.access?json={"event":"data"}
<source>@type httpport 9880
</source>
match
"match": Tell fluentd what to do
match:指定输出的目的(output)
# Receive events from 24224/tcp
# This is used by log forwarding and the fluent-cat command
<source>@type forwardport 24224
</source># http://this.host:9880/myapp.access?json={"event":"data"}
<source>@type httpport 9880
</source># Match events tagged with "myapp.access" and
# store them to /var/log/fluent/access.%Y-%m-%d
# Of course, you can control how you partition your data
# with the time_slice_format option.
<match myapp.access> @type file # 这个就是output插件path /var/log/fluent/access
</match>
filter
"filter": Event processing pipeline
filter:可以理解为过滤器
流程如下:
Input -> filter 1 -> ... -> filter N -> Output
如下为record_transformer
filter插件实例
# http://this.host:9880/myapp.access?json={"event":"data"}
<source>@type httpport 9880
</source><filter myapp.access>@type record_transformer<record>host_param "#{Socket.gethostname}"</record>
</filter><match myapp.access>@type filepath /var/log/fluent/access
</match>
label
就是为了降低tag过滤的复杂性
<source>@type forward
</source><source>@type tail@label @SYSTEM # 这个input 直接进到label 哪里进行处理
</source><filter access.**>@type record_transformer<record># ...</record>
</filter>
<match **>@type elasticsearch# ...
</match><label @SYSTEM><filter var.log.middleware.**>@type grep# ...</filter><match **>@type s3# ...</match>
</label>
system
主要设置一些系统配置的
- log_level
- suppress_repeated_stacktrace
- emit_error_log_interval
- suppress_config_dump
- without_source
- process_name (only available in system directive. No fluentd
option)
在td-agent.conf文件中添加如下
<system>process_name fluentd1
</system>
% ps aux | grep fluentd1
foo 45673 0.4 0.2 2523252 38620 s001 S+ 7:04AM 0:00.44 worker:fluentd1
foo 45647 0.0 0.1 2481260 23700 s001 S+ 7:04AM 0:00.40 supervisor:fluentd1
include
就是导入
第一步:先编写source.conf
<source>@type httpport 8887bind 0.0.0.0
</source>
第二步:编写td-agent.conf
文件
@include ./source.conf # 这一步:就会将上面的内容导入到这里
<filter test.cycle>@type grep<exclude>key actionpattern ^login$</exclude>
</filter><label @STAGING><filter test.cycle>@type grep<exclude>key actionpattern ^logout$</exclude></filter><match test.cycle>@type stdout</match>
</label><match test.cycle>@type stdout
</match>
通配符
filter 和 match 标签中的tag 通配符号
*
:匹配满足一个tag部分的事件, 比如: a.*, 它将匹配a.b这样的tag, 但是不会处理a或者a.b.c这类tag**
:匹配满足0个或多个tag部分,比如: a.**, 它将匹配a, a.b, a.b.c这三种tag{X,Y,Z}
:匹配满足X,Y或者Z的tag, 比如: {a, b}将匹配a或者b,但是不会匹配c。这种格式也可以和通配符组合使用,比如a.{b.c}.*或a.{b.c}.*#{...}
:会将里面的内容当作ruby表达式处理:比如
<match "app.#{ENV['FLUENTD_TAG']}">@type stdout
</match>
如果设置了环境变量FLUENTD_TAG
为dev
,那上面等价于app.dev
- 当指定了多个模式时(使用一个或多个空格分开),只要满足其中任意一个就行.比如:
<match a b>
匹配a和b
<match a.** b.*>
匹配a, a.b, a.b.c, b.d等
配置文件中的参数类型
每个Fluentd插件都有一组参数。例如,in_tail具有rotate_wait和pos_file等参数。每个参数都有一个与之关联的特定类型。它们的定义如下:
string
:字符串,最常见的格式,详细支持语法见文档[^literal];integer
:整数float
:浮点数;size
大小,仅支持整数<INTEGER>k
或<INTERGER>K
;<INTEGER>m
或<INTERGER>M
;<INTEGER>g
或<INTERGER>G
;<INTEGER>t
或<INTERGER>T
。time
:时间,也只支持整数;<INTEGER>s
或<INTERGER>S
;<INTEGER>m
或<INTERGER>M
;<INTEGER>h
或<INTERGER>H
;<INTEGER>d
或<INTERGER>D
。
array
:按照 JSON array 解析
完整格式的写法:["key1", "key2"]
简写:key1,key2
hash
:按照 JSON object 解析
完整格式的写法:{"key1":"value1", "key2":"value2"}
简写:key1:value1,key2:value2
多个match之间的顺序
当有多个match, 需要注意一下它们的顺序, 如下面的例子,第二个match永远也不会生效
# ** matches all tags. Bad :(
<match **>@type blackhole_plugin
</match><match myapp.access>@type filepath /var/log/fluent/access
</match>
如果将filter放在match之后,那么它也永远不会生效,正确的用法如下:
# You should NOT put this <filter> block after the <match> block below.
# If you do, Fluentd will just emit events without applying the filter.
<filter myapp.access>@type record_transformer...
</filter><match myapp.access>@type filepath /var/log/fluent/access
</match>
检查配置文件是否可用
fluentd --dry-run -c fluent.conf
4、fluentd之配置文件的格式相关推荐
- C/C++ ini配置文件的格式及如何读写ini配置文件
一.ini配置文件的格式 为什么要用INI文件?如果我们程序没有任何配置文件时,这样的程序对外是全封闭的,一旦程序需要修改一些参数必须要修改程序代码本身并重新编译,这样很不好,所以要用配置文件,让程序 ...
- yum客户端的配置文件的格式
yum客户端的配置文件放在本地的/etc/yum.repos.d/*.repo 配置文件的格式为 [仓库名1] name=仓库描述 baseurl=仓库位置 enabled=0/1(0:不 ...
- 【Prometheus】Prometheus验证配置文件yml格式
prometheus验证配置文件yml格式 ${PROMETHEUS_HOME}/promtool check config prometheus.yml
- .ini配置文件书写格式(转)
为什么要用INI文件?如果我们程序没有任何配置文件时,这样的程序对外是全封闭的,一旦程序需要修改一些参数必须要修改程序代码本身并重新编译,这样很不好,所以要用配置文件,让程序出厂后还能根据需要进行必要 ...
- Python3 configparser值为多行时配置文件书写格式
一.说明 一般而言ini配置文件键值对都是一行就完事了,但有时候我们想配置的值就是由多行组成,这里说明此时配置格式该如何书写. 二.书写格式 如果值为多行,那么在第一行外的后续所有行前加入至少一个空格 ...
- linux c配置文件书写格式,读取配置文件源代码[linux c]
转自:http://gcody.wwww.blog.ccidnet.com/blog-htm-do-showone-uid-36931-type-blog-itemid-114988.html 自己今 ...
- ini配置文件的格式
http://blog.163.com/lyzaily@126/blog/static/42438837200911901541762/ ini文件的写入和读取的MFC编程 http://jingya ...
- fluentd mysql_使用Fluentd + MongoDB构建实时日志收集系统
日志处理场景 日志量大 日志分散不易进行统一分析 难以添加有效监控 系统实现 Fluentd(td-agent) MongoDB Python Script(PyMongo module) Zabbi ...
- 微服务架构日志集中化 安装 EFK (Fluentd ElasticSearch Kibana) 采集nginx日志
本文描述如何通过FEK组合集中化nginx的访问日志.本人更喜欢按顺序来命名,所以使用FEK而不是EFK. 首先在nginx服务器上执行以下操作. 安装ruby http://blog.csdn.ne ...
最新文章
- NumPy 高级索引
- C语言函数题-P字符串的比较
- 频率概率与贝叶斯概率
- php getid3,PHP getID3类的使用方法学习笔记【附getID3源码下载】
- java jdbc连接db2数据库_Java连接db2数据库(常用数据库连接五)
- 手机浏览器网址_打开URL(在其他应用中访问网址)app下载-打开URL(在其他应用中访问网址)v2.6安卓版下载...
- Spring Cloud Config Server
- 计算机图形学----投影矩阵
- opencv之waitKey()与waitKeyEx()的区别
- Windows11快捷键大全 win11常用快捷键介绍
- php study pro,phpStudy Pro官方下载|
- 如何阅读一本书-读书笔记
- python docx文档内容提取与写入(汇总)
- 数据库系统设计综合实验
- 碱基数据处理中的算法研究
- 学习笔记——LED跑马灯
- xilinx ip video
- Word的常用操作和快捷键
- Htc Vive详细图文安装教程
- JavaFX专业开发者与业余开发者之间就差一个一个Icon packs