Splunk Search

Using the transaction command to group events being logged to two indexes, how do I only include events that are found in both indexes?

tenorway
Path Finder

Hi all!

I am using the transaction command to group events being logged to two indexes. I have a common identifier.
However, I only want to include transactions where there are events from both indexes, (Events being initiated from Web). How can I achieve that?
I tried using the join command, but the output from it just confuses me..
I tried using where (isnotnull(uri)), because I know uri will always be set if the transaction consists of events from both indexes. No result returned.

index=* | rename correlationId as CID | transaction CID | where isnotnull(uri) | fields * | table uri, serviceName,operationName,host

Thanks for any assistance!

0 Karma

tenorway
Path Finder

Hi There!

I made it work using the coalesque command. That was actually causing the whole problem.
Using the where isnotnull command strips away unwanted transactions.

I would like to use stats, but would that work when not all the fields are present in all the events?

0 Karma

wpreston
Motivator

Looking at your other question about not all fields being extracted in your transaction, it makes me wonder if uri is not extracted prior to your where command. Try rearranging the search so that | fields * comes before | where isnotnull(uri) and give that a shot.

index=* | rename correlationId as CID | transaction CID | fields * | where isnotnull(uri) | table uri, serviceName,operationName,host
0 Karma

javiergn
Super Champion

Hi,

You need to pass more parameters to your transaction command such as startsWith or endsWith, etc.
In any case, I wouldn't use transaction for what you are trying to achieve.
Try the following instead:

index=YOURINDEX_A OR index=YOURINDEX_B
| rename correlationId as CID
| fields CID, uri, serviceName, operationName, host, index
| stats range(_time) as duration, values(index) as index, values(uri) as uri, values(serviceName) as serviceName, values(operationName) as operationName, values(host) as host by CID
| where isnotnull(uri) 
| table uri, serviceName, operationName, host

Let me know if that works. If not, can you give us more details about your data and what you are trying to achieve exactly?

Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...