<?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: Can I count multi-value fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-I-count-multi-value-fields/m-p/348192#M175223</link>
    <description>&lt;P&gt;This inputs your example data.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | makeresults 
  | eval mydata="090000,1,u,v 090001,1,w,x 090002,1,y,z 090003,2,u,v 090004,2,w,x 090005,3,u,v 090006,4,u,v 090007,4,w,x" 
  | makemv mydata | mvexpand mydata | makemv delim="," mydata 
  | eval time=mvindex(mydata,0),id=mvindex(mydata,1),eth_src=mvindex(mydata,2),eth_dst=mvindex(mydata,3)
  | table time id eth_src eth_dst
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This translates the data to the a&amp;gt;b format, strips the records to only the time, leg and id, then puts the legs together into a single multivalue field ("legs") by id.  Then it uses mvjoin to create the requested format, and finally, produce the count of each route, with sparkline.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval leg = eth_src."&amp;gt;".eth_dst
| table time id leg
| eventstats min(time) as mintime, list(leg) as legs by id
| eval route = "[".mvjoin(legs,",")."]"
| where time=mintime
| eval _time = time
| eventstats count as routecount by route
| eval route=route.":".routecount
| table _time route routecount
| chart count sparkline by route
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Resulting in &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;route         count   sparkline
[u&amp;gt;v,w&amp;gt;x,y&amp;gt;z]    1    \____
[u&amp;gt;v,w&amp;gt;x]        2    _/\_/
[u&amp;gt;v]            1    __/\_
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 09 Mar 2017 05:22:19 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-03-09T05:22:19Z</dc:date>
    <item>
      <title>Can I count multi-value fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-count-multi-value-fields/m-p/348189#M175220</link>
      <description>&lt;P&gt;My event(NOT table):&lt;/P&gt;

&lt;P&gt;_time,id,eth_src,eth_dst&lt;BR /&gt;
090000,1,u,v&lt;BR /&gt;
090001,1,w,x&lt;BR /&gt;
090002,1,y,z&lt;BR /&gt;
090003,2,u,v&lt;BR /&gt;
090004,2,w,x&lt;BR /&gt;
090005,3,u,v&lt;BR /&gt;
090006,4,u,v&lt;BR /&gt;
090007,4,w,x&lt;/P&gt;

&lt;P&gt;The table I want to create &lt;BR /&gt;
([~] means multi-value field.):&lt;/P&gt;

&lt;P&gt;route,count,sparkline(count)&lt;BR /&gt;
[u&amp;gt;v,w&amp;gt;x,y&amp;gt;z],1,sparkline&lt;BR /&gt;
[u&amp;gt;v,w&amp;gt;x],2,sparkline&lt;BR /&gt;
[u&amp;gt;v],1,sparkline&lt;/P&gt;

&lt;P&gt;How can I create the table?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:11:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-count-multi-value-fields/m-p/348189#M175220</guid>
      <dc:creator>i111040d</dc:creator>
      <dc:date>2020-09-29T13:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: Can I count multi-value fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-count-multi-value-fields/m-p/348190#M175221</link>
      <description>&lt;P&gt;Hi i111040d,&lt;BR /&gt;
I'm not sure about your need because I see in your example that you have the same values &lt;A href="https://community.splunk.com/that%20I%20imagine%20that%20seems%20route%20from%20u%20to%20v"&gt;u&amp;gt;v&lt;/A&gt; in all the results, every way, try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; your_search
| eval route=case(eth_src="u" AND eth_dst="v", "[u&amp;gt;v]",eth_src="w" AND eth_dst="x", "[w&amp;gt;x]",eth_src="y" AND eth_dst="z", "[y&amp;gt;z]",............)
| stats sparkline count by route
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Obviously, you have to build your eval by your needs.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 09:18:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-count-multi-value-fields/m-p/348190#M175221</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-03-08T09:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: Can I count multi-value fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-count-multi-value-fields/m-p/348191#M175222</link>
      <description>&lt;P&gt;Hi, cusello.&lt;BR /&gt;
Thanks for your answering.&lt;BR /&gt;
But sorry my bad.&lt;BR /&gt;
What I wanted is slightly different.&lt;BR /&gt;
So I rewrite clarity.&lt;/P&gt;

&lt;P&gt;Event:&lt;BR /&gt;
_time=090000 id=1 src=w dst=x&lt;BR /&gt;
_time=090001 id=1 src=y dst=z&lt;BR /&gt;
_time=090002 id=2 src=w dst=x&lt;BR /&gt;
_time=090003 id=3 src=w dst=x&lt;BR /&gt;
_time=090004 id=3 src=y dst=z&lt;/P&gt;

&lt;P&gt;First search:&lt;BR /&gt;
Index=*&lt;BR /&gt;
|eval route=src."&amp;gt;".dst&lt;BR /&gt;
|stats last(_time) as _time values(route) as route by id&lt;/P&gt;

&lt;P&gt;First result(table):&lt;BR /&gt;
_time,id,route&lt;BR /&gt;
090001,1,[w&amp;gt;x,y&amp;gt;z]&lt;BR /&gt;
090002,2,w&amp;gt;x&lt;BR /&gt;
090004,3,[w&amp;gt;x,y&amp;gt;z]&lt;/P&gt;

&lt;P&gt;Next search:&lt;BR /&gt;
|stats count sparkline by route&lt;/P&gt;

&lt;P&gt;Ideal result(table):&lt;BR /&gt;
route,count,sparkline&lt;BR /&gt;
[w&amp;gt;x,y&amp;gt;z],2,sparkline&lt;BR /&gt;
w&amp;gt;x,1,sparkline&lt;/P&gt;

&lt;P&gt;Actual result(table):&lt;BR /&gt;
route,count,sparkline(failed)&lt;BR /&gt;
w&amp;gt;x,3,sparkline(failed)&lt;BR /&gt;
y&amp;gt;z,2,sparkline(failed)&lt;/P&gt;

&lt;P&gt;How can I get the "Ideal result"?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 01:36:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-count-multi-value-fields/m-p/348191#M175222</guid>
      <dc:creator>i111040d</dc:creator>
      <dc:date>2017-03-09T01:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Can I count multi-value fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-count-multi-value-fields/m-p/348192#M175223</link>
      <description>&lt;P&gt;This inputs your example data.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | makeresults 
  | eval mydata="090000,1,u,v 090001,1,w,x 090002,1,y,z 090003,2,u,v 090004,2,w,x 090005,3,u,v 090006,4,u,v 090007,4,w,x" 
  | makemv mydata | mvexpand mydata | makemv delim="," mydata 
  | eval time=mvindex(mydata,0),id=mvindex(mydata,1),eth_src=mvindex(mydata,2),eth_dst=mvindex(mydata,3)
  | table time id eth_src eth_dst
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This translates the data to the a&amp;gt;b format, strips the records to only the time, leg and id, then puts the legs together into a single multivalue field ("legs") by id.  Then it uses mvjoin to create the requested format, and finally, produce the count of each route, with sparkline.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval leg = eth_src."&amp;gt;".eth_dst
| table time id leg
| eventstats min(time) as mintime, list(leg) as legs by id
| eval route = "[".mvjoin(legs,",")."]"
| where time=mintime
| eval _time = time
| eventstats count as routecount by route
| eval route=route.":".routecount
| table _time route routecount
| chart count sparkline by route
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Resulting in &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;route         count   sparkline
[u&amp;gt;v,w&amp;gt;x,y&amp;gt;z]    1    \____
[u&amp;gt;v,w&amp;gt;x]        2    _/\_/
[u&amp;gt;v]            1    __/\_
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Mar 2017 05:22:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-count-multi-value-fields/m-p/348192#M175223</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-09T05:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: Can I count multi-value fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-count-multi-value-fields/m-p/348193#M175224</link>
      <description>&lt;P&gt;Take a look at the updated code on my post.  I believe it is what you are looking for.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 15:16:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-count-multi-value-fields/m-p/348193#M175224</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-09T15:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: Can I count multi-value fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-count-multi-value-fields/m-p/348194#M175225</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Index=*
|eval route=src."&amp;gt;".dst
|stats last(_time) as _time values(route) as route by id delim=","
| nomv route
|stats count sparkline by route
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Mar 2017 15:21:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-count-multi-value-fields/m-p/348194#M175225</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-03-09T15:21:22Z</dc:date>
    </item>
  </channel>
</rss>

