当 Splunk eval 命令出现错误时该怎么办

问题描述 投票:0回答:1

对于此 Splunk 查询:

index=* | eval case(status="200", "is successful", status="300", is redirect, status="400", "is error", 1=1", is did not match")

我预计我会得到一个结果,其中 200 为成功,300 为重定向,400 为错误,但我的 eval 命令为错误

splunk splunk-query splunk-dashboard splunk-formula splunk-calculation
1个回答
0
投票

您使用

case
声明时似乎存在一些问题。

  1. 您需要将 case 语句的结果分配给 可以使用的字段。

  2. 您的价值观的引用不正确。

    is redirect
    没有任何引号,并且
    is did not match"
    有尾随引号,但没有前导引号。

  3. 测试

    ==
    时应使用
    =
    而不是
    status
    价值观。

  4. 您需要根据您的结果做一些事情

    case

尝试这样的事情:

index=* 
| eval label = case(status=="200", "is successful", status=="300", "is redirect", status=="400", "is error", 1=1", "is did not match")
| stats count by label
© www.soinside.com 2019 - 2024. All rights reserved.