如何使用 Logstash 转换数组中的所有值?

发布于 2025-01-20 04:59:13 字数 1151 浏览 2 评论 0原文

我通过 Logstash 在 ELasticsearch 中索引日志,其中包含一个带有代码数组的字段,例如:

indicator.codes : [ "3", "120", "148" ]

Logstash 中是否有某种方法可以在 csv 中查找这些代码并将类别和描述保存在 2 个新字段中,例如 Indicator.categoriesindicator.descriptions

具有 3 列的 csv 子集:

Column 1 => indicator.code
Column 2 => indicator.category
Column 3 => indicator.description
3;Hiding;There are signs in the header
4;Hiding;This binary might try to schedule a task
34;General;This is a 7zip selfextracting file
120;General;This is a selfextracting RAR file
121;General;This binary tries to run as a service
148;Stealthiness;This binary uses tunnel traffic

我一直在查看 csv 过滤器和翻译过滤器,但它们似乎无法查找多个键。

翻译过滤器< /a> 似乎只适用于 2 列。 csv 过滤器< /a> 似乎无法循环 indicator.codes 数组。

I'm indexing logs in ELasticsearch through Logstash which contain a field with an array of codes, for example:

indicator.codes : [ "3", "120", "148" ]

Is there some way in Logstash to lookup these codes in a csv and save the categories and descriptions in 2 new fields such as indicator.categories and indicator.descriptions.

A subset of the csv with 3 columns:

Column 1 => indicator.code
Column 2 => indicator.category
Column 3 => indicator.description
3;Hiding;There are signs in the header
4;Hiding;This binary might try to schedule a task
34;General;This is a 7zip selfextracting file
120;General;This is a selfextracting RAR file
121;General;This binary tries to run as a service
148;Stealthiness;This binary uses tunnel traffic

I've been looking at the csv filter and the translate filter, but they do not seem to be able to lookup multiple keys.

The translate filter seems to work only with 2 columns. The csv filter seems unable to loop through the indicator.codes array.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

记忆消瘦 2025-01-27 04:59:13

我建议使用 Ruby 过滤器来循环 Indicator.codes 并将它们与从 csv 检索到的数据进行比较。

https://www.elastic.co/guide/ en/logstash/8.1/plugins-filters-ruby.html

I would suggest using a Ruby filter to loop over the indicator.codes and compare them to your data you retrieved from the csv.

https://www.elastic.co/guide/en/logstash/8.1/plugins-filters-ruby.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文