<?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: How to create a query for below scenarios? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344287#M101990</link>
    <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xyz  | rex "(?i)find url (?P[^ ]+)"  | search [|gentimes start=-1 | eval URI=split("URL1 OR URL2 OR URL3 OR URL4 OR URL5"," OR ") | table URI| mvexpand URI] | stats count by URI
| append [|gentimes start=-1 | eval URI=split("URL1 OR URL2 OR URL3 OR URL4 OR URL5"," OR ") | table URI| mvexpand URI | eval count=0]
| stats max(count) as count by URI
| eval Status=if(count=0,"Failed","Passed")
| table URI Status
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 23 Apr 2018 20:33:23 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2018-04-23T20:33:23Z</dc:date>
    <item>
      <title>How to create a query for below scenarios?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344278#M101981</link>
      <description>&lt;P&gt;field="URL1 OR URL2 OR URL3"&lt;/P&gt;

&lt;P&gt;I need to search each URL in . If the search is returns values, count &amp;gt;0 then it's Passed. If it doesn't, count ==0 then it's Failed. I will need to display a table with below format&lt;/P&gt;

&lt;P&gt;List of URL Status&lt;BR /&gt;
URL1           Passed&lt;BR /&gt;
URL2           Failed&lt;BR /&gt;
URL3           Passed&lt;/P&gt;

&lt;P&gt;Kindly let me know how to create query for this use case. Thanks in advance&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 14:54:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344278#M101981</guid>
      <dc:creator>lawzuns</dc:creator>
      <dc:date>2018-04-20T14:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a query for below scenarios?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344279#M101982</link>
      <description>&lt;P&gt;Could you try the following?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=&amp;lt;your_index&amp;gt; field=URL1 OR field=URL2 OR field=URL3
| stats count as Status by field
| eval Status=case( Status == 0, "Failed",
true(), "Passed")
| rename field as "List of URL"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Apr 2018 16:10:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344279#M101982</guid>
      <dc:creator>damien_chillet</dc:creator>
      <dc:date>2018-04-20T16:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a query for below scenarios?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344280#M101983</link>
      <description>&lt;P&gt;Error in 'eval' command: The expression is malformed. An unexpected character is reached at '= 0, "Failed", true(), Passed)'.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 16:40:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344280#M101983</guid>
      <dc:creator>lawzuns</dc:creator>
      <dc:date>2018-04-20T16:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a query for below scenarios?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344281#M101984</link>
      <description>&lt;P&gt;Whoops i've missed something, edited my answer (sorry was "air splunking")&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 16:45:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344281#M101984</guid>
      <dc:creator>damien_chillet</dc:creator>
      <dc:date>2018-04-20T16:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a query for below scenarios?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344282#M101985</link>
      <description>&lt;P&gt;I replaces Case with If statement.&lt;BR /&gt;
eval Status=if(Status == 0, "Failed","Passed")&lt;/P&gt;

&lt;P&gt;Now the result is&lt;BR /&gt;
URL1 Passed&lt;BR /&gt;
URL3 Passed&lt;/P&gt;

&lt;P&gt;All Failed status are skipped. I am looking for a solution to display all the URLs with both Passed and Failed.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 16:47:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344282#M101985</guid>
      <dc:creator>lawzuns</dc:creator>
      <dc:date>2018-04-20T16:47:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a query for below scenarios?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344283#M101986</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=YourIndexHere AND field IN("URL1", "URL2", "URL3")
| stats count(eval(field="URL1")) AS URL1  count(eval(field="URL2")) AS URL2  count(eval(field="URL3")) AS URL3
| foreach * [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=if((&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; &amp;gt;0), "Passed", "Failed") ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 22 Apr 2018 19:50:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344283#M101986</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-04-22T19:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a query for below scenarios?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344284#M101987</link>
      <description>&lt;P&gt;Well actually, if the URL2 is not in any event returned by the search it is normal it does not appear.&lt;BR /&gt;
Is it only 3 URLs you are searching for? If so, try &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=&amp;lt;your_index&amp;gt; field=URL1 OR field=URL2 OR field=URL3
| stats count(eval(field="URL1")) AS URL1  count(eval(field="URL2")) AS URL2  count(eval(field="URL3")) AS URL3
| transpose column_name="List of URL" 
| rename "row 1" as Status
| eval Status=case( Status == 0, "Failed",
 true(), "Passed")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Inspired from @woodcock answer below&lt;/P&gt;</description>
      <pubDate>Mon, 23 Apr 2018 09:08:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344284#M101987</guid>
      <dc:creator>damien_chillet</dc:creator>
      <dc:date>2018-04-23T09:08:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a query for below scenarios?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344285#M101988</link>
      <description>&lt;P&gt;This didn't work. I added transpose the table and It shows only 4 rows at the most.&lt;/P&gt;

&lt;P&gt;Thanks for your response&lt;/P&gt;</description>
      <pubDate>Mon, 23 Apr 2018 19:19:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344285#M101988</guid>
      <dc:creator>lawzuns</dc:creator>
      <dc:date>2018-04-23T19:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a query for below scenarios?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344286#M101989</link>
      <description>&lt;P&gt;This is my current query&lt;/P&gt;

&lt;P&gt;|gentimes start=-1 | eval field2=split("URL1 OR URL2 OR URL3 OR URL4 OR URL5"," OR ") | eval field3="" | mvexpand field2 | eval field3 =[search index=xyz | rex "(?i)find url (?P[^ ]+)" | search URI="\"".field2."\"" | stats count as mycount | return $mycount] | table field2 , field3&lt;/P&gt;

&lt;P&gt;Note: I didn't added Pass/fail if condition, When i added it say failed always.&lt;/P&gt;

&lt;P&gt;Field2      Field3&lt;BR /&gt;
URL1        0&lt;BR /&gt;
URL2        0&lt;BR /&gt;
URL3        0&lt;BR /&gt;
URL4        0&lt;BR /&gt;
URL5        0&lt;/P&gt;</description>
      <pubDate>Mon, 23 Apr 2018 20:18:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344286#M101989</guid>
      <dc:creator>lawzuns</dc:creator>
      <dc:date>2018-04-23T20:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a query for below scenarios?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344287#M101990</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=xyz  | rex "(?i)find url (?P[^ ]+)"  | search [|gentimes start=-1 | eval URI=split("URL1 OR URL2 OR URL3 OR URL4 OR URL5"," OR ") | table URI| mvexpand URI] | stats count by URI
| append [|gentimes start=-1 | eval URI=split("URL1 OR URL2 OR URL3 OR URL4 OR URL5"," OR ") | table URI| mvexpand URI | eval count=0]
| stats max(count) as count by URI
| eval Status=if(count=0,"Failed","Passed")
| table URI Status
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Apr 2018 20:33:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344287#M101990</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-04-23T20:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a query for below scenarios?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344288#M101991</link>
      <description>&lt;P&gt;Awesome, This worked...&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 03:24:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-query-for-below-scenarios/m-p/344288#M101991</guid>
      <dc:creator>lawzuns</dc:creator>
      <dc:date>2018-04-24T03:24:47Z</dc:date>
    </item>
  </channel>
</rss>

