Splunk Search

When searching two indexes, how do i refer to a field from a specific index?

khubyarb
Path Finder

My search is on two indexes. I want to be able to refer specifically to a field value from one of the indexes and not the other. Both indexes have the field that share the same field name. For example:

search index=indexA OR index=indexB | eval unique1= indexA.ID | eval unique = indexB.ID | ....

I cannot use subsearch because my result set of the subsearch would be over the limit of results subsearch returns so I need to be searching both indexes at the same time. Would appreciate any help.

0 Karma
1 Solution

javiergn
Super Champion

You can do it this way:

search index=indexA OR index=indexB 
| eval unique-{index}= ID

Which in your case it will create two fields: unique-indexA and unique-indexB

View solution in original post

javiergn
Super Champion

You can do it this way:

search index=indexA OR index=indexB 
| eval unique-{index}= ID

Which in your case it will create two fields: unique-indexA and unique-indexB

khubyarb
Path Finder

Follow up question: in the statement
|eval unique-{index} = ID
The value of unique-indexA should contain the IDs from only indexA right?

0 Karma

javiergn
Super Champion

Yes, that's correct.

You can do similar things with any other field.
Another common one is to use it when fetching data from multiple sourcetypes:

sourcetype=A OR sourcetype=B
| eval mycommonfield-{sourcetype} = mycommonfield
0 Karma

khubyarb
Path Finder

Thanks a lot @javiergn! This should work great for my use case!

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 ...

[Puzzles] Solve, Learn, Repeat: Dereferencing XML to Fixed-length events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Stay Connected: Your Guide to December Tech Talks, Office Hours, and Webinars!

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...