<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: dbconnect results as a subquery in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/549261#M155841</link>
    <description>&lt;P&gt;Any idea then?&lt;/P&gt;</description>
    <pubDate>Sun, 25 Apr 2021 08:02:19 GMT</pubDate>
    <dc:creator>tzvikaz</dc:creator>
    <dc:date>2021-04-25T08:02:19Z</dc:date>
    <item>
      <title>dbconnect results as a subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/548889#M155719</link>
      <description>&lt;P&gt;trying to do something like:&lt;/P&gt;&lt;P&gt;index=someindex action=someaction | where city_id in&amp;nbsp;([search dbxquery query="select city_id from Cities&amp;nbsp; where Country="USA" connection="SQLserver" ])&lt;/P&gt;&lt;P&gt;The dbxquerry will return 1 or more results&lt;/P&gt;&lt;P&gt;obviously, this is a malformed syntax.&lt;/P&gt;&lt;P&gt;Any idea how I pull this off?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 07:41:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/548889#M155719</guid>
      <dc:creator>tzvikaz</dc:creator>
      <dc:date>2021-04-22T07:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: dbconnect results as a subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/548903#M155722</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/26548"&gt;@tzvikaz&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you explain better the scope of the search?&lt;/P&gt;&lt;P&gt;if&amp;nbsp; you need a join&amp;nbsp; try:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=someindex action=someaction | join city_id [search dbxquery query="select city_id from Cities  where Country="USA" connection="SQLserver" ]&lt;/LI-CODE&gt;&lt;P&gt;but be careful because the subsearch works better with a small subset of data.&lt;/P&gt;&lt;P&gt;However if you want search the results of dbxquery on splunk index you can use:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=someindex action=someaction [search dbxquery query="select city_id from Cities  where Country="USA" connection="SQLserver" ]&lt;/LI-CODE&gt;&lt;P&gt;but to understand better the scope I need more details&lt;/P&gt;&lt;P&gt;Alessandro&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 08:54:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/548903#M155722</guid>
      <dc:creator>aasabatini</dc:creator>
      <dc:date>2021-04-22T08:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: dbconnect results as a subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/548904#M155723</link>
      <description>&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im not looking to join. I do&amp;nbsp;want to search the results of dbxquery on splunk index.&lt;/P&gt;&lt;P&gt;But I am not sure your example is good enough.&lt;/P&gt;&lt;P&gt;the "translated" Splunk SPL should look something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;index=someindex action=someaction | WHERE city_id IN(10, 3, 223,2324 12323)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;10,3,223, ... are the results returned from the DBquery.&lt;/P&gt;&lt;P&gt;So I want to search a specific field (for several options, hence the WHERE clause) in the events and not in all fields.&lt;/P&gt;&lt;P&gt;I hope I am making sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 09:05:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/548904#M155723</guid>
      <dc:creator>tzvikaz</dc:creator>
      <dc:date>2021-04-22T09:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: dbconnect results as a subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/548908#M155725</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/26548"&gt;@tzvikaz&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=someindex action=someaction [search dbxquery query="select city_id from Cities  where Country="USA" connection="SQLserver" | fields city_id ]&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 22 Apr 2021 09:23:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/548908#M155725</guid>
      <dc:creator>aasabatini</dc:creator>
      <dc:date>2021-04-22T09:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: dbconnect results as a subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/548914#M155726</link>
      <description>&lt;P&gt;I get no results.&amp;nbsp;&lt;/P&gt;&lt;P&gt;how does this compare the event fields to the db field? in no point to I write in this SPL the field name in the splunk event.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 09:48:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/548914#M155726</guid>
      <dc:creator>tzvikaz</dc:creator>
      <dc:date>2021-04-22T09:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: dbconnect results as a subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/548920#M155730</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/26548"&gt;@tzvikaz&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;are you sure you have the city_id info on the :&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=someindex&lt;/LI-CODE&gt;&lt;P&gt;Also if you run&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;dbxquery query="select city_id from Cities  where Country="USA" connection="SQLserver" | fields city_id | format&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;what is the results?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 10:24:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/548920#M155730</guid>
      <dc:creator>aasabatini</dc:creator>
      <dc:date>2021-04-22T10:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: dbconnect results as a subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/548937#M155735</link>
      <description>&lt;P&gt;Your comment made me realize I should do a field rename to match the fields so I added a rename directive.&lt;/P&gt;&lt;P&gt;Still didn't help&lt;/P&gt;&lt;P&gt;running only the query with format gives something like&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;( ( city_id="259186" ) OR ( city_id="259732" ) OR ( city_id="259733" ) OR ( city_id="259734" ) OR ( city_id="259735" ) OR ( city_id="259768" ) OR ( city_id="259846" ) OR ( city_id="259851" ) OR ( city_id="259864" ) OR ( city_id="260088" ) OR ( city_id="260827" ) OR ( city_id="260831" ) OR ( city_id="261115" ) OR ( city_id="261116" ) OR ( city_id="261916" ) OR ( city_id="262012" ) OR ( city_id="262390" ) OR ( city_id="262394" ) OR ( city_id="262501" ) OR ( city_id="262620" ) OR ( city_id="262655" ) OR ( city_id="262661" ) OR ( city_id="262877" ) OR ( city_id="262878" ) OR ( city_id="262906" ) OR ( city_id="262907" ) OR ( city_id="263650" ) OR ( city_id="263945" ) OR ( city_id="263971" ) OR ( city_id="265786" ) OR ( city_id="265805" ) OR ( city_id="266123" ) OR ( city_id="266231" ) OR ( city_id="266246" ) OR ( city_id="269376" ) OR ( city_id="270357" ) OR ( city_id="272283" ) OR ( city_id="272384" ) OR ( city_id="275371" ) OR ( city_id="277011" ) OR ( city_id="277208" ) OR ( city_id="277500" ) OR ( city_id="277652" ) OR ( city_id="277673" ) OR ( city_id="278081" ) OR ( city_id="278116" ) OR ( city_id="279034" ) OR ( city_id="279144" ) OR ( city_id="279487" ) OR ( city_id="279515" ) OR ( city_id="279677" ) OR ( city_id="279977" ) OR ( city_id="279991" ) OR ( city_id="280287" ) OR ( city_id="280291" ) OR ( city_id="280602" ) OR ( city_id="280690" ) OR ( city_id="280695" ) OR ( city_id="280921" ) OR ( city_id="281026" ) OR ( city_id="281414" ) OR ( city_id="281481" ) OR ( city_id="282798" ) OR ( city_id="282917" ) OR ( city_id="283024" ) OR ( city_id="283088" ) OR ( city_id="283094" ) OR ( city_id="283132" ) OR ( city_id="283133" ) OR ( city_id="283148" ) OR ( city_id="283149" ) OR ( city_id="283175" ) OR ( city_id="283266" ) OR ( city_id="283734" ) OR ( city_id="283802" ) OR ( city_id="284024" ) OR ( city_id="284122" ) OR ( city_id="284453" ) OR ( city_id="284473" ) OR ( city_id="285711" ) OR ( city_id="285777" ) OR ( city_id="286354" ) OR ( city_id="286479" ) OR ( city_id="286507" ) OR ( city_id="286649" ) OR ( city_id="286652" ) OR ( city_id="286653" ) OR ( city_id="286654" ) OR ( city_id="286655" ) OR ( city_id="286656" ) OR ( city_id="286657" ) OR ( city_id="286829" ) OR ( city_id="286857" ) OR ( city_id="287004" ) OR ( city_id="287073" ) OR ( city_id="287272" ) OR ( city_id="287430" ) OR ( city_id="287809" ) OR ( city_id="288027" ) OR ( city_id="288298" ) OR ( city_id="288716" ) OR ( city_id="289860" ) OR ( city_id="289984" ) OR ( city_id="290007" ) OR ( city_id="290055" ) OR ( city_id="290435" ) OR ( city_id="290625" ) OR ( city_id="290686" ) OR ( city_id="290787" ) OR ( city_id="290789" ) OR ( city_id="290904" ) OR ( city_id="290989" ) OR ( city_id="291061" ) OR ( city_id="291108" ) OR ( city_id="291216" ) OR ( city_id="291222" ) OR ( city_id="291405" ) OR ( city_id="291434" ) OR ( city_id="291449" ) OR ( city_id="291463" ) OR ( city_id="291997" ) OR ( city_id="292187" ) OR ( city_id="292625" ) OR ( city_id="292884" ) OR ( city_id="293188" ) )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 11:30:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/548937#M155735</guid>
      <dc:creator>tzvikaz</dc:creator>
      <dc:date>2021-04-22T11:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: dbconnect results as a subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/548939#M155736</link>
      <description>&lt;P&gt;ok, in this case you need to rename the field have the same values of city_id&lt;/P&gt;&lt;P&gt;example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=someindex action=someaction | rename &amp;lt;field with the same cit_id values&amp;gt; as city_id | [search dbxquery query="select city_id from Cities  where Country="USA" connection="SQLserver"| fields city_id ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 12:22:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/548939#M155736</guid>
      <dc:creator>aasabatini</dc:creator>
      <dc:date>2021-04-22T12:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: dbconnect results as a subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/548942#M155737</link>
      <description>&lt;P&gt;I did. inside the subsearch and not like you wrote (which gives a syntax error)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=someindex action=someaction [search dbxquery query="select city_id from Cities  where Country="USA" connection="SQLserver" | rename city_id as event_city_id_field| fields event_city_id_field]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I just append the result of the formatted subsearch to the main search it works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so something like this works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=someindex action=someaction AND ( ( event_city_id_field="259186" ) OR ( event_city_id_field="259732" ) OR ( event_city_id_field="259733" ) OR ( event_city_id_field="262012" ) OR ( event_city_id_field="262390" ) OR ( event_city_id_field="262394" ) OR ( event_city_id_field="262501" ) OR ( event_city_id_field="262620" ) OR ( event_city_id_field="262655" ) OR ( event_city_id_field="262661" ) OR ( event_city_id_field="262877" ) OR ( event_city_id_field="262878" ) OR ( event_city_id_field="262906" ) OR ( event_city_id_field="262907" ) OR ( event_city_id_field="263650" ) OR ( event_city_id_field="263945" ) OR ( event_city_id_field="263971" ) OR ( event_city_id_field="265786" ) OR ( event_city_id_field="265805" ) OR ( event_city_id_field="266123" ) OR ( event_city_id_field="266231" ) OR ( event_city_id_field="266246" ) OR ( event_city_id_field="269376" ) OR ( event_city_id_field="270357" ) OR ( event_city_id_field="272283" ) OR ( event_city_id_field="283175" ) OR ( event_city_id_field="283266" ) OR ( event_city_id_field="283734" ) OR ( event_city_id_field="283802" ) OR ( event_city_id_field="284024" ) OR ( event_city_id_field="284122" ) OR ( event_city_id_field="284453" ) OR ( event_city_id_field="284473" ) OR ( event_city_id_field="287272" ) OR ( event_city_id_field="287430" ) OR ( event_city_id_field="287809" ) OR ( event_city_id_field="288027" ) OR ( event_city_id_field="292884" ) OR ( event_city_id_field="293188" ) )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So no idea why it doesn't in the way I mentioned.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 12:28:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/548942#M155737</guid>
      <dc:creator>tzvikaz</dc:creator>
      <dc:date>2021-04-22T12:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: dbconnect results as a subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/549261#M155841</link>
      <description>&lt;P&gt;Any idea then?&lt;/P&gt;</description>
      <pubDate>Sun, 25 Apr 2021 08:02:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/549261#M155841</guid>
      <dc:creator>tzvikaz</dc:creator>
      <dc:date>2021-04-25T08:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: dbconnect results as a subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/549304#M155849</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/26548"&gt;@tzvikaz&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;sorry for the late reply, I think the best way is use the rename outside the subsearch, try like this.&lt;/P&gt;&lt;P&gt;(sorry if the previous search doesn't works but is not really easy understand the request without see the subset of data)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=someindex action=someaction | rename event_city_id_field as city_id | search [search dbxquery query="select city_id from Cities  where Country="USA" connection="SQLserver" | fields city_id]&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 26 Apr 2021 07:45:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/549304#M155849</guid>
      <dc:creator>aasabatini</dc:creator>
      <dc:date>2021-04-26T07:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: dbconnect results as a subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/549328#M155864</link>
      <description>&lt;P&gt;OK, got it to work like so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=someindex action=someaction |join event_city_id_field [|dbxquery query="select city_id from Cities  where Country="USA" connection="SQLserver" | rename city_id as event_city_id_field| fields event_city_id_field]
&lt;/LI-CODE&gt;&lt;P&gt;I needed to add the join directive + replace "search" with "|"&lt;/P&gt;&lt;P&gt;Really appreciate your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 13:13:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dbconnect-results-as-a-subquery/m-p/549328#M155864</guid>
      <dc:creator>splunk0</dc:creator>
      <dc:date>2021-04-26T13:13:41Z</dc:date>
    </item>
  </channel>
</rss>

