<?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: Counting Occurrences Based Off Multiple Fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Counting-Occurrences-Based-Off-Multiple-Fields/m-p/95377#M24617</link>
    <description>&lt;P&gt;Hi Iguinn,&lt;/P&gt;

&lt;P&gt;Thanks for the help, I do need to compare 3 fields at once. I think the best way would be to do a count by the values in a mvfield I can create. I'm a bit confused about your code above because I thought coalesce just takes a number of fields and returns the first one that is not null, not necessarily combining them? &lt;/P&gt;

&lt;P&gt;Would my code below count all logs that match fields a, b, and c? Also, do you know a better way of making the combinedfield?&lt;/P&gt;

&lt;P&gt;| eval combinedfield = a.b.c&lt;BR /&gt;
| stats count(combinedfield)&lt;/P&gt;

&lt;P&gt;Thanks again for the help.&lt;/P&gt;</description>
    <pubDate>Tue, 16 Jul 2013 13:03:28 GMT</pubDate>
    <dc:creator>mhenrick</dc:creator>
    <dc:date>2013-07-16T13:03:28Z</dc:date>
    <item>
      <title>Counting Occurrences Based Off Multiple Fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-Occurrences-Based-Off-Multiple-Fields/m-p/95375#M24615</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I'm currently trying to test my field structure for dedup, but aren't sure of what best practices are for doing so/how to code them all.&lt;/P&gt;

&lt;P&gt;As of now, since I'm trying to delete a duplication error in my log system, I'm trying to count the amount of response where three fields are equal across the logs (not within the logs). If the count is above 2, it means that with those 3 fields of some set values I must be counting not only the original and the copy, but also some other log.&lt;/P&gt;

&lt;P&gt;Do you know how I could potentially code this efficiently? Will I have to merge the 3 fields into one and then compare them with a count, or can I keep them separate?&lt;BR /&gt;
Also, do any of you have any other ideas for how I could check dedup? I'm open to any and all suggestions.&lt;/P&gt;

&lt;P&gt;Thanks so much for your help!&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2013 19:04:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-Occurrences-Based-Off-Multiple-Fields/m-p/95375#M24615</guid>
      <dc:creator>mhenrick</dc:creator>
      <dc:date>2013-07-15T19:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: Counting Occurrences Based Off Multiple Fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-Occurrences-Based-Off-Multiple-Fields/m-p/95376#M24616</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere-across-all-sources
| eval combinedField = null()
| eval combinedField = coalesce(possibleFieldName1,possibleFieldName2,possibleFieldName3)
| stats count(combinedField) by source
| stats count values(source)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will give you what you want for one field, I think. First, it creates a single field called &lt;CODE&gt;combinedField&lt;/CODE&gt;, based on all the possible names that the field could have across the sources (&lt;CODE&gt;possibleFieldName1&lt;/CODE&gt;, &lt;CODE&gt;possibleFieldName2&lt;/CODE&gt;, etc.)&lt;BR /&gt;
Then it counts the number of times that the field appears across the sources, and finally reduces that to the number of sources where the field appears. It displays the count of sources along with a list of the source names.&lt;/P&gt;

&lt;P&gt;This works for one field. However, I can't see how you would do this for multiple fields simultaneously, especially if the field names can vary across sources. But perhaps I did not clearly understand the question...&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2013 19:38:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-Occurrences-Based-Off-Multiple-Fields/m-p/95376#M24616</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-07-15T19:38:23Z</dc:date>
    </item>
    <item>
      <title>Re: Counting Occurrences Based Off Multiple Fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-Occurrences-Based-Off-Multiple-Fields/m-p/95377#M24617</link>
      <description>&lt;P&gt;Hi Iguinn,&lt;/P&gt;

&lt;P&gt;Thanks for the help, I do need to compare 3 fields at once. I think the best way would be to do a count by the values in a mvfield I can create. I'm a bit confused about your code above because I thought coalesce just takes a number of fields and returns the first one that is not null, not necessarily combining them? &lt;/P&gt;

&lt;P&gt;Would my code below count all logs that match fields a, b, and c? Also, do you know a better way of making the combinedfield?&lt;/P&gt;

&lt;P&gt;| eval combinedfield = a.b.c&lt;BR /&gt;
| stats count(combinedfield)&lt;/P&gt;

&lt;P&gt;Thanks again for the help.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2013 13:03:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-Occurrences-Based-Off-Multiple-Fields/m-p/95377#M24617</guid>
      <dc:creator>mhenrick</dc:creator>
      <dc:date>2013-07-16T13:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: Counting Occurrences Based Off Multiple Fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-Occurrences-Based-Off-Multiple-Fields/m-p/95378#M24618</link>
      <description>&lt;P&gt;Hi Iguinn,&lt;/P&gt;

&lt;P&gt;I actually think this may work alone.&lt;BR /&gt;
| stats count by a, b, c&lt;/P&gt;

&lt;P&gt;Also, if I wanted to keep other values, I think I'd do it this way:&lt;BR /&gt;
| stats values(d),count by a,b,c&lt;/P&gt;

&lt;P&gt;Will this work?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2013 13:18:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-Occurrences-Based-Off-Multiple-Fields/m-p/95378#M24618</guid>
      <dc:creator>mhenrick</dc:creator>
      <dc:date>2013-07-16T13:18:48Z</dc:date>
    </item>
  </channel>
</rss>

