<?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 Why does my external scripted lookup give me an error code 1? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Why-does-my-external-scripted-lookup-give-me-an-error-code-1/m-p/401275#M6916</link>
    <description>&lt;P&gt;So I created a way to use Mark Baggett's freq_server script as a lookup and blogged about it here (&lt;A href="http://shadowtrackers.net/blog/get-your-freq-on-in-splunk"&gt;http://shadowtrackers.net/blog/get-your-freq-on-in-splunk&lt;/A&gt;).  &lt;/P&gt;

&lt;P&gt;But, that is not the point of this forum post.&lt;/P&gt;

&lt;P&gt;I had based my blog post on my setup at home.  I was running a single Splunk server and making the URL connection to a separate Linux server running in a vm on the same box as the Splunk server.  So, when I got to work and tried to implement the same lookup, I was surprised and frustrated when it didn't work right out of the box.  On the small Splunk instance where I implemented the lookup, I have a single search head and two Indexers.  When I ran the lookup search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=dns | rename query as domain | lookup freqserver domain
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I received the following error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    2 errors occurred while the search was executing. Therefore, search results might be incomplete. Hide errors.   

        [INDEX01] Script for lookup table 'freqserver' returned error code 1. Results may be incorrect.
        [INDEX02] Script for lookup table 'freqserver' returned error code 1. Results may be incorrect.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 09 Jan 2019 19:09:40 GMT</pubDate>
    <dc:creator>reswob4</dc:creator>
    <dc:date>2019-01-09T19:09:40Z</dc:date>
    <item>
      <title>Why does my external scripted lookup give me an error code 1?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-does-my-external-scripted-lookup-give-me-an-error-code-1/m-p/401275#M6916</link>
      <description>&lt;P&gt;So I created a way to use Mark Baggett's freq_server script as a lookup and blogged about it here (&lt;A href="http://shadowtrackers.net/blog/get-your-freq-on-in-splunk"&gt;http://shadowtrackers.net/blog/get-your-freq-on-in-splunk&lt;/A&gt;).  &lt;/P&gt;

&lt;P&gt;But, that is not the point of this forum post.&lt;/P&gt;

&lt;P&gt;I had based my blog post on my setup at home.  I was running a single Splunk server and making the URL connection to a separate Linux server running in a vm on the same box as the Splunk server.  So, when I got to work and tried to implement the same lookup, I was surprised and frustrated when it didn't work right out of the box.  On the small Splunk instance where I implemented the lookup, I have a single search head and two Indexers.  When I ran the lookup search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=dns | rename query as domain | lookup freqserver domain
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I received the following error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    2 errors occurred while the search was executing. Therefore, search results might be incomplete. Hide errors.   

        [INDEX01] Script for lookup table 'freqserver' returned error code 1. Results may be incorrect.
        [INDEX02] Script for lookup table 'freqserver' returned error code 1. Results may be incorrect.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Jan 2019 19:09:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-does-my-external-scripted-lookup-give-me-an-error-code-1/m-p/401275#M6916</guid>
      <dc:creator>reswob4</dc:creator>
      <dc:date>2019-01-09T19:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: Why does my external scripted lookup give me an error code 1?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-does-my-external-scripted-lookup-give-me-an-error-code-1/m-p/401276#M6917</link>
      <description>&lt;P&gt;My first thought was WTH? &lt;/P&gt;

&lt;P&gt;But here are some of the things I tried:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/369810/python-alert-script-fails-and-i-cant-see-errors-in.html"&gt;https://answers.splunk.com/answers/369810/python-alert-script-fails-and-i-cant-see-errors-in.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/559456/script-for-lookup-table-whois-returned-error-code.html"&gt;https://answers.splunk.com/answers/559456/script-for-lookup-table-whois-returned-error-code.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;But ultimately the information in the error clued me in.  The linux server at work where I was running the frequency analysis server had iptables running and I had configured it to allow my SH to connect on the exact port the frequency analysis server was listening on.  But what I didn't know, and isn't mentioned here (&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Configureexternallookups"&gt;https://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Configureexternallookups&lt;/A&gt;), is that the script is actually run from the search peers (which in my case were the indexers).  Since the search peers were not permitted to connect to the frequency analysis server per the iptables rules, the script was blocked from connecting and thus it failed.  &lt;/P&gt;

&lt;P&gt;Once I opened up iptables to allow the search peers access to the frequency analysis server, everything worked. &lt;/P&gt;

&lt;P&gt;Maybe someone from Splunk can better explain, but apparently the script is copied from the SH to one of the following locations (or both) on each search peer and run from there:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$SPLUNK_HOME$/var/run/searchpeers/&amp;lt;servername&amp;gt;-#########/searchscripts/
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$SPLUNK_HOME$/var/run/searchpeers/&amp;lt;servername&amp;gt;-#########/system/bin/
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hopefully this helps someone else troubleshoot their scripted lookups....&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jan 2019 19:10:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-does-my-external-scripted-lookup-give-me-an-error-code-1/m-p/401276#M6917</guid>
      <dc:creator>reswob4</dc:creator>
      <dc:date>2019-01-09T19:10:57Z</dc:date>
    </item>
  </channel>
</rss>

