<?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: Creating a table from a single event with multivalue field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-from-a-single-event-with-multivalue-field/m-p/300223#M90393</link>
    <description>&lt;P&gt;If you are trying to get a horizontal table of all mountpoints for each host, then this will calculate them.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; your base search which includes hostname and multivalued field Mountpoint 
 | table hostname Mountpoint
 | mvexpand Mountpoint 
 | rex field=Mountpoint "(?&amp;lt;Mountpoint&amp;gt;[^\=]+)\=(?&amp;lt;used&amp;gt;\d+)" 

 | rename COMMENT as "Deal with things that wouldn't be valid variable names"
 | replace "\\" WITH "XX_" IN Mountpoint
 | eval {Mountpoint} = used
 | fields - Mountpoint used
 | stats values(*) as * by hostname
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;At this point, the values are splayed out horizontally, but I'm not sure how useful that will be to look at.  Using chart with useother=f will give you a pretty wide thing to look at.   &lt;/P&gt;

&lt;P&gt;Unless you have a reason to want to compare the mountpoints across hosts, you might be better off going this way...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; your base search which includes hostname and multivalued field Mountpoint 
 | table hostname Mountpoint
 | mvexpand Mountpoint 
 | rex field=Mountpoint "(?&amp;lt;Mountpoint&amp;gt;[^\=]+)\=(?&amp;lt;used&amp;gt;\d+)" 
 | sort 0 hostname Mountpoint
 | stats list(Mountpoint) as Mountpoint  list(used) as used by hostname
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 25 Aug 2017 00:48:33 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-08-25T00:48:33Z</dc:date>
    <item>
      <title>Creating a table from a single event with multivalue field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-from-a-single-event-with-multivalue-field/m-p/300219#M90389</link>
      <description>&lt;P&gt;I have an event that has disk information like: there are hosts that have more mountpoints or less mountpoints. So I need to automate this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;     /=1828716544   
     /_crit=4392484864  
     /_max=4881121280   
     /_warn=3904897024  
     /boot=106954752    
     /boot_crit=435159040   
     /boot_max=484442112    
     /boot_warn=386924544   
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now =Ii'm trying to get a table like:&lt;BR /&gt;
Mountpoint | used | crit ....&lt;BR /&gt;
/  | 1828716544 | 4392484864 ...&lt;/P&gt;

&lt;P&gt;Update:&lt;/P&gt;

&lt;P&gt;Because there were misunderstandings, here a little bit more details:&lt;/P&gt;

&lt;P&gt;The event can no be split because there are much more details in it that i use. The event contains only information for a single host. In the example above, there are only a few "mountpoints" in this example i have the fields /, /_crit, /_max, /_warn what are automatically extracted from Splunk.(There can be a lot more of the fields for example /var/log or /opt/ and so on So it need to be dynamic).&lt;/P&gt;

&lt;P&gt;Now i want to calculate per "mounpoint" (like, / and /boot in the example) the usage, max...)&lt;/P&gt;

&lt;P&gt;I was thinking it was helpful to create a MV with regex that i have all paths in a field (Path has the values / and /boot).&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:30:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-from-a-single-event-with-multivalue-field/m-p/300219#M90389</guid>
      <dc:creator>ColinCH</dc:creator>
      <dc:date>2020-09-29T15:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table from a single event with multivalue field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-from-a-single-event-with-multivalue-field/m-p/300220#M90390</link>
      <description>&lt;P&gt;Are the values consistent in the multivalue field?  If so, you could use mvindex to create a field for each.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR BASE SEARCH | | eval field1=mvindex(bytes,0) | eval field2=mvindex(bytes,1)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Aug 2017 14:32:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-from-a-single-event-with-multivalue-field/m-p/300220#M90390</guid>
      <dc:creator>kmorris_splunk</dc:creator>
      <dc:date>2017-08-24T14:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table from a single event with multivalue field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-from-a-single-event-with-multivalue-field/m-p/300221#M90391</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search which includes multivalued field Mountpoint 
| mvexpand Mountpoint 
| rex field=Mountpoint "(?&amp;lt;Mountpoint&amp;gt;[^\=]+)\=(?&amp;lt;used&amp;gt;\d+)" 
| table Mountpoint used ..anyother field you need
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Aug 2017 16:30:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-from-a-single-event-with-multivalue-field/m-p/300221#M90391</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-08-24T16:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table from a single event with multivalue field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-from-a-single-event-with-multivalue-field/m-p/300222#M90392</link>
      <description>&lt;P&gt;@ColinCH - I don't recognize why _crit would roll up, or what the rest of your desired chart might look like.&lt;/P&gt;

&lt;P&gt;@somesoni2's answer will work if you are willing to take each individual mountpount as listed.  &lt;/P&gt;

&lt;P&gt;If you want to roll up the mountpoints, like if everything under / needs to be tabled somehow as belonging to /, and everything under /foo/bar needs to be rolled up to /foo, then you should give us a clear picture of what the specs might be, with example data and the layout, more than a single line.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Aug 2017 00:33:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-from-a-single-event-with-multivalue-field/m-p/300222#M90392</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-08-25T00:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table from a single event with multivalue field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-from-a-single-event-with-multivalue-field/m-p/300223#M90393</link>
      <description>&lt;P&gt;If you are trying to get a horizontal table of all mountpoints for each host, then this will calculate them.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; your base search which includes hostname and multivalued field Mountpoint 
 | table hostname Mountpoint
 | mvexpand Mountpoint 
 | rex field=Mountpoint "(?&amp;lt;Mountpoint&amp;gt;[^\=]+)\=(?&amp;lt;used&amp;gt;\d+)" 

 | rename COMMENT as "Deal with things that wouldn't be valid variable names"
 | replace "\\" WITH "XX_" IN Mountpoint
 | eval {Mountpoint} = used
 | fields - Mountpoint used
 | stats values(*) as * by hostname
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;At this point, the values are splayed out horizontally, but I'm not sure how useful that will be to look at.  Using chart with useother=f will give you a pretty wide thing to look at.   &lt;/P&gt;

&lt;P&gt;Unless you have a reason to want to compare the mountpoints across hosts, you might be better off going this way...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; your base search which includes hostname and multivalued field Mountpoint 
 | table hostname Mountpoint
 | mvexpand Mountpoint 
 | rex field=Mountpoint "(?&amp;lt;Mountpoint&amp;gt;[^\=]+)\=(?&amp;lt;used&amp;gt;\d+)" 
 | sort 0 hostname Mountpoint
 | stats list(Mountpoint) as Mountpoint  list(used) as used by hostname
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Aug 2017 00:48:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-from-a-single-event-with-multivalue-field/m-p/300223#M90393</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-08-25T00:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table from a single event with multivalue field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-from-a-single-event-with-multivalue-field/m-p/300224#M90394</link>
      <description>&lt;P&gt;hi, thanks for your answer. I don't think that works. I update the question, that the question is more understandable.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Aug 2017 06:43:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-from-a-single-event-with-multivalue-field/m-p/300224#M90394</guid>
      <dc:creator>ColinCH</dc:creator>
      <dc:date>2017-08-25T06:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table from a single event with multivalue field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-from-a-single-event-with-multivalue-field/m-p/300225#M90395</link>
      <description>&lt;P&gt;Thanks, but that is not what i want. I've updates my initial question. So there are much more detail now.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Aug 2017 08:21:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-from-a-single-event-with-multivalue-field/m-p/300225#M90395</guid>
      <dc:creator>ColinCH</dc:creator>
      <dc:date>2017-08-25T08:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table from a single event with multivalue field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-from-a-single-event-with-multivalue-field/m-p/300226#M90396</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;index=* sourcetype=mysourcetype check_command=disk hostname=myhostname
| dedup hostname 
| rex mode=sed "s/(\"\_(\/|\/[a-zA-Z\/]+))\"/\1_used\"/g"
| rex max_match=0 "(?&amp;lt;bbb&amp;gt;\"\_(\/|\/[a-zA-Z\/]+)\_\w+\"\:\d+\.\d+\,)" 
| table bbb | eval aaa=mvsort(bbb)
| rex max_match=0 field=aaa "\_(?&amp;lt;path&amp;gt;(\/|\/[a-zA-Z\/]+)\_used)\"\:(?&amp;lt;used&amp;gt;\d+)"
| rex max_match=0 field=aaa "_crit\":(?&amp;lt;crit&amp;gt;\d+)" 
| rex max_match=0 field=aaa "_max\":(?&amp;lt;max&amp;gt;\d+)"
| rex max_match=0 field=aaa "_warn\":(?&amp;lt;warn&amp;gt;\d+)" 
| eval zip=mvzip(path,used,"##") 
| eval zip=mvzip(zip,crit,"##")
| eval zip=mvzip(zip,max,"##")
| eval zip=mvzip(zip,warn,"##")
| mvexpand zip 
|rex max_match=0 field=zip "(?&amp;lt;path&amp;gt;.*)##(?&amp;lt;used&amp;gt;.*)##(?&amp;lt;crit&amp;gt;.*)##(?&amp;lt;max&amp;gt;.*)##(?&amp;lt;warn&amp;gt;.*)" 
| fields - zip 
| eval used=used/1024/1024
| eval crit=crit/1024/1024 
| eval max=max/1024/1024 
| eval warn=warn/1024/1024
| eval free=max-used
| eval percent=(used/max*100)
| eval percent=round(percent,0)
| table path free used  max percent
| rex mode=sed field=path "s/_used//" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;here is my result, the main event was JSON and the mountpoint were not sorted, so i need to modify first with sed the fields before i can sort i with mvsort correctly. Then i created some more MV-Fields with rex and create an "array" with mvzip. &lt;/P&gt;

&lt;P&gt;For me, this is a good solution. I can process several fields per event in this way. it performs very well for me.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 11:04:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-from-a-single-event-with-multivalue-field/m-p/300226#M90396</guid>
      <dc:creator>ColinCH</dc:creator>
      <dc:date>2017-08-29T11:04:43Z</dc:date>
    </item>
  </channel>
</rss>

