<?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 Custom search command with python stopped working - not returning ressult in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-with-python-stopped-working-not-returning/m-p/510308#M9124</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a custom search command following the instruction in the page and it was working fine (&lt;A href="https://www.splunk.com/en_us/blog/tips-and-tricks/write-your-own-search-language.html" target="_blank"&gt;https://www.splunk.com/en_us/blog/tips-and-tricks/write-your-own-search-language.html&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;however stopped working suddenly.&amp;nbsp; Tried to put some file creation statement, the files are not created - looks the python program is not running at all.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Python code&amp;nbsp;(C:\Program Files\Splunk\etc\apps\search\bin)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;import splunk.Intersplunk&lt;/P&gt;&lt;P&gt;def getShape(text):&lt;BR /&gt;phrase1 = "upload"&lt;BR /&gt;phrase2 = "TrustedInstaller"&lt;BR /&gt;description = []&lt;BR /&gt;if (phrase1 in text):&lt;BR /&gt;description.append("Infra")&lt;BR /&gt;elif (phrase2 in text):&lt;BR /&gt;description.append("InstallationGroup")&lt;BR /&gt;else:&lt;BR /&gt;description.append("Misc")&lt;BR /&gt;Corpus = pd.read_csv(r"E:\corpus_single.csv",encoding='latin-1')&lt;BR /&gt;Corpus.to_csv(r'E:\corpus_func.csv', index = False)&lt;BR /&gt;if len(description) == 0&lt;BR /&gt;return "normal"&lt;BR /&gt;return "_".join(description)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# get the previous search results&lt;BR /&gt;results,unused1,unused2 = splunk.Intersplunk.getOrganizedResults()&lt;BR /&gt;Corpus = pd.read_csv(r"E:\corpus_single.csv",encoding='latin-1')&lt;BR /&gt;Corpus.to_csv(r'E:\corpus_out.csv', index = False)&lt;BR /&gt;# for each results, add a 'shape' attribute, calculated from the raw event text&lt;BR /&gt;for result in results:&lt;BR /&gt;result["assignmentgrp"] = getShape(result["Message"])&lt;BR /&gt;# output results&lt;BR /&gt;splunk.Intersplunk.outputResults(results)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;---------&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Entry in command.conf&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;(folder :C:\Program Files\Splunk\etc\apps\search\default)&lt;/P&gt;&lt;P&gt;[getgroup]&lt;BR /&gt;filename = getgroup.py&lt;/P&gt;&lt;P&gt;---------------&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Search Query&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;source="winlog1.txt" | rex field=_raw "Message: &amp;lt;(?&amp;lt;Message&amp;gt;.*)&amp;gt;" | dedup Message | table Message, getgroup&lt;/P&gt;&lt;P&gt;--------&lt;/P&gt;&lt;P&gt;winlog1.txt sample data - having around 10 records&amp;nbsp;&lt;/P&gt;&lt;P&gt;2016-09-28 04:30:31, Info Message: &amp;lt;Ending TrustedInstaller initialization.&amp;gt;&lt;BR /&gt;2016-09-28 04:30:31, Info Message: &amp;lt;Starting the TrustedInstaller main loop.&amp;gt;&lt;BR /&gt;2016-09-28 04:30:31, Info Message: &amp;lt;TrustedInstaller service starts successfully.&amp;gt;&lt;BR /&gt;2016-09-28 04:30:31, Info Message: &amp;lt;Initializing online with Windows opt-in: False.&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jul 2020 22:54:51 GMT</pubDate>
    <dc:creator>smitra_cis</dc:creator>
    <dc:date>2020-07-21T22:54:51Z</dc:date>
    <item>
      <title>Custom search command with python stopped working - not returning ressult</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-with-python-stopped-working-not-returning/m-p/510308#M9124</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a custom search command following the instruction in the page and it was working fine (&lt;A href="https://www.splunk.com/en_us/blog/tips-and-tricks/write-your-own-search-language.html" target="_blank"&gt;https://www.splunk.com/en_us/blog/tips-and-tricks/write-your-own-search-language.html&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;however stopped working suddenly.&amp;nbsp; Tried to put some file creation statement, the files are not created - looks the python program is not running at all.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Python code&amp;nbsp;(C:\Program Files\Splunk\etc\apps\search\bin)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;import splunk.Intersplunk&lt;/P&gt;&lt;P&gt;def getShape(text):&lt;BR /&gt;phrase1 = "upload"&lt;BR /&gt;phrase2 = "TrustedInstaller"&lt;BR /&gt;description = []&lt;BR /&gt;if (phrase1 in text):&lt;BR /&gt;description.append("Infra")&lt;BR /&gt;elif (phrase2 in text):&lt;BR /&gt;description.append("InstallationGroup")&lt;BR /&gt;else:&lt;BR /&gt;description.append("Misc")&lt;BR /&gt;Corpus = pd.read_csv(r"E:\corpus_single.csv",encoding='latin-1')&lt;BR /&gt;Corpus.to_csv(r'E:\corpus_func.csv', index = False)&lt;BR /&gt;if len(description) == 0&lt;BR /&gt;return "normal"&lt;BR /&gt;return "_".join(description)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# get the previous search results&lt;BR /&gt;results,unused1,unused2 = splunk.Intersplunk.getOrganizedResults()&lt;BR /&gt;Corpus = pd.read_csv(r"E:\corpus_single.csv",encoding='latin-1')&lt;BR /&gt;Corpus.to_csv(r'E:\corpus_out.csv', index = False)&lt;BR /&gt;# for each results, add a 'shape' attribute, calculated from the raw event text&lt;BR /&gt;for result in results:&lt;BR /&gt;result["assignmentgrp"] = getShape(result["Message"])&lt;BR /&gt;# output results&lt;BR /&gt;splunk.Intersplunk.outputResults(results)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;---------&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Entry in command.conf&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;(folder :C:\Program Files\Splunk\etc\apps\search\default)&lt;/P&gt;&lt;P&gt;[getgroup]&lt;BR /&gt;filename = getgroup.py&lt;/P&gt;&lt;P&gt;---------------&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Search Query&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;source="winlog1.txt" | rex field=_raw "Message: &amp;lt;(?&amp;lt;Message&amp;gt;.*)&amp;gt;" | dedup Message | table Message, getgroup&lt;/P&gt;&lt;P&gt;--------&lt;/P&gt;&lt;P&gt;winlog1.txt sample data - having around 10 records&amp;nbsp;&lt;/P&gt;&lt;P&gt;2016-09-28 04:30:31, Info Message: &amp;lt;Ending TrustedInstaller initialization.&amp;gt;&lt;BR /&gt;2016-09-28 04:30:31, Info Message: &amp;lt;Starting the TrustedInstaller main loop.&amp;gt;&lt;BR /&gt;2016-09-28 04:30:31, Info Message: &amp;lt;TrustedInstaller service starts successfully.&amp;gt;&lt;BR /&gt;2016-09-28 04:30:31, Info Message: &amp;lt;Initializing online with Windows opt-in: False.&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 22:54:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-with-python-stopped-working-not-returning/m-p/510308#M9124</guid>
      <dc:creator>smitra_cis</dc:creator>
      <dc:date>2020-07-21T22:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: Custom search command with python stopped working - not returning ressult</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-with-python-stopped-working-not-returning/m-p/510515#M9125</link>
      <description>&lt;P&gt;Is there anything in&amp;nbsp;C:\Program Files\Splunk\var\log\splunk\python.log ?&lt;/P&gt;&lt;P&gt;Its also worth checking the search log, Inspect your search through Job -&amp;gt; Inspect Job and then click the "search.log" link.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does this shine any light on things?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2020 18:59:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Custom-search-command-with-python-stopped-working-not-returning/m-p/510515#M9125</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2020-07-22T18:59:00Z</dc:date>
    </item>
  </channel>
</rss>

