fluentd 配置文件中label的作用是什么?
在正常的情况下,在fluentd的配置文件中,是像下面这样进行配置的:
<source> @type http port 8888 bind 0.0.0.0 </source> <filter test.cycle> @type grep <exclude> key action pattern ^logout$ </exclude> </filter> <match test.cycle> @type stdout </match>
那么,对于一个事件数据(event),是按照 一步一步顺序的方式,从上到下 进行处理的。
那这样存在的一个问题是什么呢?随着插件的不断的增多,数据源的不断的增多,整个配置文件的可读性就会下降了。为了解决这个问题,就引入了label
label
label就是为了解决配置文件复杂度的问题,增加了一种路由的规则,不通过顺序的步骤进行执行。而是通过label直接定位到路由的部分,比如下面的配置文件:
<source> @type http bind 0.0.0.0 port 8888 @label @STAGING </source> <filter test.cycle> @type grep <exclude> key action pattern ^login$ </exclude> </filter> <label @STAGING> <filter test.cycle> @type grep <exclude> key action pattern ^logout$ </exclude> </filter> <match test.cycle> @type stdout </match> </label>
通过@label参数 @STAGING,就直接跳转到下面的处理部分了:
<label @STAGING>
... ...
</label>