<?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: Splunk filter search to show only multi-value fields in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-filter-search-to-show-only-multi-value-fields/m-p/406878#M72181</link>
    <description>&lt;P&gt;You need to realize that it maybe only a single event that has multivalue fields when all others do not.  In any case, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="puppies" | foreach * [ eval mvcount_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = mvcount(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) | eval mvcount_AnyTh1n6 = if(mvcount_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; &amp;gt; 0, "YES", mvcount_AnyTh1n6) ]
| where mvcount_AnyTh1n6 == "YES"
| evenstats max(mvcount_*) AS dropme_*
| foreach dropme_* [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = if(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; == 0, "YES", null()) ]
| foreach dropme_* [ fields - &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt; &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also, the &lt;CODE&gt;fieldsummary&lt;/CODE&gt; command may be helpful:&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Fieldsummary"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Fieldsummary&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Jul 2019 20:44:33 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-07-26T20:44:33Z</dc:date>
    <item>
      <title>Splunk filter search to show only multi-value fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-filter-search-to-show-only-multi-value-fields/m-p/406874#M72177</link>
      <description>&lt;P&gt;I'm working on a splunk search head that was set up my someone else at work and I'm not very familiar with the dataset we're using splunk to analyze. I can see from the search results that some fields have multiple values, but I'm not sure how many fields are multi-value. I'd like to construct a query to only show the multi-value fields in the results, or better yet, to get a list of all of the multi-value fields in my dataset. &lt;/P&gt;

&lt;P&gt;I'm familiar with the &lt;CODE&gt;fields some_field&lt;/CODE&gt; command that filters the results by a particular field. I think I could use something similar to filter the results to show only multi-value fields.  I would need something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="puppies" | fields=[only multi-value fields]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is this possible in splunk?&lt;BR /&gt;
&lt;EM&gt;Note:&lt;/EM&gt; I have an inkling that there might be a button or something in the splunk results gui that could show me only multi-value fields. If that exists, please let me know. Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 16:28:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-filter-search-to-show-only-multi-value-fields/m-p/406874#M72177</guid>
      <dc:creator>brinley</dc:creator>
      <dc:date>2019-07-25T16:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk filter search to show only multi-value fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-filter-search-to-show-only-multi-value-fields/m-p/406875#M72178</link>
      <description>&lt;P&gt;Here is one way to get an overview of all the fields:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval multival_1=mvappend("one","two","three") 
| eval multival_2=mvappend("red","green") 
| eval singleval_1="winter,spring,summer" 
| eval singleval_2="fall"
| fieldsummary
| eval fieldType=if(like(values,"%},{%"),"Multi","Single")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then if you want to see only the multivalue, you can add this line to the bottom:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where fieldType="Multi"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And then the field named "field" will contain all your mv fields.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 17:50:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-filter-search-to-show-only-multi-value-fields/m-p/406875#M72178</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2019-07-25T17:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk filter search to show only multi-value fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-filter-search-to-show-only-multi-value-fields/m-p/406876#M72179</link>
      <description>&lt;P&gt;@jpolvino Thanks for the help. This query is returning results that say all my fields are multi-valued, which is not correct. Unless I'm wrong about the meaning of a multi-valued field: is a field with a value equal to a single string of unique words delimited by newlines considered a multi-valued field? Because it sure behaves like a single valued field (especially given that splunk returns multi-valued field values as objects, and I'm consistently getting strings from splunk). &lt;/P&gt;

&lt;P&gt;Sorry if I'm not making much sense. If you can't answer my question above, can you tell me what &lt;CODE&gt;"%},{%"&lt;/CODE&gt; means? I'm guessing a pattern that matches on two unique values separated by a comma? How does that pattern determine if a field is multi-valued?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 21:17:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-filter-search-to-show-only-multi-value-fields/m-p/406876#M72179</guid>
      <dc:creator>brinley</dc:creator>
      <dc:date>2019-07-25T21:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk filter search to show only multi-value fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-filter-search-to-show-only-multi-value-fields/m-p/406877#M72180</link>
      <description>&lt;P&gt;Pass the field in question as a parameter to the mvcount function. If it returns 1, it is not multivalue. If it returns &amp;gt;1 then it is multivalue.&lt;/P&gt;

&lt;P&gt;The pattern you call out above detects a multivalue field. If you look at the output of the top code snippet I provided, you'll see a "value" field at the right, looking like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;values
[{"value":"one","count":1},{"value":"three","count":1},{"value":"two","count":1}]
[{"value":"green","count":1},{"value":"red","count":1}]
[{"value":"winter,spring,summer","count":1}]
[{"value":"fall","count":1}]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The top 2 rows belong to the multivalue fields, and have the },{ pattern.&lt;/P&gt;

&lt;P&gt;If this doesn't work for your case, then please post sample fields: ones you want to collect, and ones you want to reject, and I'm sure the community will help get you what you need.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2019 12:05:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-filter-search-to-show-only-multi-value-fields/m-p/406877#M72180</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2019-07-26T12:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk filter search to show only multi-value fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-filter-search-to-show-only-multi-value-fields/m-p/406878#M72181</link>
      <description>&lt;P&gt;You need to realize that it maybe only a single event that has multivalue fields when all others do not.  In any case, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="puppies" | foreach * [ eval mvcount_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = mvcount(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) | eval mvcount_AnyTh1n6 = if(mvcount_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; &amp;gt; 0, "YES", mvcount_AnyTh1n6) ]
| where mvcount_AnyTh1n6 == "YES"
| evenstats max(mvcount_*) AS dropme_*
| foreach dropme_* [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = if(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; == 0, "YES", null()) ]
| foreach dropme_* [ fields - &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt; &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also, the &lt;CODE&gt;fieldsummary&lt;/CODE&gt; command may be helpful:&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Fieldsummary"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Fieldsummary&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2019 20:44:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-filter-search-to-show-only-multi-value-fields/m-p/406878#M72181</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-26T20:44:33Z</dc:date>
    </item>
  </channel>
</rss>

