Splunk Search

If len() then A else B

sai33
Explorer

Hi All,

I'm looking to include a If Else Check along with Len() Function along with Eval in my Search.

My Raw syntax would be something like this:
If Len(A)>o then 'A' else 'B'

Can you please help out on creating something like the above statement using Eval.

Thanks!

0 Karma
1 Solution

MuS
Legend

Hi sai33,

give this a try:

| makeresults | eval A="", B="22" `comment("creates fake events")` 
| eval result_len_0=if(len(A) > 0, A, B)

Hope this helps ...

cheers, MuS

View solution in original post

MuS
Legend

Hi sai33,

give this a try:

| makeresults | eval A="", B="22" `comment("creates fake events")` 
| eval result_len_0=if(len(A) > 0, A, B)

Hope this helps ...

cheers, MuS

sai33
Explorer

Thanks @MuS

0 Karma
Get Updates on the Splunk Community!

Technical Workshop Series: Splunk Data Management and SPL2 | Register here!

Hey, Splunk Community! Ready to take your data management skills to the next level? Join us for a 3-part ...

Spotting Financial Fraud in the Haystack: A Guide to Behavioral Analytics with Splunk

In today's digital financial ecosystem, security teams face an unprecedented challenge. The sheer volume of ...

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability As businesses scale ...