Refine your search:

Is it possible with subsearch to pass a list of search results to the outside search? similar to a SQL correlated subquery?

Background: I have an event that lists an ID and a ReferenceID. The ReferenceID will be a previous ID. Often however, there has been several days, if not weeks between the original ID and the ReferenceID. This makes a Transaction search ineffective for this query.

What I'd like to do, is to obtain a list of ReferenceIDs that match some criteria (quick) and then pass each of those into an outer search, so the outer search runs for each of the results returned from the inner search (not the combined results of the inner search). Is this possible?

asked 29 Jan '10, 19:58

Yancy's gravatar image

Yancy
396114
accept rate: 37%

edited 29 Jan '10, 22:53

V_at_Splunk's gravatar image

V_at_Splunk
8121414


3 Answers:

Hi Yancy,

This is possible. Something to note about subsearches is the format of what is passed from the inner search to the outer search is important. If you are looking to pass a list of ReferenceIDs, then use the fields command at the end of your inner search. Otherwise, Splunk will by default pass the events themselves to the outer search.

In pseudo search, your use case will look something like this:

... <my outer search> [search ReferenceID=abc | fields + ReferenceID]

If you post some sample data, we can help you construct the specific query.

link

answered 29 Jan '10, 21:15

hulahoop's gravatar image

hulahoop ♦
2.5k3240
accept rate: 40%

edited 01 Feb '10, 16:52

It is possible to run an outer search the way you want with the map command, one time over each inner search result. However, this is extremely inefficient in Splunk, and it is likely that there is a much better way to do it using a subsearch as described by hulahoop. The difference is that you'll have to execute n+1 searches (where N is the number of inner search results) instead of 2 searches. To a first approximation, this will take (n+1)/2 times as long.

link

answered 01 Feb '10, 08:14

gkanapathy's gravatar image

gkanapathy ♦
26.3k1622
accept rate: 42%

Splunk For SQL Users is also a good resource for this type of question.

link

answered 13 Apr '10, 19:43

Yancy's gravatar image

Yancy
396114
accept rate: 37%

Post your answer
toggle preview

Follow this question

Log In to enable email subscriptions

RSS:

Answers

Answers + Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×1,088

Asked: 29 Jan '10, 19:58

Seen: 1,895 times

Last updated: 13 Apr '10, 19:43

Copyright © 2005-2012 Splunk, Inc. All rights reserved.