<?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: Making a table from data with objects in an array in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Making-a-table-from-data-with-objects-in-an-array/m-p/41211#M9564</link>
    <description>&lt;P&gt;Could we see your search, or at least relevant parts of it? I'm curious to see how you used mvzip to achieve your results.&lt;/P&gt;</description>
    <pubDate>Wed, 21 Nov 2012 11:22:49 GMT</pubDate>
    <dc:creator>alacercogitatus</dc:creator>
    <dc:date>2012-11-21T11:22:49Z</dc:date>
    <item>
      <title>Making a table from data with objects in an array</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Making-a-table-from-data-with-objects-in-an-array/m-p/41210#M9563</link>
      <description>&lt;P&gt;I have data that looks like&lt;/P&gt;

&lt;P&gt;{&lt;BR /&gt;
  event: "request",&lt;BR /&gt;
  timers: [&lt;BR /&gt;
      {&lt;BR /&gt;
          category : "serverA",&lt;BR /&gt;
           duration : 3,&lt;BR /&gt;
          host : abc&lt;BR /&gt;
       },&lt;BR /&gt;
      {&lt;BR /&gt;
         category: "serverB",&lt;BR /&gt;
           duration: 4,&lt;BR /&gt;
        host: abc&lt;BR /&gt;
    },&lt;BR /&gt;
    {&lt;BR /&gt;
        category: "serverA",&lt;BR /&gt;
        duration: 6,&lt;BR /&gt;
       host: xyz&lt;BR /&gt;
    }&lt;BR /&gt;
   ]&lt;BR /&gt;
 }&lt;/P&gt;

&lt;P&gt;The timers array can vary in the number of objects it has. I want to go through all the data pulling out information from each object in the timers array, and make a table that looks something like:&lt;/P&gt;

&lt;P&gt;_time      category  duration  host&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;8:30      serverA   3               abc&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;8:30     serverB     4             abc&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;8:30    serverA   6            xyz&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;I would then ALSO like to be able to make a timechart of this by host, so .... | timechart avg(duration) by  host&lt;/P&gt;

&lt;P&gt;The problem I am having is getting it into the table above AND being able to make an efficient timechart. Right now, I am using mvzip and mvexpand in order to get it to the format of the table above. I have a feeling that this is the main reason why the  timechart currently takes forever to load. Is there any easy way to extract information from objects in an array and then put it in a table like above?&lt;/P&gt;

&lt;P&gt;Without using mvzip and mvexpand, and trying to just show a table with those fields causes a table like this for me:&lt;/P&gt;

&lt;P&gt;_time      category  duration  host&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;8:30      serverA   3    abc &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;         serverB     4    abc

         serverA   6   xyz 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;That is, objects in the same timers array payload seem to clump together into the same row.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2012 08:57:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Making-a-table-from-data-with-objects-in-an-array/m-p/41210#M9563</guid>
      <dc:creator>benobviate</dc:creator>
      <dc:date>2012-11-21T08:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: Making a table from data with objects in an array</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Making-a-table-from-data-with-objects-in-an-array/m-p/41211#M9564</link>
      <description>&lt;P&gt;Could we see your search, or at least relevant parts of it? I'm curious to see how you used mvzip to achieve your results.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2012 11:22:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Making-a-table-from-data-with-objects-in-an-array/m-p/41211#M9564</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2012-11-21T11:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: Making a table from data with objects in an array</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Making-a-table-from-data-with-objects-in-an-array/m-p/41212#M9565</link>
      <description>&lt;P&gt;You need field extractions or rex.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="your_source_type" | rex field=_raw "(?&amp;lt;category&amp;gt;(?&amp;lt;=category.:.")(.*)(?=",))" |rex field=_raw "(?&amp;lt;duration&amp;gt;(?&amp;lt;=duration.:.)(.*)(?=,))" | rex field=_raw "(?&amp;lt;hostname&amp;gt;(?&amp;lt;=host.:.)(.*))"| table _time,category,duration,hostname | rename hostname as host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If that doesnt work, try removing | rename hostname as host.&lt;/P&gt;

&lt;P&gt;If that doesnt work, then you gave the wrong data. I "corrected" your data as follows (spacing between colons).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
event: "request",
timers: [

  {

      category : "serverA",

       duration : 3,

      host : abc

   },

  {

     category : "serverB",

       duration : 4,

    host : abc

},

{

    category : "serverA",

    duration : 6,

   host : xyz

}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If this isn't how your data is formatted please let us know.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2012 16:53:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Making-a-table-from-data-with-objects-in-an-array/m-p/41212#M9565</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2012-11-21T16:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: Making a table from data with objects in an array</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Making-a-table-from-data-with-objects-in-an-array/m-p/41213#M9566</link>
      <description>&lt;P&gt;Thanks. That works. Is there an easy way when doing this to only make rows for when category is serverB ? I currently do something like yoursolution | search category="serverB" &lt;/P&gt;

&lt;P&gt;Just wondering if that was a way to do it while it was extracting with rex.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2012 22:15:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Making-a-table-from-data-with-objects-in-an-array/m-p/41213#M9566</guid>
      <dc:creator>benobviate</dc:creator>
      <dc:date>2012-11-21T22:15:49Z</dc:date>
    </item>
  </channel>
</rss>

