<?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 regex on inputlookup (via python script ?) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/regex-on-inputlookup-via-python-script/m-p/258198#M77350</link>
    <description>&lt;P&gt;I tried to use regex on inputlookup csv file, but seems that although Splunk regex works fine on search but&lt;BR /&gt;
it doesnt work on inputlookup tables. &lt;/P&gt;

&lt;P&gt;Is there anyway to add a python script that takes the input csv file and then gives me the parsed value from the regex to be piped for next processing ?&lt;/P&gt;

&lt;P&gt;i.e.&lt;/P&gt;

&lt;P&gt;| inputlookup data.csv python_regex_script.py | table  regex_field&lt;/P&gt;

&lt;P&gt;Also as a general question, is it possible to add python script in a splunk search query ?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 09:10:46 GMT</pubDate>
    <dc:creator>smhsplunk</dc:creator>
    <dc:date>2020-09-29T09:10:46Z</dc:date>
    <item>
      <title>regex on inputlookup (via python script ?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-on-inputlookup-via-python-script/m-p/258198#M77350</link>
      <description>&lt;P&gt;I tried to use regex on inputlookup csv file, but seems that although Splunk regex works fine on search but&lt;BR /&gt;
it doesnt work on inputlookup tables. &lt;/P&gt;

&lt;P&gt;Is there anyway to add a python script that takes the input csv file and then gives me the parsed value from the regex to be piped for next processing ?&lt;/P&gt;

&lt;P&gt;i.e.&lt;/P&gt;

&lt;P&gt;| inputlookup data.csv python_regex_script.py | table  regex_field&lt;/P&gt;

&lt;P&gt;Also as a general question, is it possible to add python script in a splunk search query ?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:10:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-on-inputlookup-via-python-script/m-p/258198#M77350</guid>
      <dc:creator>smhsplunk</dc:creator>
      <dc:date>2020-09-29T09:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: regex on inputlookup (via python script ?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-on-inputlookup-via-python-script/m-p/258199#M77351</link>
      <description>&lt;P&gt;Not sure what you intended to do, but if you had this lookup file:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;customer     host        service
Customer1   ABC123431   Service1
Customer2   ABC123300   Service2
Customer3   ABC123321   Service3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And you are interested in what comes after the ABC in the host field, you can simply do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup file.csv | rex field=host "ABC(?&amp;lt;host_id&amp;gt;\d+)" | table customer host host_id service
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The rex command will extract any regular expression from any field you tell it to, no matter the source.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2016 14:19:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-on-inputlookup-via-python-script/m-p/258199#M77351</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2016-03-24T14:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: regex on inputlookup (via python script ?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-on-inputlookup-via-python-script/m-p/258200#M77352</link>
      <description>&lt;P&gt;One cannot use a regex with inputlookup directly.  However, there are other options.&lt;/P&gt;

&lt;P&gt;If you're running 6.3.3, you may be able to use inputlookup's where argument to filter the lookup data&lt;BR /&gt;
Pipe the lookup to &lt;CODE&gt;regex&lt;/CODE&gt; as in &lt;CODE&gt;|inputlookup data.csv foo | regex "some regex string" | ...&lt;/CODE&gt; &lt;BR /&gt;
Create a custom command that reads and processes your CSV file.  See the &lt;CODE&gt;script&lt;/CODE&gt; command at &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Script"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Script&lt;/A&gt; and "About writing custom search commands" at &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.3/Search/Aboutcustomsearchcommands"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.3/Search/Aboutcustomsearchcommands&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2016 14:26:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-on-inputlookup-via-python-script/m-p/258200#M77352</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-03-24T14:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: regex on inputlookup (via python script ?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-on-inputlookup-via-python-script/m-p/258201#M77353</link>
      <description>&lt;P&gt;Thanks! I am going through the examples right now.&lt;BR /&gt;
Will get back if I run into any issues.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2016 17:14:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-on-inputlookup-via-python-script/m-p/258201#M77353</guid>
      <dc:creator>smhsplunk</dc:creator>
      <dc:date>2016-03-24T17:14:27Z</dc:date>
    </item>
  </channel>
</rss>

