<?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: Splitting single lookup table column/field to filter on multiple fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splitting-single-lookup-table-column-field-to-filter-on-multiple/m-p/310756#M93196</link>
    <description>&lt;P&gt;Hi Kamlesh,&lt;/P&gt;

&lt;P&gt;The issue specifically was about using eval with split in the subsearch in the lookup. So the ask is :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; host=data_source "data{}.http_status_code"= 5* NOT [| inputlookup 5xx-error-lookup | *&amp;lt;SPLIT endpoint_url FROM LOOKUP AND THEN USE THE 2 FIELDS AS FILTERS ON THE OUTER SEARCH&amp;gt;* ] | eval endpoint_url='data{}.hostname'+'data{}.uri' | stats count(endpoint_url) as error-count by endpoint_url
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any pointers here?&lt;/P&gt;</description>
    <pubDate>Thu, 19 Oct 2017 14:56:57 GMT</pubDate>
    <dc:creator>technie101</dc:creator>
    <dc:date>2017-10-19T14:56:57Z</dc:date>
    <item>
      <title>Splitting single lookup table column/field to filter on multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splitting-single-lookup-table-column-field-to-filter-on-multiple/m-p/310754#M93194</link>
      <description>&lt;P&gt;We have JSON logs being stored in Splunk. A sample log record looks like : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
     data:
      {
        "hostname":"http://server.com",
        "uri":"/api/something/",
        "service":"service_1",
        "http_status_code":"500"
      }
 }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The following search query (to find endpoints which throw 5xx errors) runs against a schedule and puts the results in a KVStore (lookup table) : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=data_source "data{}.http_status_code"= 5* | eval endpoint_url='data{}.hostname'+'data{}.uri' | stats count(endpoint_url) as error-count by endpoint_url | outputlookup 5xx-error-lookup
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The requirement now is that, we have to only show endpoints (results) that were not part of the previous search.&lt;BR /&gt;
I am able to filter results against a simple field like service_name with something like.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=data_source "data{}.http_status_code"= 5* NOT [| inputlookup 5xx-error-lookup | fields service-name | rename service-name as data{}.service_name ] | eval endpoint_url='data{}.hostname'+'data{}.uri' | stats count(endpoint_url) as error-count by endpoint_url
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I'd actually want to do is to split the endpoint_url to 'hostname' and 'uri' and filter results based on a match for BOTH these fields. Any inputs please?&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 17:13:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splitting-single-lookup-table-column-field-to-filter-on-multiple/m-p/310754#M93194</guid>
      <dc:creator>technie101</dc:creator>
      <dc:date>2017-10-18T17:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting single lookup table column/field to filter on multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splitting-single-lookup-table-column-field-to-filter-on-multiple/m-p/310755#M93195</link>
      <description>&lt;P&gt;hi @technie101,&lt;/P&gt;

&lt;P&gt;Can you try below approach?&lt;BR /&gt;
Here I'm adding a &lt;CODE&gt;"|"&lt;/CODE&gt; (pipe) as a separator in endpoint_url field. see below lookup search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=data_source "data{}.http_status_code"= 5* | eval endpoint_url='data{}.hostname'+'|'+'data{}.uri' | stats count(endpoint_url) as error-count by endpoint_url | outputlookup 5xx-error-lookup
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And split using &lt;CODE&gt;split&lt;/CODE&gt; and &lt;CODE&gt;mvindex&lt;/CODE&gt;. check below search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR SEACH | eval hostname=mvindex(split(endpoint_url,"|"),0), uri=mvindex(split(endpoint_url,"|"),1)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if any help you need.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 17:49:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splitting-single-lookup-table-column-field-to-filter-on-multiple/m-p/310755#M93195</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2017-10-18T17:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting single lookup table column/field to filter on multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splitting-single-lookup-table-column-field-to-filter-on-multiple/m-p/310756#M93196</link>
      <description>&lt;P&gt;Hi Kamlesh,&lt;/P&gt;

&lt;P&gt;The issue specifically was about using eval with split in the subsearch in the lookup. So the ask is :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; host=data_source "data{}.http_status_code"= 5* NOT [| inputlookup 5xx-error-lookup | *&amp;lt;SPLIT endpoint_url FROM LOOKUP AND THEN USE THE 2 FIELDS AS FILTERS ON THE OUTER SEARCH&amp;gt;* ] | eval endpoint_url='data{}.hostname'+'data{}.uri' | stats count(endpoint_url) as error-count by endpoint_url
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any pointers here?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2017 14:56:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splitting-single-lookup-table-column-field-to-filter-on-multiple/m-p/310756#M93196</guid>
      <dc:creator>technie101</dc:creator>
      <dc:date>2017-10-19T14:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting single lookup table column/field to filter on multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splitting-single-lookup-table-column-field-to-filter-on-multiple/m-p/310757#M93197</link>
      <description>&lt;P&gt;Hi Kamlesh - any help here please?&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2017 12:55:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splitting-single-lookup-table-column-field-to-filter-on-multiple/m-p/310757#M93197</guid>
      <dc:creator>technie101</dc:creator>
      <dc:date>2017-10-30T12:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting single lookup table column/field to filter on multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splitting-single-lookup-table-column-field-to-filter-on-multiple/m-p/310758#M93198</link>
      <description>&lt;P&gt;Hi &lt;BR /&gt;
Apology for late reply.&lt;BR /&gt;
Can you please try this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=data_source "data{}.http_status_code"= 5* NOT [| inputlookup 5xx-error-lookup  | eval hostname=mvindex(split(endpoint_url,"|"),0),uri=mvindex(split(endpoint_url,"|"),1) | return @hostname @uri] | eval endpoint_url='data{}.hostname'+'data{}.uri' | stats count(endpoint_url) as error-count by endpoint_url
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Oct 2017 13:28:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splitting-single-lookup-table-column-field-to-filter-on-multiple/m-p/310758#M93198</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2017-10-30T13:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting single lookup table column/field to filter on multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splitting-single-lookup-table-column-field-to-filter-on-multiple/m-p/310759#M93199</link>
      <description>&lt;P&gt;I get an error saying : 'Error in 'eval' command: The arguments to the 'split' function are invalid.'&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2017 06:38:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splitting-single-lookup-table-column-field-to-filter-on-multiple/m-p/310759#M93199</guid>
      <dc:creator>technie101</dc:creator>
      <dc:date>2017-10-31T06:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting single lookup table column/field to filter on multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splitting-single-lookup-table-column-field-to-filter-on-multiple/m-p/310760#M93200</link>
      <description>&lt;P&gt;@technie101, since everything else is working fine for you and you want to split &lt;CODE&gt;endpoint_url&lt;/CODE&gt; as &lt;CODE&gt;hostname&lt;/CODE&gt; and &lt;CODE&gt;uri&lt;/CODE&gt;, I am giving you only that piece.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[| inputlookup 5xx-error-lookup 
| fields endpoint_url 
| rex field=endpoint_url "(?&amp;lt;hostname&amp;gt;\w+\:\/\/\w+\.\w+)(?&amp;lt;uri&amp;gt;\/\w+\/\w+\/)"
| rename hostname as "data{}.hostname"
| rename uri as "data{}.uri" ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: &lt;BR /&gt;
I have tested regular expression based on only one sample data provided. Please refer to various hostname you have got and the uri to ensure that your regular expression is working as expected with the sample data. Use regex101.com for testing regular expression with sample data (ll possible patterns).&lt;/P&gt;

&lt;P&gt;It would be better to create field alias (or rename in the base index search rather than lookup here, since it is better to have normalized field names without special characters like &lt;CODE&gt;{&lt;/CODE&gt;, &lt;CODE&gt;}&lt;/CODE&gt; and &lt;CODE&gt;.&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Please try out and confirm.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2017 09:24:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splitting-single-lookup-table-column-field-to-filter-on-multiple/m-p/310760#M93200</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-10-31T09:24:14Z</dc:date>
    </item>
  </channel>
</rss>

