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!

New in Observability - Improvements to Custom Metrics SLOs, Log Observer Connect & ...

The latest enhancements to the Splunk observability portfolio deliver improved SLO management accuracy, better ...

Improve Data Pipelines Using Splunk Data Management

  Register Now   This Tech Talk will explore the pipeline management offerings Edge Processor and Ingest ...

3-2-1 Go! How Fast Can You Debug Microservices with Observability Cloud?

Register Join this Tech Talk to learn how unique features like Service Centric Views, Tag Spotlight, and ...