<?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 compare a field name with different field values? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294207#M164908</link>
    <description>&lt;P&gt;Thank you for your answer.&lt;/P&gt;

&lt;P&gt;I did some changes to get minimum solution.  Two changes I did. &lt;BR /&gt;
1. Distinct count w.r.t clientip &lt;BR /&gt;
2. Which is done in the last eval search, replaced with count instead of sum_status then it works fine. &lt;/P&gt;

&lt;P&gt;index=_internal clientip=* status=* &lt;BR /&gt;
 | stats dc(clientip) by clientip status&lt;BR /&gt;
 | eval dc_200=case(status="200", 1, 1=1, 0), dc_404=case(status="404", 1, 1=1, 0) &lt;BR /&gt;
 | stats dc(eval(dc_200 + dc_404)) AS sum_status count by clientip &lt;BR /&gt;
 | eval frequent=case(count="2", "common", count="1", "uncommon", 1=1, "unknown")&lt;/P&gt;

&lt;P&gt;But i need to represent uncommon ip_addresses with status value.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 17:00:03 GMT</pubDate>
    <dc:creator>chandanaberi</dc:creator>
    <dc:date>2020-09-29T17:00:03Z</dc:date>
    <item>
      <title>How to compare a field name with different field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294198#M164899</link>
      <description>&lt;P&gt;I am new to splunk,&lt;/P&gt;

&lt;P&gt;I have two field names: status and ip_address, &lt;BR /&gt;
status has different field values, status=200, 300, 400, 405. I can select any status value to list out ip_addresses by using below search&lt;BR /&gt;
&lt;STRONG&gt;index=tutorial_data status = 200 | stats dc by ip_address&lt;/STRONG&gt;&lt;BR /&gt;
some ip_addresses are common in different status. I want to pull out all common ip_addresses list from status=200 and status=400.&lt;BR /&gt;
How can i do that in a single search? &lt;/P&gt;

&lt;P&gt;Appreciate your answers.  &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:52:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294198#M164899</guid>
      <dc:creator>chandanaberi</dc:creator>
      <dc:date>2020-09-29T16:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare a field name with different field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294199#M164900</link>
      <description>&lt;P&gt;a direct approach might be &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=tutorial_data status=200  
| stats count by status ip_address 
| sort 10 count 
| append [search index=tutorial_data status=400  | stats count by status ip_address | sort 10 count]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Nov 2017 23:50:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294199#M164900</guid>
      <dc:creator>MonkeyK</dc:creator>
      <dc:date>2017-11-22T23:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare a field name with different field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294200#M164901</link>
      <description>&lt;P&gt;Hi @chandanaberi &lt;/P&gt;

&lt;P&gt;Can you please try this search?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH | makemv status delim="," | where status="200"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sample Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval status="200,300,400,405",ip_address="10.0.0.1" 
| append 
    [| makeresults 
    | eval status="300,400,405",ip_address="10.0.0.2" ] 
| makemv status delim="," | search status="200" status="400"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can use search OR where for filter.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search status="200" status="400"
| where status="200" AND status="400"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will give &lt;CODE&gt;ip_address&lt;/CODE&gt; which contain &lt;CODE&gt;200&lt;/CODE&gt; status.&lt;/P&gt;

&lt;P&gt;If you want &lt;CODE&gt;ip_address&lt;/CODE&gt; only with &lt;CODE&gt;200&lt;/CODE&gt; status then use below search,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH | makemv status delim="," | stats count by status, ip_address | search status="200" status="400"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sample Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval status="200,300,400,405",ip_address="10.0.0.1" 
| append 
    [| makeresults 
    | eval status="300,400,405",ip_address="10.0.0.2" ] 
| makemv status delim="," | stats count by status, ip_address | search status="200" status="400"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I hope this will help you.&lt;/P&gt;

&lt;P&gt;Happy Splunking&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2017 08:09:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294200#M164901</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2017-11-23T08:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare a field name with different field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294201#M164902</link>
      <description>&lt;P&gt;This command is works fine, but it's listing only 50,000 statistics of append search. I want to list all common ip_addresses and also want to list uncommon ip_addresses w.r.t status=200 and status=400 &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:01:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294201#M164902</guid>
      <dc:creator>chandanaberi</dc:creator>
      <dc:date>2020-09-29T17:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare a field name with different field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294202#M164903</link>
      <description>&lt;P&gt;Hi @chandanaberi, &lt;BR /&gt;
Have you tried?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 18:22:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294202#M164903</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2017-11-27T18:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare a field name with different field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294203#M164904</link>
      <description>&lt;P&gt;Yeah, I tried the above searches, Those are not what i am looking exactly. I want to list all common/uncommon ip_addresses in a single search Because my data has 100+ ip_addresses.  &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:01:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294203#M164904</guid>
      <dc:creator>chandanaberi</dc:creator>
      <dc:date>2020-09-29T17:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare a field name with different field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294204#M164905</link>
      <description>&lt;P&gt;Hi chandanaberi,&lt;/P&gt;

&lt;P&gt;as you said correctly, there is no need for any subsearch here. A single &lt;CODE&gt;stats&lt;/CODE&gt; search with additional &lt;CODE&gt;eval&lt;/CODE&gt; will do it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal clientip=* status=* 
| eval dc_200=case(status="200", 1, 1=1, 0), dc_404=case(status="404", 1, 1=1, 0) 
| stats dc(eval(dc_200 + dc_404)) AS sum_status count by clientip 
| eval frequent=case(sum_status="2", "common", sum_status="1", "uncommon", 1=1, "unknown")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is a run everywhere search and you need to adapt it to your needs &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps to get you started ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 19:04:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294204#M164905</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2017-11-27T19:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare a field name with different field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294205#M164906</link>
      <description>&lt;P&gt;Sorry, I had misunderstood how you were using common and uncommon.  If common mean has both and uncommon means has only 1, you can do it like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=tutorial_data (status=200 OR status=400) | stats dc(status) as statusCount by ip_address| eval common=case(statusCount=2,"Y", statusCount=1,"N", 1=1, "error") | table ip_address common
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;we could add count to the stats command and sort on that if you were interested in the most/least frequent IP addresses&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2017 02:26:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294205#M164906</guid>
      <dc:creator>MonkeyK</dc:creator>
      <dc:date>2017-11-29T02:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare a field name with different field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294206#M164907</link>
      <description>&lt;P&gt;Thank you so much for your answer. &lt;/P&gt;

&lt;P&gt;This one is listing common and uncommon ip_addresses. Though, It's not full solution, i wanted to list uncommon values with status values. &lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 19:13:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294206#M164907</guid>
      <dc:creator>chandanaberi</dc:creator>
      <dc:date>2017-12-01T19:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare a field name with different field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294207#M164908</link>
      <description>&lt;P&gt;Thank you for your answer.&lt;/P&gt;

&lt;P&gt;I did some changes to get minimum solution.  Two changes I did. &lt;BR /&gt;
1. Distinct count w.r.t clientip &lt;BR /&gt;
2. Which is done in the last eval search, replaced with count instead of sum_status then it works fine. &lt;/P&gt;

&lt;P&gt;index=_internal clientip=* status=* &lt;BR /&gt;
 | stats dc(clientip) by clientip status&lt;BR /&gt;
 | eval dc_200=case(status="200", 1, 1=1, 0), dc_404=case(status="404", 1, 1=1, 0) &lt;BR /&gt;
 | stats dc(eval(dc_200 + dc_404)) AS sum_status count by clientip &lt;BR /&gt;
 | eval frequent=case(count="2", "common", count="1", "uncommon", 1=1, "unknown")&lt;/P&gt;

&lt;P&gt;But i need to represent uncommon ip_addresses with status value.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:00:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294207#M164908</guid>
      <dc:creator>chandanaberi</dc:creator>
      <dc:date>2020-09-29T17:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare a field name with different field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294208#M164909</link>
      <description>&lt;P&gt;OK, simple correction:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=tutorial_data (status=200 OR status=400) 
| stats dc(status) as statusCount max(status) as status by ip_address
| eval common=case(statusCount=2,"Y", statusCount=1,"N", 1=1, "error"), status=case(statusCount=1,status,1=1,"") 
| table ip_address common status
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Dec 2017 19:59:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294208#M164909</guid>
      <dc:creator>MonkeyK</dc:creator>
      <dc:date>2017-12-01T19:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare a field name with different field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294209#M164910</link>
      <description>&lt;P&gt;Wow, this is what i expected. &lt;BR /&gt;
But I have one more doubt, How can i know, which command I have to use for a particular situation? I am confused with the search commands. If you know any references to learn more about it, please suggest me. &lt;/P&gt;

&lt;P&gt;Thank you so much&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 20:08:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294209#M164910</guid>
      <dc:creator>chandanaberi</dc:creator>
      <dc:date>2017-12-01T20:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare a field name with different field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294210#M164911</link>
      <description>&lt;P&gt;Glad I could help.  In learning commands, we all start to accumulate patterns of solutions.&lt;/P&gt;

&lt;P&gt;The main patterns of searches that I use:&lt;BR /&gt;
When I want to transform data, or create new fields, I lean on eval.  Within that I learn the eval functions.&lt;BR /&gt;
When I want to summarize data, I lean on stats.  Within that I learn the stats functions&lt;BR /&gt;
When I want to search based on previous results, I use a subsearch or a lookup table.&lt;/P&gt;

&lt;P&gt;When the categories that I know how to use fail me, I come to answers.splunk.com and somebody usually tells me about a new command or explains new ways to think about the ones that I already know.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 20:27:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294210#M164911</guid>
      <dc:creator>MonkeyK</dc:creator>
      <dc:date>2017-12-01T20:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare a field name with different field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294211#M164912</link>
      <description>&lt;P&gt;I also summarize as you but some times I had to scratch my head to use particular commands. You just used values command to solve this problem. Anyways, thank you so much. &lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 20:33:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-a-field-name-with-different-field-values/m-p/294211#M164912</guid>
      <dc:creator>chandanaberi</dc:creator>
      <dc:date>2017-12-01T20:33:32Z</dc:date>
    </item>
  </channel>
</rss>

