<?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: Transforming event data for table display in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-transform-event-data-for-table-display/m-p/613546#M213240</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;, thanks for the reply, unfortunately I am unable to make this method work on my actual data despite it working on the run-anywhere. I am not very familiar with rex, hence please pardon me as I have some questions on the code.&lt;/P&gt;&lt;P&gt;1. Do I need to define the data as per this line? What if I have many (&amp;gt;100) variables?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;\"Name1\" : \"A\", \"Name2\" : \"B\", \"Name3\" : \"C\", ... \"Name10\" : \"J\",
\"Var1\" : 10, \"Var2\" : 10, \"Var3\" : 25, ... \"Var10\" : 50"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. After the &lt;STRONG&gt;| &lt;FONT color="#0000FF"&gt;mvexpand&lt;/FONT&gt; zip&lt;/STRONG&gt; line, the search returns &lt;STRONG&gt;"Field 'zip' does not exist in the data."&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;Any further help is much appreciated, thank you.&lt;/P&gt;</description>
    <pubDate>Mon, 19 Sep 2022 04:43:03 GMT</pubDate>
    <dc:creator>dzyfer</dc:creator>
    <dc:date>2022-09-19T04:43:03Z</dc:date>
    <item>
      <title>How to transform event data for table display?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-transform-event-data-for-table-display/m-p/613350#M213163</link>
      <description>&lt;P&gt;Hi, I would like display values of variables from an event as a Table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My data format is as follow:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="50%" height="25px"&gt;Time&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;Event&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="121px"&gt;9/16/22&lt;BR /&gt;10:10:10.000 AM&lt;/TD&gt;
&lt;TD width="50%" height="121px"&gt;
&lt;P&gt;index=* sourcetype=* type=*&lt;/P&gt;
&lt;P&gt;"&lt;STRONG&gt;Name1&lt;/STRONG&gt;" : "A", "&lt;STRONG&gt;Name2&lt;/STRONG&gt;" : "B", "&lt;STRONG&gt;Name3&lt;/STRONG&gt;" : "C", ... "&lt;STRONG&gt;Name10&lt;/STRONG&gt;" : "J",&lt;BR /&gt;"&lt;STRONG&gt;Var1&lt;/STRONG&gt;" : 10, "&lt;STRONG&gt;Var2&lt;/STRONG&gt;" : 10, "&lt;STRONG&gt;Var3&lt;/STRONG&gt;" : 25, ... "&lt;STRONG&gt;Var10&lt;/STRONG&gt;" : 50&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;BR /&gt;I would like the search data to be transformed into a table formatted like this, internalizing the field names Name*, Var* and replacing the column headers with new names as shown below.&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="50%" height="25px"&gt;&lt;STRONG&gt;Station&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;&lt;STRONG&gt;Value&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="25px"&gt;A&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="25px"&gt;B&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="25px"&gt;C&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;25&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="25px"&gt;...&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;...&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="25px"&gt;J&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;50&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;BR /&gt;How can I do this? Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 03:32:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-event-data-for-table-display/m-p/613350#M213163</guid>
      <dc:creator>dzyfer</dc:creator>
      <dc:date>2022-09-21T03:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: Transforming event data for table display</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-transform-event-data-for-table-display/m-p/613421#M213191</link>
      <description>&lt;P&gt;It can be done, but it requires jumping through a few hoops.&amp;nbsp; The first step is to extract the Name and Var values.&amp;nbsp; Then the Names and Vars are paired up and then separated into their own events.&amp;nbsp; Finally, the pairs are split up for display.&lt;/P&gt;&lt;P&gt;Here's a run-anywhere example.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval _raw="index=* sourcetype=* type=* \"Name1\" : \"A\", \"Name2\" : \"B\", \"Name3\" : \"C\", ... \"Name10\" : \"J\",
\"Var1\" : 10, \"Var2\" : 10, \"Var3\" : 25, ... \"Var10\" : 50"
```Above defines test data```
```Use rex to extract fields```
| rex max_match=0 "Name\d+\\\"\s*:\s*\\\"(?&amp;lt;Name&amp;gt;[^\\\"]+)"
| rex max_match=0 "Var\d+\\\"\s*:\s*(?&amp;lt;Var&amp;gt;\d+)"
```Pair-up Name and Var values```
| eval zip=mvzip(Name, Var)
```Create separate events for each pair```
| mvexpand zip
```Break up the pairs```
| eval unzip=split(zip, ",")
| eval Name=mvindex(unzip,0), Var=mvindex(unzip,1)
```Display the results```
| table Name,Var&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 16 Sep 2022 14:13:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-event-data-for-table-display/m-p/613421#M213191</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-09-16T14:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: Transforming event data for table display</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-transform-event-data-for-table-display/m-p/613546#M213240</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;, thanks for the reply, unfortunately I am unable to make this method work on my actual data despite it working on the run-anywhere. I am not very familiar with rex, hence please pardon me as I have some questions on the code.&lt;/P&gt;&lt;P&gt;1. Do I need to define the data as per this line? What if I have many (&amp;gt;100) variables?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;\"Name1\" : \"A\", \"Name2\" : \"B\", \"Name3\" : \"C\", ... \"Name10\" : \"J\",
\"Var1\" : 10, \"Var2\" : 10, \"Var3\" : 25, ... \"Var10\" : 50"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. After the &lt;STRONG&gt;| &lt;FONT color="#0000FF"&gt;mvexpand&lt;/FONT&gt; zip&lt;/STRONG&gt; line, the search returns &lt;STRONG&gt;"Field 'zip' does not exist in the data."&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;Any further help is much appreciated, thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 04:43:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-event-data-for-table-display/m-p/613546#M213240</guid>
      <dc:creator>dzyfer</dc:creator>
      <dc:date>2022-09-19T04:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: Transforming event data for table display</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-transform-event-data-for-table-display/m-p/613604#M213265</link>
      <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;makeresults&lt;/FONT&gt; and first &lt;FONT face="courier new,courier"&gt;eval&lt;/FONT&gt; commands must be removed to use the query with real data.&amp;nbsp; Replace them with the search the returns your data.&lt;/P&gt;&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;rex&lt;/FONT&gt; commands may need to be modified to fit the real-life data.&amp;nbsp; Share a sanitized sample of that data if you need help crafting a regular expression.&lt;/P&gt;&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;mvexpand&lt;/FONT&gt; command will fail if the Name and/or Var fields are missing so it's important to get the regular expressions right.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 12:55:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-event-data-for-table-display/m-p/613604#M213265</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-09-19T12:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: Transforming event data for table display?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-transform-event-data-for-table-display/m-p/613744#M213305</link>
      <description>&lt;P&gt;In addition to mvzip that&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;suggested, there could be a shortcut using &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Multikv" target="_blank" rel="noopener"&gt;multikv&lt;/A&gt; if data format is as regular as illustrated. &amp;nbsp;Try&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval event = replace(event, "[^:]+:( *[^,]+)", "\1")
| eval _raw = replace(event, "(\d+.*)", "
\1")
| multikv&lt;/LI-CODE&gt;&lt;P&gt;This is assuming that the resultant keys ("A", "B", etc.) contain no numeric characters. &amp;nbsp;The method is still usable if they do contain numeric characters, but the formula needs to be refined.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2022 09:25:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-event-data-for-table-display/m-p/613744#M213305</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-09-20T09:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: Transforming event data for table display</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-transform-event-data-for-table-display/m-p/613866#M213331</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;, thanks for the tips, they've helped me solve the issue.&amp;nbsp;&lt;BR /&gt;I have an additional question,&lt;/P&gt;&lt;P&gt;I have fields containing strings that sometimes do not return data, how can I include these as NULL in the table as well?&amp;nbsp;&lt;/P&gt;&lt;P&gt;E.g.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"stTestData9":"","stTestData10":"TestValue",&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 05:53:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-event-data-for-table-display/m-p/613866#M213331</guid>
      <dc:creator>dzyfer</dc:creator>
      <dc:date>2022-09-21T05:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: Transforming event data for table display</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-transform-event-data-for-table-display/m-p/613921#M213338</link>
      <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;fillnull&lt;/FONT&gt; comand should help with that.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| fillnull stTestData9&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 21 Sep 2022 12:26:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-transform-event-data-for-table-display/m-p/613921#M213338</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-09-21T12:26:52Z</dc:date>
    </item>
  </channel>
</rss>

