I am using Splunk Enterprise Version 8.0.5.1 Consider an index with half a million events being generated every day. There are three fields in the index I am particularly interested in. sourcetype has 20 different values, but I am interested in one sourcetype that accounts for 10,000 events per day objectid is populated on each event and there are multiple events for the same objectid. versionid can be two different values : 1 or 2 - objects move from 1 to 2, but never back to 1. For the query period, there should be no objectids with a versionid of 1. For those objectids that have an event with versionid 1, I want to know when they changed to a 2. The problem I have is that there are so many 2s in the index, querying all of them just to then join to the 1s is taking forever and generates a job of over 1GB. So, what I'd really like to do is to query the 1s first, and then feed that list into a subsequent search where it only finds the rows with the objectid in the results of the first search for the 1s. If I do this, it just takes forever... index=myindex sourcetype=mysourcetype versionid=1
| reverse | table _time objectid | dedup objectid
| join objectid [ index=myindex sourcetype=mysourcetype versionid=2 | reverse | eval fixed=_time | table fixed objectid | dedup objectid ]
| table _time objectid fixed What I want to do is to reference the results of the first query in an IN statement inside the second, but I can't find a way to do that. If I could create a dashboard with a base query, and a panel uses the results of that base query in an IN statement, that might work, but at the moment I am stuck. I know that Splunk is not SQL, but to make it a bit clearer what I am trying to achieve... SELECT * FROM MYINDEX WHERE OBJECTID IN (SELECT OBJECTID FROM MYINDEX WHERE VERSIONID=1) AND VERSIONID=2 i.e. it evaluates the versionid=1 objectids first, and then the outer query only returns rows that match those ids. When I do this manually with a small number of IDs and put them in an explicit IN clause, it runs very quickly. Any suggestions would be much appreciated.
... View more