<?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: Case condition check issue in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Case-condition-check-issue/m-p/379900#M111229</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;
I have added some sample data. Please check.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Jun 2018 14:01:50 GMT</pubDate>
    <dc:creator>mugilbala</dc:creator>
    <dc:date>2018-06-12T14:01:50Z</dc:date>
    <item>
      <title>Case condition check issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Case-condition-check-issue/m-p/379896#M111225</link>
      <description>&lt;P&gt;Application logs execution time for many apis. I am interested in 2 apis with following urls.&lt;BR /&gt;
/apis/deviceservice/2.0/accounts/&lt;STRONG&gt;&lt;EM&gt;acountid&lt;/EM&gt;&lt;/STRONG&gt;/devices&lt;BR /&gt;
/apis/deviceservice/2.0/accounts/devices/&lt;STRONG&gt;&lt;EM&gt;deviceId&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I am trying to print a report with following query.&lt;/P&gt;

&lt;P&gt;index="xyz" source="*access.log" &lt;BR /&gt;
| eval Service=case( &lt;BR /&gt;
Url like ("%/apis/deviceservice/2.0/accounts/devices/%") AND Method="GET", "Get Specific Device", &lt;BR /&gt;
Url like ("%/apis/deviceservice/2.0/accounts/%/devices"), "Get Devices Account Level",&lt;BR /&gt;&lt;BR /&gt;
true(), Url  ) &lt;BR /&gt;
| table ExternalId, Time, Service | xyseries ExternalId Service Time &lt;/P&gt;

&lt;P&gt;Sample data:&lt;BR /&gt;
2018-06-12 07:40:45,643 GMT DEBUG Bytes=3653|HttpStatus=200|Method=GET|Time=42|Url=&lt;A href="https://hostip/apis/deviceservice/2.0/accounts/devices/9930cf66-3480-4e7a-b31b-539287dfcd10%7CLogMessage=HTTP"&gt;https://hostip/apis/deviceservice/2.0/accounts/devices/9930cf66-3480-4e7a-b31b-539287dfcd10|LogMessage=HTTP&lt;/A&gt; 200&lt;BR /&gt;
2018-06-12 07:40:45,643 GMT DEBUG Bytes=3653|HttpStatus=200|Method=GET|Time=45|Url=&lt;A href="https://hostip/apis/deviceservice/2.0/accounts/e7546806-a507-49dc-853c-7dcae1a85f92/devices%7CLogMessage=HTTP"&gt;https://hostip/apis/deviceservice/2.0/accounts/e7546806-a507-49dc-853c-7dcae1a85f92/devices|LogMessage=HTTP&lt;/A&gt; 200&lt;BR /&gt;
2018-06-12 07:40:45,644 GMT DEBUG Bytes=3653|HttpStatus=200|Method=GET|Time=38|Url=&lt;A href="https://hostip/apis/deviceservice/2.0/accounts/devices/9930cf66-3480-4e7a-b31b-539287dfcd10%7CLogMessage=HTTP"&gt;https://hostip/apis/deviceservice/2.0/accounts/devices/9930cf66-3480-4e7a-b31b-539287dfcd10|LogMessage=HTTP&lt;/A&gt; 200&lt;BR /&gt;
2018-06-12 07:40:45,708 GMT DEBUG Bytes=3653|HttpStatus=200|Method=GET|Time=71|Url=&lt;A href="https://hostip/apis/deviceservice/2.0/accounts/e7546806-a507-49dc-853c-7dcae1a85f92/devices%7CLogMessage=HTTP"&gt;https://hostip/apis/deviceservice/2.0/accounts/e7546806-a507-49dc-853c-7dcae1a85f92/devices|LogMessage=HTTP&lt;/A&gt; 200&lt;BR /&gt;
2018-06-12 07:41:45,689 GMT DEBUG Bytes=3653|HttpStatus=200|Method=GET|Time=28|Url=&lt;A href="https://hostip/apis/deviceservice/2.0/accounts/devices/9930cf66-3480-4e7a-b31b-539287dfcd10%7CLogMessage=HTTP"&gt;https://hostip/apis/deviceservice/2.0/accounts/devices/9930cf66-3480-4e7a-b31b-539287dfcd10|LogMessage=HTTP&lt;/A&gt; 200&lt;/P&gt;

&lt;P&gt;How ever, "Url like ("%/apis/deviceservice/2.0/accounts/%/devices")" condition is not working as expected and prints the full url with different account ids.&lt;/P&gt;

&lt;P&gt;Can you help me with the correct condition to achieve the result?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 13:42:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Case-condition-check-issue/m-p/379896#M111225</guid>
      <dc:creator>mugilbala</dc:creator>
      <dc:date>2018-06-11T13:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: Case condition check issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Case-condition-check-issue/m-p/379897#M111226</link>
      <description>&lt;P&gt;post some sample data. &lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 17:10:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Case-condition-check-issue/m-p/379897#M111226</guid>
      <dc:creator>vasanthmss</dc:creator>
      <dc:date>2018-06-11T17:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: Case condition check issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Case-condition-check-issue/m-p/379898#M111227</link>
      <description>&lt;P&gt;&lt;STRONG&gt;[UPDATED ANSWER]&lt;/STRONG&gt;&lt;BR /&gt;
Based on raw events provided, you would need to use following updated &lt;CODE&gt;match()&lt;/CODE&gt; condition. &lt;CODE&gt;.*&lt;/CODE&gt; has been added as beginning pattern.&lt;/P&gt;

&lt;P&gt;@mugilbala you can use following &lt;CODE&gt;match()&lt;/CODE&gt; eval function instead of like to use regular expression based pattern match.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval data="2018-06-12 07:40:45,643 GMT DEBUG Bytes=3653|HttpStatus=200|Method=GET|Time=42|Url=https://hostip/apis/deviceservice/2.0/accounts/devices/9930cf66-3480-4e7a-b31b-539287dfcd10|LogMessage=HTTP 200;2018-06-12 07:40:45,643 GMT DEBUG Bytes=3653|HttpStatus=200|Method=GET|Time=45|Url=https://hostip/apis/deviceservice/2.0/accounts/e7546806-a507-49dc-853c-7dcae1a85f92/devices|LogMessage=HTTP 200;2018-06-12 07:40:45,644 GMT DEBUG Bytes=3653|HttpStatus=200|Method=GET|Time=38|Url=https://hostip/apis/deviceservice/2.0/accounts/devices/9930cf66-3480-4e7a-b31b-539287dfcd10|LogMessage=HTTP 200;2018-06-12 07:40:45,708 GMT DEBUG Bytes=3653|HttpStatus=200|Method=GET|Time=71|Url=https://hostip/apis/deviceservice/2.0/accounts/e7546806-a507-49dc-853c-7dcae1a85f92/devices|LogMessage=HTTP 200;2018-06-12 07:41:45,689 GMT DEBUG Bytes=3653|HttpStatus=200|Method=GET|Time=28|Url=https://hostip/apis/deviceservice/2.0/accounts/devices/9930cf66-3480-4e7a-b31b-539287dfcd10|LogMessage=HTTP 200"
| makemv data delim=";"
| mvexpand data
| rename data as _raw
| KV
| eval Service=case( 
     match(Url,".*\/apis\/deviceservice\/2\.0\/accounts\/devices\/"), "Get Specific Device", 
     match(Url,".*\/apis\/deviceservice\/2\.0\/accounts\/[^\/]+\/devices"), "Get Devices Account Level",
     true(), Url )
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jun 2018 06:35:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Case-condition-check-issue/m-p/379898#M111227</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-06-12T06:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Case condition check issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Case-condition-check-issue/m-p/379899#M111228</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
Thanks for quick response. I have added sample data. I tried your suggestion and it did not work. Can you please check the sample data provided and let me know if any change is required for the search query?&lt;/P&gt;

&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 14:01:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Case-condition-check-issue/m-p/379899#M111228</guid>
      <dc:creator>mugilbala</dc:creator>
      <dc:date>2018-06-12T14:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: Case condition check issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Case-condition-check-issue/m-p/379900#M111229</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I have added some sample data. Please check.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 14:01:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Case-condition-check-issue/m-p/379900#M111229</guid>
      <dc:creator>mugilbala</dc:creator>
      <dc:date>2018-06-12T14:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: Case condition check issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Case-condition-check-issue/m-p/379901#M111230</link>
      <description>&lt;P&gt;Please try the updated answer as per your question following is the regular expression based match() you need:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;yourCurrentSearch&amp;gt;
 | eval Service=case( 
      match(Url,".*\/apis\/deviceservice\/2\.0\/accounts\/devices\/"), "Get Specific Device", 
      match(Url,".*\/apis\/deviceservice\/2\.0\/accounts\/[^\/]+\/devices"), "Get Devices Account Level",
      true(), Url )
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jun 2018 02:25:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Case-condition-check-issue/m-p/379901#M111230</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-06-13T02:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: Case condition check issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Case-condition-check-issue/m-p/379902#M111231</link>
      <description>&lt;P&gt;Thank you. It worked as needed. Appreciate your help.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2018 14:49:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Case-condition-check-issue/m-p/379902#M111231</guid>
      <dc:creator>mugilbala</dc:creator>
      <dc:date>2018-06-13T14:49:41Z</dc:date>
    </item>
  </channel>
</rss>

