如何评估代表另一个字段长度的Splunk字段?

发布于 2025-01-19 17:09:57 字数 1129 浏览 0 评论 0原文

我已将以下包含 JSON 行的示例文件加载到 Splunk 中:

{"duration":2134,"input":["foo","bar"],"level":"info","msg":"Processed input","time":"2022-04-07T08:10:23.14427-07:00"}
{"duration":997,"input":["baz"],"level":"info","msg":"Processed input","time":"2022-04-07T08:10:23.144526-07:00"}

Splunk 已解析这些字段,使得 input 字段是一个列表: 输入图片此处描述我想生成一个包含输入长度(元素数量)和 duration 字段的表格。遵循 https://docs.splunk.com/Documentation /StreamProcessor/standard/FunctionReference/List#length.28input.29,我已经尝试过

msg="Processed input" 
| eval N=length(input) 
| table N, duration

,但这不会产生 N 的值:

输入图片此处描述

确定 N 的正确方法是什么?

I've loaded the following example file containing lines of JSON into Splunk:

{"duration":2134,"input":["foo","bar"],"level":"info","msg":"Processed input","time":"2022-04-07T08:10:23.14427-07:00"}
{"duration":997,"input":["baz"],"level":"info","msg":"Processed input","time":"2022-04-07T08:10:23.144526-07:00"}

Splunk has parsed these fields such that the input field is a list:
enter image description here
I would like to generate a table of the length of (number of elements in) the input and the duration field. Following https://docs.splunk.com/Documentation/StreamProcessor/standard/FunctionReference/List#length.28input.29, I've tried

msg="Processed input" 
| eval N=length(input) 
| table N, duration

but this yields no values for N:

enter image description here

What would be the correct way to determine N?

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

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

发布评论

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

评论(1

撞了怀 2025-01-26 17:09:57

使用mvCount('input {}')length(input)

edit> edit:在input> input {} as 周围放置单个引号{}是特殊字符。

Use mvcount('input{}') in replace of length(input)

Edit: Put Single quotes around input{} as {,} are special characters.

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