<?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 Splunk python SDK and REST string search query issues. in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-python-SDK-and-REST-string-search-query-issues/m-p/523319#M9374</link>
    <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;In advance, thanks for reading and responding.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an existing issue when using (with python) Splunk SDK and Rest to perform a search.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this case i am attempting to query for details given a SMTP message ID (the query parameter) .&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additionally, to note that about 75% of the queries work as expected and return the data while the rest will indicate that there are no results. (and of course, i can confirm that there is data through the gui)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As an example, the search query will return results for parameter (1) (2) and (3) but not for parameter (4) (5)&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;92037848562344152638461b32.1739vb98635.290-9302924841.1701506175.7300a656@mail00.cat66.vvvv.net&amp;nbsp;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;AM7P191MB0581C4397B54F7DA07DD3DAF840D0@AM7P191MB0581.EURP191.PROD.OUTLOOK.COM&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;WHGD892HSG6328EA0C84C32E79576307E810D0@VXBSGHD82978GS.US9978WS.PRUDD.OUTLOOK.COM&lt;/LI&gt;&lt;LI&gt;&lt;A href="http://nothinghere" target="_self"&gt;PHJKUYU4758WHD74393JHEHE7387648Y3B0CC40D0@DSE334WS01MB4950.DEVDEV.predd.exchange.com&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;MU98SAHKJ8E87495023B503385D6E36513B0CC40D0@TEUYS899WK93UE3.DROID.svrti.resound.com&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I am really confused about the reason behind this issue.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Oct 2020 00:22:11 GMT</pubDate>
    <dc:creator>cresposh</dc:creator>
    <dc:date>2020-10-07T00:22:11Z</dc:date>
    <item>
      <title>Splunk python SDK and REST string search query issues.</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-python-SDK-and-REST-string-search-query-issues/m-p/523319#M9374</link>
      <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;In advance, thanks for reading and responding.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an existing issue when using (with python) Splunk SDK and Rest to perform a search.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this case i am attempting to query for details given a SMTP message ID (the query parameter) .&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additionally, to note that about 75% of the queries work as expected and return the data while the rest will indicate that there are no results. (and of course, i can confirm that there is data through the gui)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As an example, the search query will return results for parameter (1) (2) and (3) but not for parameter (4) (5)&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;92037848562344152638461b32.1739vb98635.290-9302924841.1701506175.7300a656@mail00.cat66.vvvv.net&amp;nbsp;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;AM7P191MB0581C4397B54F7DA07DD3DAF840D0@AM7P191MB0581.EURP191.PROD.OUTLOOK.COM&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;WHGD892HSG6328EA0C84C32E79576307E810D0@VXBSGHD82978GS.US9978WS.PRUDD.OUTLOOK.COM&lt;/LI&gt;&lt;LI&gt;&lt;A href="http://nothinghere" target="_self"&gt;PHJKUYU4758WHD74393JHEHE7387648Y3B0CC40D0@DSE334WS01MB4950.DEVDEV.predd.exchange.com&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;MU98SAHKJ8E87495023B503385D6E36513B0CC40D0@TEUYS899WK93UE3.DROID.svrti.resound.com&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I am really confused about the reason behind this issue.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2020 00:22:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-python-SDK-and-REST-string-search-query-issues/m-p/523319#M9374</guid>
      <dc:creator>cresposh</dc:creator>
      <dc:date>2020-10-07T00:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk python SDK and REST string search query issues.</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-python-SDK-and-REST-string-search-query-issues/m-p/523364#M9375</link>
      <description>&lt;P&gt;What is the exact query you are using and some sample raw log events (anonymised of course) would be helpful too?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2020 07:33:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-python-SDK-and-REST-string-search-query-issues/m-p/523364#M9375</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2020-10-07T07:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk python SDK and REST string search query issues.</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-python-SDK-and-REST-string-search-query-issues/m-p/523460#M9376</link>
      <description>&lt;P&gt;Hi ITWhisperer,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did not add any of the code just because it is the one i use as a template to complete other queries successfully, so i would (maybe mistakenly) think that it is not necessarily the code.&lt;/P&gt;&lt;P&gt;Still here is part of it and thanks for your input.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;my_creds_here {}

servercontent = requests.post(str(baseurl) + '/services/auth/login', headers = {}, data = data, verify = False)
sessionkey = minidom.parseString(servercontent.content).getElementsByTagName('sessionKey')[0].childNodes[
0].nodeValue


searchquery = 'index=myindex smtp-message-id="' + str(message_id) + '" earliest=-72 | fields smtp-message-id'

searchjob = requests.post(str(baseurl) + '/services/search/jobs',
headers = {'Authorization': 'Splunk %s' % sessionkey},
data = {'search': searchquery}, verify = False) # [1]
sid = minidom.parseString(searchjob.content).getElementsByTagName('sid')[0].childNodes[0].nodeValue



servicessearchstatusstr = '/services/search/jobs/%s/' % sid
isnotdone = True
while isnotdone:
searchstatus = requests.get(baseurl + servicessearchstatusstr, auth = (username, password),
verify = False).content.decode('utf-8')
isdonestatus = re.compile('isDone"&amp;gt;(0|1)')
isdonestatus = isdonestatus.search(searchstatus).groups()[0]
if (isdonestatus == '1'):
isnotdone = False
print("====&amp;gt;search status: %s &amp;lt;====" % isdonestatus)

# Get the search results
if isdonestatus == '1':
services_search_results_str = '/services/search/jobs/%s/results?output_mode=json&amp;amp;count=0' % sid
searchresults = requests.get(baseurl + services_search_results_str, auth = (username, password),
verify = False)

#print response&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the response for queries in which no results are given.&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;b'{"preview":false,"init_offset":0,"post_process_count":0,"messages":[{"type":"INFO","text":"Your timerange was substituted based on your search string"}],"results":[]}'&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Response where it responds with results&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;b'{"preview":false,"init_offset":0,"messages":[{"type":"INFO","text":"Your timerange was substituted based on your search string"}],"fields":[{"&lt;STRONG&gt;MY FIELDS HERE&lt;/STRONG&gt;"],"results":[{"&lt;STRONG&gt;MY RESULTS HERE&lt;/STRONG&gt; "}], "highlighted":{}}'&lt;/LI&gt;&lt;/UL&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;</description>
      <pubDate>Wed, 07 Oct 2020 15:52:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-python-SDK-and-REST-string-search-query-issues/m-p/523460#M9376</guid>
      <dc:creator>cresposh</dc:creator>
      <dc:date>2020-10-07T15:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk python SDK and REST string search query issues.</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-python-SDK-and-REST-string-search-query-issues/m-p/523466#M9377</link>
      <description>&lt;P&gt;Maybe this line should be closing the double quotes around message_id?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;searchquery = 'index=myindex smtp-message-id="' + str(message_id) + '" earliest=-72 | fields smtp-message-id'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2020 15:47:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-python-SDK-and-REST-string-search-query-issues/m-p/523466#M9377</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2020-10-07T15:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk python SDK and REST string search query issues.</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-python-SDK-and-REST-string-search-query-issues/m-p/523468#M9378</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is, i had removed it by accident when posting the code.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2020 15:52:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-python-SDK-and-REST-string-search-query-issues/m-p/523468#M9378</guid>
      <dc:creator>cresposh</dc:creator>
      <dc:date>2020-10-07T15:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk python SDK and REST string search query issues.</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-python-SDK-and-REST-string-search-query-issues/m-p/523555#M9379</link>
      <description>&lt;P&gt;RESOLVED:&amp;nbsp;&lt;/P&gt;&lt;P&gt;While looking for API call logs to see if i could find any clue, i found that the search head the call is goes through is missing configuration for the parsing of fields from a few sources and including the messageID field that I am querying for.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have not had this issue before but were under the (wrong) impression that the parsing of fields and data was synchronized automatically.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Oct 2020 23:43:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-python-SDK-and-REST-string-search-query-issues/m-p/523555#M9379</guid>
      <dc:creator>cresposh</dc:creator>
      <dc:date>2020-10-07T23:43:54Z</dc:date>
    </item>
  </channel>
</rss>

