Splunk Search

help with appendcols needed

damucka
Builder

Hello,

I have quite long SPL search in my alert and one part of it looks as follows:

| eval rcatrigger = ""
| appendcols
[

| noop search_optimization=false
| dbxquery query="myQueryText"   
     connection="HANA_MLBSO"
     |eval rcatrigger=$rcatrigger$| fields - rcatrigger
]

Now, the result is a table, which columns should be appended to another table from the processing happening earlier. My questions would be:
- how do I make it conditional in a way, that the dbxquery should be executed / columns appended only when the rcatrigger variable is not empty, say="1" ? Please see my try above, not workig ...
- the result columns are appended in the lexicographical order to the previous columns, I mean at the end they are mixed by the alphabet order. Is there any way to get the appended cols just on the right side? Unfortunately I cannot sort it later on with table command because the above dbxquery is not always the same - there will be several depending on the rcatrigger, so I do not know what columns will there be returned.

Kind Regards,
Kamil

0 Karma

jawaharas
Motivator

I don't think you can pass variables from parent query to subquery (appendcols) as subquery executes first.

You can try 'map' command for your use case.

Reference:
https://docs.splunk.com/Documentation/Splunk/7.3.0/SearchReference/Map

0 Karma

damucka
Builder

Thank you.

I am not fixed on passing parameter from parent to subquery, what I want to achieve is conditional execution of the appendcols when the rcatrigger=1.
How would I do this?

Kind Regards,
Kamil

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...