<?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: How to create a table in which mandatory and optional fields are correctly aligned in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-in-which-mandatory-and-optional-fields-are/m-p/405769#M117310</link>
    <description>&lt;P&gt;Hmm!  This is not how it should work, so there must be another issue at hand.&lt;/P&gt;

&lt;P&gt;Just to confirm behavior, I tested by importing the data you provided into an index, telling Splunk nothing other than to break every line and to timestamp it at index time.  Splunk extracted the values, and &lt;CODE&gt;...| table *&lt;/CODE&gt; worked fine.  A tweak, as jason.prondak mentions below, is to &lt;CODE&gt;... | table s* f*&lt;/CODE&gt; so you don't get raw and stuff.  But still, I have it working absolutely fine.  Gaps appear in the responses as expected when there is an event with no value for a particular field.  &lt;/P&gt;

&lt;P&gt;So some follow on questions...&lt;/P&gt;

&lt;P&gt;How are you using regex to extract these fields?  Is that your &lt;EM&gt;actual&lt;/EM&gt; data that has a problem or is it sample?  What sourcetype is used for it?   &lt;/P&gt;</description>
    <pubDate>Fri, 22 Feb 2019 20:47:41 GMT</pubDate>
    <dc:creator>Richfez</dc:creator>
    <dc:date>2019-02-22T20:47:41Z</dc:date>
    <item>
      <title>How to create a table in which mandatory and optional fields are correctly aligned</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-in-which-mandatory-and-optional-fields-are/m-p/405764#M117305</link>
      <description>&lt;P&gt;Hello, I have a problem extracting data from a log with format not fixed.&lt;/P&gt;

&lt;P&gt;I explain:&lt;BR /&gt;
each row of my log contains a mandatory tag (always present) followed by some other optional tags (so they may be present or not).&lt;BR /&gt;
For example:  &lt;/P&gt;

&lt;P&gt;father="A"; son1="A1"; son2="A2"; son3="A3"&lt;BR /&gt;
father="B"; son1="B1"; son3="B3"&lt;BR /&gt;
father="C"; son2="C2"; son3="C3"&lt;/P&gt;

&lt;P&gt;I need a query returning a table like this, where all values are correctly aligned under the respective tag:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;father sun1 sun2 sun3
 A     A1   A2   A3
 B     B1   -    B3
 C     -    C2   C3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OK, I must use "rex" statement to identify "father", "sun1", "sun2", "sun3" values.&lt;BR /&gt;
But when, after this, I use "table" statement to see the results, I obtain a table where the alignment of the values is lost (for example, value C3 is under the wrong column "sun2" instead the correct column "sun3"):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;father sun1 sun2 sun3
 A     A1   A2   A3
 B     B1   B3
 C     C2   C3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can someone help me?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 13:48:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-in-which-mandatory-and-optional-fields-are/m-p/405764#M117305</guid>
      <dc:creator>marcoemme41</dc:creator>
      <dc:date>2019-02-22T13:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table in which mandatory and optional fields are correctly aligned</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-in-which-mandatory-and-optional-fields-are/m-p/405765#M117306</link>
      <description>&lt;P&gt;Add this to the end of your base search* :&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;... | table *&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;*base search, like &lt;CODE&gt;sourcetype=foo index=bar&lt;/CODE&gt;  so the whole thing is like &lt;CODE&gt;sourcetype=foo index=bar | table *&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;You should look into Splunk Fundamentals 1 class, I think it covers this and is free.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 14:00:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-in-which-mandatory-and-optional-fields-are/m-p/405765#M117306</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2019-02-22T14:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table in which mandatory and optional fields are correctly aligned</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-in-which-mandatory-and-optional-fields-are/m-p/405766#M117307</link>
      <description>&lt;P&gt;Thank you rich7177, &lt;/P&gt;

&lt;P&gt;unfortunately "table" statement doesn't work correctly in this case .&lt;/P&gt;

&lt;P&gt;The absence of some tags causes a table with non-aligned fields, like the example I've posted before.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 17:12:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-in-which-mandatory-and-optional-fields-are/m-p/405766#M117307</guid>
      <dc:creator>marcoemme41</dc:creator>
      <dc:date>2019-02-22T17:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table in which mandatory and optional fields are correctly aligned</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-in-which-mandatory-and-optional-fields-are/m-p/405767#M117308</link>
      <description>&lt;P&gt;Does this help? &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval raw="father=A;son1=A1;son2=A2;son3=A3 father=B;son1=B1;son3=B3 father=C;son2=C2;son3=C3" 
| makemv raw
| mvexpand raw
| rename raw AS _raw 
| kv 
| fillnull value="-" 
| fields - _* 
| table f* s*
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Feb 2019 18:02:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-in-which-mandatory-and-optional-fields-are/m-p/405767#M117308</guid>
      <dc:creator>jason_prondak</dc:creator>
      <dc:date>2019-02-22T18:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table in which mandatory and optional fields are correctly aligned</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-in-which-mandatory-and-optional-fields-are/m-p/405768#M117309</link>
      <description>&lt;P&gt;@marcoemme41 Please share the rex command you are using to get father, son1,son2 and son3 values.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 20:17:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-in-which-mandatory-and-optional-fields-are/m-p/405768#M117309</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-02-22T20:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table in which mandatory and optional fields are correctly aligned</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-in-which-mandatory-and-optional-fields-are/m-p/405769#M117310</link>
      <description>&lt;P&gt;Hmm!  This is not how it should work, so there must be another issue at hand.&lt;/P&gt;

&lt;P&gt;Just to confirm behavior, I tested by importing the data you provided into an index, telling Splunk nothing other than to break every line and to timestamp it at index time.  Splunk extracted the values, and &lt;CODE&gt;...| table *&lt;/CODE&gt; worked fine.  A tweak, as jason.prondak mentions below, is to &lt;CODE&gt;... | table s* f*&lt;/CODE&gt; so you don't get raw and stuff.  But still, I have it working absolutely fine.  Gaps appear in the responses as expected when there is an event with no value for a particular field.  &lt;/P&gt;

&lt;P&gt;So some follow on questions...&lt;/P&gt;

&lt;P&gt;How are you using regex to extract these fields?  Is that your &lt;EM&gt;actual&lt;/EM&gt; data that has a problem or is it sample?  What sourcetype is used for it?   &lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 20:47:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-in-which-mandatory-and-optional-fields-are/m-p/405769#M117310</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2019-02-22T20:47:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table in which mandatory and optional fields are correctly aligned</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-in-which-mandatory-and-optional-fields-are/m-p/405770#M117311</link>
      <description>&lt;P&gt;It works!  Thanks jason and rich for your precious help. &lt;BR /&gt;
Now I have to apply this solution to my real problem. I will keep you informed &lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 09:57:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-in-which-mandatory-and-optional-fields-are/m-p/405770#M117311</guid>
      <dc:creator>marcoemme41</dc:creator>
      <dc:date>2019-02-25T09:57:19Z</dc:date>
    </item>
  </channel>
</rss>

