Splunk Search

Stitching all Search (stats) Fields into new_raw Field (need foreach assistance)

ssteinmann
Explorer

Hi all,

i tried get rid of my workaround solution with adding

| collect index=test testmode=true

to my searches. The above command is creating a _raw Field with all Fields from my (stats) search, so i didnt need to specify all my fields to a new aggregated one. I need all Fields=Value Pairs in one Field because i set up a alert action for each saved_search and with an standard field $result._raw$ it's easier to apply this to many Searches(250+).

Aggregating with collect:

| makeresults count=2
| eval src="1.1.1.1", dest="10.10.10.10", dest_port="123", eventCount=random()
| eval eventDetails="Source=" . src . " " . "Destination=" . dest . " " . "Port=" . dest_port . " " . "eventCount=" . eventCount
| collect index=test testmode=true

Aggregating with foreach:

| makeresults count=2
| eval src="1.1.1.1", dest="10.10.10.10", dest_port="123", eventCount=random()
| eval eventDetails="Source=" . src . " " . "Destination=" . dest . " " . "Port=" . dest_port . " " . "eventCount=" . eventCount
| eval x_raw=""
| foreach * [ eval x_raw="<<FIELD>>"+"="+'<<FIELD>>' + ", " + x_raw]

my x_raw field contains the fields twice, i was not able to get a result like a _raw Field from my "| collect" workaround.

x_raw=src=1.1.1.1, eventDetails=Source=1.1.1.1 Destination=10.10.10.10 Port=123 eventCount=607756396, eventCount=607756396, dest_port=123, dest=10.10.10.10, , src=1.1.1.1, eventDetails=Source=1.1.1.1 Destination=10.10.10.10 Port=123 eventCount=607756396, eventCount=607756396, dest_port=123, dest=10.10.10.10, 

Any Ideas how to solve this?

Tags (1)
0 Karma
Get Updates on the Splunk Community!

Modern way of developing distributed application using OTel

Recently, I had the opportunity to work on a complex microservice using Spring boot and Quarkus to develop a ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had 3 releases of new security content via the Enterprise Security ...

Archived Metrics Now Available for APAC and EMEA realms

We’re excited to announce the launch of Archived Metrics in Splunk Infrastructure Monitoring for our customers ...