<?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: mvindex with a conditional in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-this-search-with-a-mvindex-with-a-conditional/m-p/630153#M218922</link>
    <description>&lt;P&gt;Not a problem. It looks like I may have achieved it by modifying your solution. I had issues in the past with Regex so was hoping to use this. &lt;U&gt;I am not sure what "null" does in the below "status_index"&lt;/U&gt; but it seems to work by not including frivolous information.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="user33_0-1675875201520.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/23785i2DFF8D4372D8DE53/image-size/medium?v=v2&amp;amp;px=400" role="button" title="user33_0-1675875201520.png" alt="user33_0-1675875201520.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval temp=split(_raw," ")
| eval status_index1 = if(match(API,"/services/protected/v1/developers"), 6, null)
| eval status_index2 = if(match(API,"/services/public/v1/signup"), 6, null)
| eval status_index3 = if(match(API,"/wcaapi/userReg/wgt/apps"), 10, null)
| eval http_status1 = mvindex(temp, status_index1)
| eval http_status2 = mvindex(temp, status_index2)
| eval http_status3 = mvindex(temp, status_index3)
| eval http_status = coalesce(http_status1, http_status2, http_status3)

| search (
"/services/public/v1/signup" OR
"/services/protected/v1/developers" OR 
"/services/public/v1/captcha" OR 
"/wcaapi/userReg/wgt/apps"
)
| search NOT "Mozilla"
| eval API = if(match(API,"/services/public/v1/signup"), "DEVP1: Signup", API)
| eval API = if(match(API,"/services/protected/v1/developers"), "DEVP1: Developers", API)
| eval API = if(match(API,"/services/public/v1/captcha"), "DEVP1: Captcha", API)
| eval API = if(match(API,"/wcaapi/userReg/wgt/apps"), "User Registration Enhanced Login", API)
| fields API, http_status, wf_env
| convert timeformat="%Y-%m" ctime(_time) AS Date
| stats count(http_status) as Total_Calls, count(eval(http_status&amp;gt;=500)) as Server_Error by Date, API, wf_env
| eval SuccessRate=round((1-(Server_Error/Total_Calls)) * 100,2)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Feb 2023 16:53:45 GMT</pubDate>
    <dc:creator>user33</dc:creator>
    <dc:date>2023-02-08T16:53:45Z</dc:date>
    <item>
      <title>How do I write this search with a mvindex with a conditional?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-this-search-with-a-mvindex-with-a-conditional/m-p/629986#M218856</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have the below SPL with the two &lt;EM&gt;mvindex&lt;/EM&gt; functions.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;mvindex&lt;/EM&gt;&amp;nbsp;position '6' in the array &lt;U&gt;is supposed&lt;/U&gt; to apply http statuses for /&lt;EM&gt;developers.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;mvindex&lt;/EM&gt;&amp;nbsp;position '10' in the array &lt;U&gt;is supposed&lt;/U&gt; to apply http statuses for &lt;EM&gt;/apps&lt;/EM&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently position 6 and 10 are crossing events. Applying to both APIs. Is there anyway I can have one mvindex apply to one command?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;(index=wf_pvsi_virt OR index=wf_pvsi_tmps) (sourcetype="wf:wca:access:txt" OR sourcetype="wf:devp1:access:txt") wf_env=PROD
| eval temp=split(_raw," ")
| eval API=mvindex(temp,4,8)
| eval http_status=mvindex(temp,6,10)
| search (
"/services/protected/v1/developers" OR
"/wcaapi/userReg/wgt/apps"
)
| search NOT "Mozilla"
| eval API = if(match(API,"/services/protected/v1/developers"), "DEVP1: Developers", API)
| eval API = if(match(API,"/wcaapi/userReg/wgt/apps"), "User Registration Enhanced Login", API)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 16:44:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-this-search-with-a-mvindex-with-a-conditional/m-p/629986#M218856</guid>
      <dc:creator>user33</dc:creator>
      <dc:date>2023-02-08T16:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: mvindex with a conditional</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-this-search-with-a-mvindex-with-a-conditional/m-p/629993#M218859</link>
      <description>&lt;LI-CODE lang="markup"&gt;| eval status_index = if(match(API,"/services/protected/v1/developers"), 6, 10)
| eval http_status=mvindex(temp, status_index)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 07 Feb 2023 22:44:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-this-search-with-a-mvindex-with-a-conditional/m-p/629993#M218859</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-02-07T22:44:28Z</dc:date>
    </item>
    <item>
      <title>Re: mvindex with a conditional</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-this-search-with-a-mvindex-with-a-conditional/m-p/630112#M218906</link>
      <description>&lt;P&gt;Thank you!!&lt;/P&gt;&lt;P&gt;However, if I wanted to make more than one "status_index" for each API and then combine all status_indexes into one field called "http_status"; how would I do that?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 13:49:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-this-search-with-a-mvindex-with-a-conditional/m-p/630112#M218906</guid>
      <dc:creator>user33</dc:creator>
      <dc:date>2023-02-08T13:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: mvindex with a conditional</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-this-search-with-a-mvindex-with-a-conditional/m-p/630113#M218907</link>
      <description>&lt;P&gt;What I am attempting to do below:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval temp=split(_raw," ")
| eval API=mvindex(temp,4,8)
```| eval http_status=mvindex(temp,6,10)```

| eval status_index = if(match(API,"/services/protected/v1/developers"), 4, 6)
| eval status_index1 = if(match(API,"/services/public/v1/signup"), 4, 6)
| eval status_index2 = if(match(API,"/wcaapi/userReg/wgt/apps"), 8, 10)
| eval http_status=mvindex(temp, status_index)


| search (
"/services/public/v1/signup" OR
"/services/protected/v1/developers" OR 
"/services/public/v1/captcha" OR 
"/wcaapi/userReg/wgt/apps"
)
| eval API = if(match(API,"/services/public/v1/signup"), "DEVP1: Signup", API)
| eval API = if(match(API,"/services/protected/v1/developers"), "DEVP1: Developers", API)
| eval API = if(match(API,"/services/public/v1/captcha"), "DEVP1: Captcha", API)
| eval API = if(match(API,"/wcaapi/userReg/wgt/apps"), "User Registration Enhanced Login", API)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 08 Feb 2023 13:50:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-this-search-with-a-mvindex-with-a-conditional/m-p/630113#M218907</guid>
      <dc:creator>user33</dc:creator>
      <dc:date>2023-02-08T13:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: mvindex with a conditional</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-this-search-with-a-mvindex-with-a-conditional/m-p/630141#M218916</link>
      <description>&lt;P&gt;I am not sure I understand what you are trying to do. Please can you share some sample events and highlight which part you want extracted to which field - rex might be an easier option for you.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 15:53:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-this-search-with-a-mvindex-with-a-conditional/m-p/630141#M218916</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-02-08T15:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: mvindex with a conditional</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-this-search-with-a-mvindex-with-a-conditional/m-p/630153#M218922</link>
      <description>&lt;P&gt;Not a problem. It looks like I may have achieved it by modifying your solution. I had issues in the past with Regex so was hoping to use this. &lt;U&gt;I am not sure what "null" does in the below "status_index"&lt;/U&gt; but it seems to work by not including frivolous information.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="user33_0-1675875201520.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/23785i2DFF8D4372D8DE53/image-size/medium?v=v2&amp;amp;px=400" role="button" title="user33_0-1675875201520.png" alt="user33_0-1675875201520.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval temp=split(_raw," ")
| eval status_index1 = if(match(API,"/services/protected/v1/developers"), 6, null)
| eval status_index2 = if(match(API,"/services/public/v1/signup"), 6, null)
| eval status_index3 = if(match(API,"/wcaapi/userReg/wgt/apps"), 10, null)
| eval http_status1 = mvindex(temp, status_index1)
| eval http_status2 = mvindex(temp, status_index2)
| eval http_status3 = mvindex(temp, status_index3)
| eval http_status = coalesce(http_status1, http_status2, http_status3)

| search (
"/services/public/v1/signup" OR
"/services/protected/v1/developers" OR 
"/services/public/v1/captcha" OR 
"/wcaapi/userReg/wgt/apps"
)
| search NOT "Mozilla"
| eval API = if(match(API,"/services/public/v1/signup"), "DEVP1: Signup", API)
| eval API = if(match(API,"/services/protected/v1/developers"), "DEVP1: Developers", API)
| eval API = if(match(API,"/services/public/v1/captcha"), "DEVP1: Captcha", API)
| eval API = if(match(API,"/wcaapi/userReg/wgt/apps"), "User Registration Enhanced Login", API)
| fields API, http_status, wf_env
| convert timeformat="%Y-%m" ctime(_time) AS Date
| stats count(http_status) as Total_Calls, count(eval(http_status&amp;gt;=500)) as Server_Error by Date, API, wf_env
| eval SuccessRate=round((1-(Server_Error/Total_Calls)) * 100,2)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 16:53:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-write-this-search-with-a-mvindex-with-a-conditional/m-p/630153#M218922</guid>
      <dc:creator>user33</dc:creator>
      <dc:date>2023-02-08T16:53:45Z</dc:date>
    </item>
  </channel>
</rss>

