Splunk Search

search filed values from sourcetype1 to another sourcetype2

shrinivaskittur
Explorer

Hi,
I need help in searching field value from the first search to another search with deferent sourcetype and combine both search fields in one table.
but the issue is filed name is the same in both sourcetype but the values are different.
example:


Sourcetype 1 has filed name "user" with value "ABCD"


sourcetype 2 has filed name "user" with value "xxx\\ABCD"


I tried with below query but not getting the output


sourcetype=sourcetype1 | eval User="*".User
| table User | join User [search sourcetype=sourcetype2 | fields User HostName HostIP FileName Timestamp Message] | table User Email HostName HostIP FileName  Message

Labels (1)
0 Karma

jwalthour
Communicator

Try this:

 

(index=index1 sourcetype=sourcetype1) OR (index=index2 sourcetype=sourcetype2)
| eval user=replace(user,"xxx\\\\\\\\","")
| rename user as User
| stats values(Email) as Email values(HostName) as HostName values(HostIP) as HostIP values(FileName) as FileName values(Message) as Message by User

 

 

If you like it, please mark it as the Solution; if not, let me know what needs changed.

0 Karma

shrinivaskittur
Explorer

Hello Jwalthour,

 

Thank you for your reply, but the "xxx" is not static value here,  need some command to remove  all text before "\\"  and including "\\"

0 Karma

jwalthour
Communicator

Replace line 2 with:

 

 

| rex field=user "^\S{3}\\\\\\\\(?P<user>[\s\S]+)"

 

or this gets you there, too:

| rex field=user "\\\\\\\\(?P<user>[\s\S]+)"

shrinivaskittur
Explorer

Hi,

Sorry for coming again, I have verified the output table and the table contain only the field of sourcetype1 and the sourcetype2  field values are showing blank

0 Karma
Get Updates on the Splunk Community!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...