Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
492 views
in Technique[技术] by (71.8m points)

How do I access an array value inside a case in Splunk?

I'm new to Splunk and need some help with the following:

  • authIndexValue[] is an array that will hold at least one value
  • I want to access its value from inside a case in an eval statement but I get this error: Unknown search command '0'.
  • I also tried http.request.queryParameters.authIndexValue{} with no luck

Below the eval line:

..search
| eval EventType=case(http.request.queryParameters.authIndexValue[0]==Login_FooBar, "LOGIN") 

How can I achieve this?

Thanks.

question from:https://stackoverflow.com/questions/65892385/how-do-i-access-an-array-value-inside-a-case-in-splunk

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Splunk doesn't have "arrays"

It has multivalue fields

To access/do anything with them, you need to use multivalue commands/functions

In your example, you'd want to do something like the following:

<search>
| eval EventType=case(mvindex(http.request.queryParameters.authIndexValue,0)==Login_FooBar,"LOGIN", mvindex(http.request.queryParameters.authIndexValue,0)==Login_BarFoo,"not a good login",1=1,"error state")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...