

Use the > attribute | makeresults | eval TEST1="100",TEST2="200",TEST3="300" | fields - _time | foreach TEST* In this command we use one attribute >, this attribute refers all the fields that taken by the " * " into the loop ( FIELD is template to access all the fields ). In foreach command we use “ * ” to get all the fields into the loop.

Using foreach command we can take multiple fields in a loop and easily we can perform any calculation.įind below the skeleton of the usage of the command “foreach” in SPLUNKĭescription : A list of field names.

Now if we want to calculate multiple fields at same time we can’t do using eval command, we can do using foreach command. Using eval command we can perform calculation for a single field. Earlier we already discuss about eval command. You can easily rename the fields "option.name" and "de" to whatever you would like using rename.Basically foreach command runs a streaming sub-search for each field. Here is my search that produces a table with a row for each text pair: my_search_terms | spath de | spath options.name | table options.name deĪnd here are my results: options.name de The only difference in output is one table has four separate rows for each and the other table has one row with four lines in it the row. Hi, you be more specific about what your XML looks like when it is returned in Splunk events? Is it broken up into separate events, so that the events fall cleanly between "" and "" keys? If not, is your search returning one big XML event? Or is it something else all together?Įither way, when I drop your XML into my Splunk instance, I am able to extract both the "name" and "code" text from each XML tag using spath. Index=beast_app sourcetype="beast_us_cap_app_beast_parallel" " I have tried both spath and xpath, at the most i am getting a single line value that is ExpandedINTLROAM when i use xmlkv, but i am looking for all the values under options/name in a list. Below is my xml from which i need the Name and code under every option
#Spath splunk examples code