I was looking for an answer to the same sort of question, if one exists, and as I read this exchange I wanted to comment. Partly as a "better but still very unsatisfactory answer" for folks, and maybe also for a bit of "let's see if anyone else comes up with a solution". I think the ask is really for - Is there a way to have a code path that either is or is not *executed* depending on some condition; a variable being set or not, or being of a particular value or whatever? In every example thus far, the code path executes regardless of the status of the variable. You can test this yourself with a search/expression there that fails and fails *hard*. Here's an example. On Splunk <any edition but free> this returns either your srchJobsQuota value, or the word "skipped" depending on if you flip the true to false. To be clear, this works fine: | makeresults
| eval results = if(false(), [| rest /services/authorization/roles/admin splunk_server=local | return $srchJobsQuota], "") But if I change my test box from my dev license to the Splunk Free license, since Splunk Free doesn't support that rest call *at all* (LOL - "Payment Required"), then no matter which way false/true is flipped, this fails. In both cases in Splunk Free, true and false, you get this same error: Error in 'eval' command: The expression is malformed. An unexpected character is reached at ', "skipped")'.
[subsearch]: Unexpected status for to fetch REST endpoint uri=https://127.0.0.1:8089/services/authorization/roles/admin?count=0 from server=https://127.0.0.1:8089 - Payment Required So it's executing that code without regard to whether it's in the active path or not. Because it's a subsearch, they run first. I thought maybe I could get around this using map, but all attempts so far that I've tried have failed because I can't find a way to run an arbitrary string (which can easily be created from an if like above) from map. It looks almost like you should be able to, but either it just won't work or I haven't found the magic combination. And I've tried quite a bit... I'll think on it some more, maybe there will be more suggestions from the peanut gallery too. 🙂 Happy Splunking, Rich
... View more