首页 > 其他分享 >fluentd中,sample输入插件的作用是什么?

fluentd中,sample输入插件的作用是什么?

时间:2022-12-12 11:35:33浏览次数:54  
标签:11 fluentd 插件 12 0500 sample world hello


in_sample输入插件的作用是什么?

 

  • sample输入插件,用来产生样本事件。
  • 主要用于:测试,调试,和压力测试。
  • 这个插件,包含在fluentd的核心代码中
  • sample是由dummy插件而来。dummy在1.11.1版本之后,改名为sample.

 

示例配置

 

<source>
  @type sample
  sample {"hello":"world"}  # 后面是具体生成的数据
  tag sample
</source>

<match sample.**>
  @type stdout
</match>

 

 

fluentd是1.11.1及之前的版本,使用如下的配置

<source>
  @type dummy
  dummy {"hello":"world"}
  tag dummy
</source>

<match sample.**>
  @type stdout
</match>

 

 

修改配置后,重启fluentd服务

 

 systemctl restart td-agent

 

 

查看fluentd的日志

2022-12-11 21:13:16.025463038 -0500 sample: {"hello":"world"}
2022-12-11 21:13:17.030226348 -0500 sample: {"hello":"world"}
2022-12-11 21:13:18.034567035 -0500 sample: {"hello":"world"}
2022-12-11 21:13:19.035534972 -0500 sample: {"hello":"world"}
2022-12-11 21:13:20.041229570 -0500 sample: {"hello":"world"}
2022-12-11 21:13:21.044743524 -0500 sample: {"hello":"world"}
2022-12-11 21:13:22.050372237 -0500 sample: {"hello":"world"}
2022-12-11 21:13:23.054434973 -0500 sample: {"hello":"world"}
2022-12-11 21:13:24.057681448 -0500 sample: {"hello":"world"}
2022-12-11 21:13:25.061615612 -0500 sample: {"hello":"world"}
2022-12-11 21:13:26.064179152 -0500 sample: {"hello":"world"}

 

可以看到,每隔1秒钟,就会产生一次,样本或者说样例事件。

 

参数说明

 

sample有如下的其他的可以配置的参数

 

sample

 

后面接要生成的样例数据。是json格式。

 

数组形式,或者对象格式。

[{"message":"sample"}]

 

  • 对象形式(大括号)
<source>
  @type sample
  sample {"hello":"world","time":"firsttest"}
  auto_increment_key number
  tag sample
  rate 3
</source>

<match sample.**>
  @type stdout
</match>

 

 

日志

 

2022-12-11 22:02:12.015593374 -0500 sample: {"hello":"world","time":"firsttest","number":96}
2022-12-11 22:02:12.015692296 -0500 sample: {"hello":"world","time":"firsttest","number":97}
2022-12-11 22:02:12.015711858 -0500 sample: {"hello":"world","time":"firsttest","number":98}
2022-12-11 22:02:13.019935712 -0500 sample: {"hello":"world","time":"firsttest","number":99}
2022-12-11 22:02:13.020026300 -0500 sample: {"hello":"world","time":"firsttest","number":100}
2022-12-11 22:02:13.020047705 -0500 sample: {"hello":"world","time":"firsttest","number":101}
2022-12-11 22:02:14.024082817 -0500 sample: {"hello":"world","time":"firsttest","number":102}
2022-12-11 22:02:14.024174741 -0500 sample: {"hello":"world","time":"firsttest","number":103}
2022-12-11 22:02:14.024206715 -0500 sample: {"hello":"world","time":"firsttest","number":104}
2022-12-11 22:02:15.028988007 -0500 sample: {"hello":"world","time":"firsttest","number":105}

 

 

  • 数组格式(方括号)

 

<source>
  @type sample
  sample [{"hello":"world","time":"firsttest"},{"name":"trybest"}]
  auto_increment_key number # 每个数据都有自增key和value
  tag sample
  rate 3  # 每秒钟3个事件
</source>

<match sample.**>
  @type stdout
</match>

 

 

日志

 

每个json对象,都是一个单独的事件!

 

size

每次触发,事件流的事件数(默认:1)

<source>
  @type sample
  sample {"hello":"world"}  # 后面是具体生成的数据
  tag sample
  size 3
</source>

<match sample.**>
  @type stdout
</match>

 

修改为3,之后,看fluentd的日志

 

每一次的采样,都会生成3个事件(size 3)

 

rate

 

控制每秒钟,产生的事件数(默认:1)—— 一个事件是一个事件流。

 

<source>
  @type sample
  sample {"hello":"world"}  # 后面是具体生成的数据
  tag sample
  rate 4
</source>

<match sample.**>
  @type stdout
</match>

 

 

重启fluentd服务,查看日志

 

每秒钟生成4个事件。

 

size和rate之间,有什么区别呢?

 

如果是如下的配置,既有size,又有rate

 

<source>
  @type sample
  sample {"hello":"world"}
  tag sample
  rate 4
  size 3
</source>

<match sample.**>
  @type stdout
</match>

 

查看日志

 

每次输出12个事件。

 

所以:

 

rate: 每秒钟的事件数,或者说事件流的数量。

 

size: 一个事件流中的事件数

 

两个参数都有的话,就是相乘的关系。

 

auto_increment_key

 

可以在采样数据中,定义一个自增的字段。

 

如:

<source>
  @type sample
  sample {"hello":"world"}
  auto_increment_key number  # 指定自增的key
  tag sample
  rate 3
</source>

<match sample.**>
  @type stdout
</match>

 

 

输出的日志:增加了number的key,值是一个自增的值,附加在采样数据的后面。

 

 

标签:11,fluentd,插件,12,0500,sample,world,hello
From: https://www.cnblogs.com/chuanzhang053/p/16975585.html

相关文章

  • 如何实现ignite的安全插件(security plugin)
    Ignite可以实现自定义的安全插件,以下实现在2.13.0测试可行。1.如何实现自定义的安全插件第一步:需要定义一个提供插件的类,它会被IgniteKernal在启动时调用,主要实现的是cre......
  • [笔记]Volatility 取证工具使用以及Hollow插件使用
    ​​Volatility内存取证使用​​文章目录​​前言​​​​环境​​​​使用Dumpit生成内存镜像​​​​使用VMware的内存镜像​​​​安装Volatility​​​​使用HollowFind......
  • vb6怎么调用大漠插件
    首先下载大漠插件,版本是3.1233  https://wwon.lanzout.com/iNl8Xhfx75c打开vb6引用dm.dll创建两个变量 dimdm,ver鼠标点击事件PrivateSubCommand1_Click()v......
  • 安装Sublime Text 3插件的方法:
    安装SublimeText3插件的方法:直接安装安装Sublimetext3插件很方便,可以直接下载安装包解压缩到Packages目录(菜单->preferences->packages)。使用PackageControl组件安装也......
  • 全栈开发必备的10款Sublime Text 插件
    全栈开发必备的10款SublimeText插件SublimeText具有漂亮的用户界面和强大的功能,例如代码缩略图,多重选择,快捷命令等。SublimeText 更妙的是它的可扩展性。所以,这里......
  • 2011年6月几个不错的jquery插件
    1ROUNDYJQuery轮转图墙[img]http://bloggerspath.com/wp-content/uploads/2011/07/roundy-jquery-gallery.jpg[/img]这个插件的特点是,象俄罗斯......
  • Web电子表格插件、在线Excel插件、在线Spreadsheet插件、大量数据行-百万数据行插件、
    实现在线表格的方式有:1、以HTML的Table元素实现,主要靠虚拟渲染优化性能,体验较差,插件却很多。2、以HTML的Canvas绘图实现,得益于Canvas的高性能,体验可以优化到极致,但绘图相......
  • sft1200插件安装|ssr|istore
    之前都是使用代理软件上网,github都得挂(github访问非常玄学)后来买了xbox,发现xbox上有Netflix,所以最终选择软路由,挑来挑去最终咸鱼130收了这个路由器,比r2s便宜还带wifi,主要......
  • Vue2(笔记30) - 脚手架 - 插件
    插件Vue的插件功能可以整合之前所有的全局配置,也支持传参,使用起来比较强大;Vue 的插件,本质上是一个 对象;要求这个对象中,必须包含install() 方法;第一步:定义一个插件文件;pu......
  • VSCode离线安装插件报错Unable to install extension 'formulahendry.code-runner' as
    1.将下载好的插件放到D:\MicrosoftVSCode\bin下然后shift+右键输入命令code--install-extension文件名,安装失败2.把插件.visx改为.zip,打开插件找到package.jso......