<?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: All URL'S Not coming after using match functionality in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/All-URL-S-Not-coming-after-using-match-functionality/m-p/306770#M92042</link>
    <description>&lt;P&gt;"Because of the way match works"   -  I didnt understood what you mean by this ?   Why the fourth case  will never execute ??&lt;/P&gt;

&lt;P&gt;I have taken below example in which  both the requests are different  , they server diff purpose and i want then separately  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=noact host=loss0* sourcetype=pro-e 
   ( 
     path="/desktop/organization/groups"
      path="/desktop/organization/groups/*"
     )
  | eval URL= case ( 

       match(path,"\/desktop\/organization\/groups"), "/desktop/organization/groups",
      match(path,"\/desktop\/organization\/groups/.*"), "/desktop/organization/groups/*"
        ) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But i observed that when i execute this , splunk  throws  the second URL (/desktop/organization/groups/*)&lt;BR /&gt;
in the new field  'URL' as /desktop/organization/groups   ...and thats why  i am not getting other values &lt;/P&gt;

&lt;P&gt;and i think this is what you are refering to ..am i right?&lt;/P&gt;

&lt;P&gt;Why  this behavior ??&lt;/P&gt;

&lt;P&gt;When  i swapped the position of  URLs in case  command  , then i am getting both the URL's  as expected .....:)     Why this thing i am not  understanding ?&lt;/P&gt;

&lt;P&gt;As match compares the URL with  the regex i give it to and it should populate the values in the field  which i give then why it act like that?? Please clarify this&lt;/P&gt;</description>
    <pubDate>Wed, 30 Aug 2017 00:39:54 GMT</pubDate>
    <dc:creator>shabdadev</dc:creator>
    <dc:date>2017-08-30T00:39:54Z</dc:date>
    <item>
      <title>All URL'S Not coming after using match functionality</title>
      <link>https://community.splunk.com/t5/Splunk-Search/All-URL-S-Not-coming-after-using-match-functionality/m-p/306767#M92039</link>
      <description>&lt;P&gt;Hi ALL,&lt;BR /&gt;
I wrote the below query &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=noact host=loss0* sourcetype=pro-e 

(
path="/desktop/account/" OR
path="/desktop/PerItemNumber" OR
path="/desktop/organization/groups" OR
path="/desktop/organization/groups/*"  
)

| eval URL=

case
(

match(path,"\/desktop\/account"),"/desktop/account",
match(path,"\/desktop\/PerItemNumber"),"/desktop/PerItemNumber",
match(path,"\/desktop\/organization\/groups"),"/desktop/organization/groups",
match(path,"\/desktop\/organization\/groups\/.*"),"/desktop/organization/groups/*"


) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But when i am running it  only the    desktop/account  value is being populated in URL ( NEW FIELD ) .Not sure why   while  rest url's also have values  but  they are not coming .&lt;/P&gt;</description>
      <pubDate>Sun, 27 Aug 2017 06:17:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/All-URL-S-Not-coming-after-using-match-functionality/m-p/306767#M92039</guid>
      <dc:creator>shabdadev</dc:creator>
      <dc:date>2017-08-27T06:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: All URL'S Not coming after using match functionality</title>
      <link>https://community.splunk.com/t5/Splunk-Search/All-URL-S-Not-coming-after-using-match-functionality/m-p/306768#M92040</link>
      <description>&lt;P&gt;[UPDATED ANSWER]&lt;/P&gt;

&lt;P&gt;@shabdadev, sorry I had missed &lt;CODE&gt;.*&lt;/CODE&gt; in my search.&lt;/P&gt;

&lt;P&gt;Match finds a regular expression pattern in the string being searched. So the substring in 3rd condition, i.e. &lt;CODE&gt;"\/desktop\/organization\/groups"&lt;/CODE&gt;, will always be true even if you have more content in your path after &lt;CODE&gt;groups&lt;/CODE&gt;. Hence the final case block will never be hit. If this is clear you do not need a separate case for &lt;CODE&gt;groups/.*&lt;/CODE&gt; as @DalJeanis has suggested.&lt;/P&gt;

&lt;P&gt;In case you want exact match for groups url and partial match for groups url to be categorized differently you can try the following case block:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval path= "/desktop/account/,/desktop/PerItemNumber,/desktop/organization/groups,/desktop/organization/groups/.*"
| makemv path delim=","
| mvexpand path
| eval URL= case (match(path,"/desktop/account"),"/desktop/account",
                  match(path,"/desktop/PerItemNumber"),"/desktop/PerItemNumber",
                  (path="/desktop/organization/groups"),"/desktop/organization/groups",
                  match(path,"/desktop/organization/groups/.*"),"/desktop/organization/groups/.*")
| table path URL
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: As you can see in 3rd condition I am comparing exact url and 4th I am using &lt;CODE&gt;match()&lt;/CODE&gt; pattern.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;It should work as expected. Can you please post some sample Data?&lt;BR /&gt;
Following is a run anywhere search with pipes until mvexpand command to generate paths for four groups you have. I have used similar &lt;CODE&gt;case()&lt;/CODE&gt; and &lt;CODE&gt;match()&lt;/CODE&gt; methods as yours (only modification is backslash need not be escaped)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval path= "/desktop/account/,
 /desktop/PerItemNumber,
 /desktop/organization/groups,
 /desktop/organization/groups/*"
| makemv path delim=","
| mvexpand path
| eval URL= case (match(path,"/desktop/account"),"/desktop/account",
                  match(path,"/desktop/PerItemNumber"),"/desktop/PerItemNumber",
                  match(path,"/desktop/organization/groups"),"/desktop/organization/groups",
                  match(path,"/desktop/organization/groups/.*"),"/desktop/organization/groups/*")
| table path URL
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am able to see four groups of URL as per the path.&lt;/P&gt;</description>
      <pubDate>Sun, 27 Aug 2017 08:26:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/All-URL-S-Not-coming-after-using-match-functionality/m-p/306768#M92040</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-08-27T08:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: All URL'S Not coming after using match functionality</title>
      <link>https://community.splunk.com/t5/Splunk-Search/All-URL-S-Not-coming-after-using-match-functionality/m-p/306769#M92041</link>
      <description>&lt;P&gt;Because of the way &lt;CODE&gt;match&lt;/CODE&gt; works, the fourth case construct is never going to execute, and you don't need it anyway.  I agree with @niketnilay that your code should work fine if the events exist.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index=noact host=loss0* sourcetype=pro-e 
  ( path="/desktop/account/" OR
    path="/desktop/PerItemNumber" OR
    path="/desktop/organization/groups*"
    )
 | eval URL= case ( match(path,"\/desktop\/account"), "/desktop/account",
      match(path,"\/desktop\/PerItemNumber"), "/desktop/PerItemNumber",
      match(path,"\/desktop\/organization\/groups"), "/desktop/organization/groups"
       ) 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Aug 2017 14:40:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/All-URL-S-Not-coming-after-using-match-functionality/m-p/306769#M92041</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-08-29T14:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: All URL'S Not coming after using match functionality</title>
      <link>https://community.splunk.com/t5/Splunk-Search/All-URL-S-Not-coming-after-using-match-functionality/m-p/306770#M92042</link>
      <description>&lt;P&gt;"Because of the way match works"   -  I didnt understood what you mean by this ?   Why the fourth case  will never execute ??&lt;/P&gt;

&lt;P&gt;I have taken below example in which  both the requests are different  , they server diff purpose and i want then separately  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=noact host=loss0* sourcetype=pro-e 
   ( 
     path="/desktop/organization/groups"
      path="/desktop/organization/groups/*"
     )
  | eval URL= case ( 

       match(path,"\/desktop\/organization\/groups"), "/desktop/organization/groups",
      match(path,"\/desktop\/organization\/groups/.*"), "/desktop/organization/groups/*"
        ) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But i observed that when i execute this , splunk  throws  the second URL (/desktop/organization/groups/*)&lt;BR /&gt;
in the new field  'URL' as /desktop/organization/groups   ...and thats why  i am not getting other values &lt;/P&gt;

&lt;P&gt;and i think this is what you are refering to ..am i right?&lt;/P&gt;

&lt;P&gt;Why  this behavior ??&lt;/P&gt;

&lt;P&gt;When  i swapped the position of  URLs in case  command  , then i am getting both the URL's  as expected .....:)     Why this thing i am not  understanding ?&lt;/P&gt;

&lt;P&gt;As match compares the URL with  the regex i give it to and it should populate the values in the field  which i give then why it act like that?? Please clarify this&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2017 00:39:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/All-URL-S-Not-coming-after-using-match-functionality/m-p/306770#M92042</guid>
      <dc:creator>shabdadev</dc:creator>
      <dc:date>2017-08-30T00:39:54Z</dc:date>
    </item>
  </channel>
</rss>

