Splunk Search

How to edit my search to get all fields associated with an internal_message_id field?

packet_hunter
Contributor

Trying to correlate email security appliance logs to email malware analysis logs.

I am using the following code that returns a field internal_message_id with different values via the--> | stats list(*).

index=AAA sourcetype="Xmail" eventtype=X_email [search index=BBB sourcetype=Y_cef_syslog eventtype=Y suser=*  | fields suser| rex field=suser "(?<attacker>[\w\d\.\-\@]+)" | eval sender= lower(attacker) |table sender] | search internal_message_id=*  |stats list(*)

Within index=AAA, there are a number of events that share the unique value for the internal_message_id field.

Need a little help pulling all the other field values from events (in index=AAA) that share the same unique internal_message_id value.

For example, with each unique internal_message_id, I can stitch together separate events that contain fields such as "sender" , "recipient", "message_subject", "file_name", etc.

Currently the code is returning the correct fields but more than just the specific events related to the subsearch sender results.

Any help greatly appreciated.

0 Karma
1 Solution

somesoni2
Revered Legend

How about this

index=AAA sourcetype="Xmail" eventtype=X_email [search index=BBB sourcetype=Y_cef_syslog eventtype=Y suser=*  | fields suser| rex field=suser "(?<attacker>[\w\d\.\-\@]+)" | eval sender= lower(attacker) |table sender] | search internal_message_id=*  |stats list(*) by internal_message_id

Update

Try this

index=AAA [ search index=AAA sourcetype="Xmail" eventtype=X_email [search index=BBB sourcetype=Y_cef_syslog eventtype=Y suser=*  | fields suser| rex field=suser "(?<attacker>[\w\d\.\-\@]+)" | eval sender= lower(attacker) |table sender] | stats count by internal_message_id  | table internal_message_id] | table *

View solution in original post

somesoni2
Revered Legend

How about this

index=AAA sourcetype="Xmail" eventtype=X_email [search index=BBB sourcetype=Y_cef_syslog eventtype=Y suser=*  | fields suser| rex field=suser "(?<attacker>[\w\d\.\-\@]+)" | eval sender= lower(attacker) |table sender] | search internal_message_id=*  |stats list(*) by internal_message_id

Update

Try this

index=AAA [ search index=AAA sourcetype="Xmail" eventtype=X_email [search index=BBB sourcetype=Y_cef_syslog eventtype=Y suser=*  | fields suser| rex field=suser "(?<attacker>[\w\d\.\-\@]+)" | eval sender= lower(attacker) |table sender] | stats count by internal_message_id  | table internal_message_id] | table *

packet_hunter
Contributor

I must have accidentally cleaned out your additional post:

Can you just run this and see if it returns just the list of internal_message_id field which corresponds to attacker/sender from index=BBB?

index=AAA sourcetype="Xmail" eventtype=X_email [search index=BBB sourcetype=Y_cef_syslog eventtype=Y suser=*  | fields suser| rex field=suser "(?[\w\d\.\-\@]+)" | eval sender= lower(attacker) |table sender] | stats count by internal_message_id  | table internal_message_id

If above works fine without any problems, copy the above query into following format

 index=AAA [ search   <>   ]  | table *

Yes sir!!! that also works!!! Thank you!

0 Karma

packet_hunter
Contributor

Thank you Somesoni2!
I had to clean up the post so not to confuse anyone with my inability to post your query correctly.... d'oh!*&!
This is definitely what I was after, and I thank you for showing how to nest these subsearches correctly.

0 Karma
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...