<?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: Make table from key-value serie in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-table-from-key-value-series/m-p/633083#M219916</link>
    <description>&lt;P&gt;Thank you!.&lt;/P&gt;&lt;P&gt;The key for solving this was the rename command to _raw!&lt;/P&gt;&lt;P&gt;But I have to remove the old fields completley - otherwise the table output (| table *&amp;nbsp; ---needed to display a stastic table ) will display ALL fields, _time, host, sourcetype, old_index etc.&lt;/P&gt;&lt;P&gt;I added just before the split-command:&lt;/P&gt;&lt;PRE&gt;| table tab_res&lt;BR /&gt;| fields tab_res&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Mar 2023 00:13:08 GMT</pubDate>
    <dc:creator>fechnert</dc:creator>
    <dc:date>2023-03-03T00:13:08Z</dc:date>
    <item>
      <title>How to make table from key-value series?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-table-from-key-value-series/m-p/633042#M219900</link>
      <description>&lt;P&gt;HI,&lt;/P&gt;
&lt;P&gt;I have this table with one column and 3 rows (could be more as this is a search result) and ther could be also more entries in a data set&lt;/P&gt;
&lt;P&gt;date_minute:34,host:h_a,index:prod&lt;BR /&gt;date_minute:39,host:h_b,index:prod&lt;BR /&gt;date_minute:44,host:h_c:index:prod&lt;/P&gt;
&lt;P&gt;date_minute &amp;nbsp; host &amp;nbsp; index&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;--- these are the table headers&lt;BR /&gt;34&amp;nbsp;&amp;nbsp;&amp;nbsp; h_a &amp;nbsp;&amp;nbsp; prod&lt;BR /&gt;39 &amp;nbsp;&amp;nbsp; h_b &amp;nbsp;&amp;nbsp; prod&lt;BR /&gt;44 &amp;nbsp;&amp;nbsp; h_c&amp;nbsp;&amp;nbsp;&amp;nbsp; prod&lt;/P&gt;
&lt;P&gt;if there is a line like:&lt;BR /&gt;date_minute:44,host:h_c:index:prod,user:test&lt;BR /&gt;the&amp;nbsp; user:test&amp;nbsp; should be added as new column (to have 4 column)&lt;/P&gt;
&lt;P&gt;What is the best way to do this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 23:27:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-table-from-key-value-series/m-p/633042#M219900</guid>
      <dc:creator>fechnert</dc:creator>
      <dc:date>2023-03-02T23:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: Make table from key-value serie</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-table-from-key-value-series/m-p/633057#M219904</link>
      <description>&lt;P&gt;Use the &lt;FONT face="courier new,courier"&gt;extract&lt;/FONT&gt; command to convert those key:value pairs into fields and values.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;&amp;lt;your search&amp;gt;&amp;gt;
| extract pairdelim="," kvdelim=":"
| table date_minute host index *&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 20:46:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-table-from-key-value-series/m-p/633057#M219904</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-03-02T20:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to make table from key-value series?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-table-from-key-value-series/m-p/633058#M219905</link>
      <description>&lt;P&gt;I'm a little confused about what's going on with the tables that you mentioned in your question. Let me know if I'm missing the beat here.&lt;/P&gt;&lt;P&gt;From what I'm reading you're starting out with data structured like this&lt;BR /&gt;&lt;SPAN&gt;1date_minute:44,host:h_c:index:prod1&lt;/SPAN&gt;&lt;BR /&gt;key:value, comma-delimited&lt;BR /&gt;and you want to be able to format this data as a table? If so:&lt;BR /&gt;&lt;BR /&gt;I suggest that you set-up field extractions for your sourcetype. Add the following to your props and transforms conf (replacing my_sourcetype with the name of the sourcetype in question).&lt;EM&gt;&lt;BR /&gt;&lt;BR /&gt;props.conf&lt;/EM&gt;&lt;/P&gt;&lt;PRE&gt;[my_sourcetype]&lt;BR /&gt;REPORT-kv_comma_colon&lt;/PRE&gt;&lt;P&gt;&lt;EM&gt;transforms.conf&lt;/EM&gt;&lt;/P&gt;&lt;PRE&gt;[kv_comma_colon]&lt;BR /&gt;DELIMS = ",", ":"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Then you will be able to make any table that you want with:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=my_index sourcetype=my_sourcetype
| table data_minute, host, index&lt;/LI-CODE&gt;&lt;P&gt;Note that&amp;nbsp;&lt;EM&gt;host&amp;nbsp;&lt;/EM&gt;and&amp;nbsp;&lt;EM&gt;index&amp;nbsp;&lt;/EM&gt;are default fields so you might want to set-up a field alias for these.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 23:57:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-table-from-key-value-series/m-p/633058#M219905</guid>
      <dc:creator>Tom_Lundie</dc:creator>
      <dc:date>2023-03-02T23:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: Make table from key-value serie</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-table-from-key-value-series/m-p/633062#M219907</link>
      <description>&lt;P&gt;to clarify: it is not a normal output whith known fields and number of fields.&lt;BR /&gt;the fields are dynamicly created from a different search. The result of this search is pasted to through a macro, done some work on the fields. Now I have the table with one column and an unkown/dynamic amount of fields and names. So I cannot be sure about the amount of fields or the names.&lt;BR /&gt;I tried with mv-operations, transpose or split operations but get stuck.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 21:53:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-table-from-key-value-series/m-p/633062#M219907</guid>
      <dc:creator>fechnert</dc:creator>
      <dc:date>2023-03-02T21:53:09Z</dc:date>
    </item>
    <item>
      <title>Re: Make table from key-value serie</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-table-from-key-value-series/m-p/633064#M219908</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Thanks for clarifying,&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/248650"&gt;@fechnert&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;The result of this search is pasted to through a macro&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;What do you mean by this? I'm struggling to understand why there is no way to edit the upstream SPL in order to&amp;nbsp; get the fields structured nicely. Is there anyway you could share some sample SPL / Data showing the whole problem end-to-end please? I understand that you might need to obfuscate this.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 22:01:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-table-from-key-value-series/m-p/633064#M219908</guid>
      <dc:creator>Tom_Lundie</dc:creator>
      <dc:date>2023-03-02T22:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: Make table from key-value serie</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-table-from-key-value-series/m-p/633072#M219912</link>
      <description>&lt;P&gt;Background: I like to store the output of a table crypted into another index.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;example search from&amp;nbsp; user-1:&lt;BR /&gt;...&lt;BR /&gt;| table user,host,_time,eventcode, status&lt;BR /&gt;| 'macro X'&lt;BR /&gt;&lt;BR /&gt;example search from user-2:&lt;BR /&gt;| table severity,proc,username,dest, source_ip&lt;BR /&gt;| 'macro X'&lt;BR /&gt;&lt;BR /&gt;example search from user-3:&lt;BR /&gt;| table date_minute,host,index&lt;BR /&gt;| 'macro X'&lt;/P&gt;&lt;P&gt;user-3 search creates this before the macro call:&lt;BR /&gt;date_minute&amp;nbsp;&amp;nbsp; host&amp;nbsp;&amp;nbsp; index &amp;nbsp;&lt;BR /&gt;34&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; h_a&amp;nbsp;&amp;nbsp;&amp;nbsp; prod&lt;BR /&gt;39&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; h_b&amp;nbsp;&amp;nbsp;&amp;nbsp; prod&lt;BR /&gt;44&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; h_c&amp;nbsp;&amp;nbsp;&amp;nbsp; prod&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;macro X:&lt;BR /&gt;| ....&lt;BR /&gt;/|&amp;nbsp; now converting output of table into json field (thanks to this forum!)&lt;BR /&gt;| appendpipe&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; | eventstats count as r_ev&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | foreach *&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ | eval jsonmv_ = if("&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;" == "r_ev",jsonmv_ , mvappend(jsonmv_,"'&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;':'" + &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; + "'")&amp;nbsp; ) ]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | eval json_result = "{" + mvjoin(jsonmv_,",") + "}"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | fields - jsonmv_&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; | stats values(json_result) AS table_result by r_ev&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; /## here the field "table_result"&amp;nbsp; for user-3 is a long string:&lt;BR /&gt;&amp;nbsp;&amp;nbsp; {date_minute:34,host:h_a,index:prod} {date_minute:39,host:h_b,index:prod} {date_minute:44,host:h_c:index:prod}&amp;nbsp;&amp;nbsp; /&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; /| ##crypting the table_result -&amp;gt;output field is table_result_crypted/&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; | table some_fiels , table_result_crypted&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; | collect index=XXX&amp;nbsp;&lt;BR /&gt;]&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;Now I have the result of the user search from the user-1 or user-2 as a json-field crypted in another index.&lt;BR /&gt;In a dashboard I like to have a table as the user-1 or user-2&amp;nbsp; or user-3 had: in the beginning:&lt;BR /&gt;&lt;BR /&gt;index=XXX&lt;BR /&gt;| /####decrypting the field into field "tab_res" : I have the same field content as table_result above /&lt;BR /&gt;| /##removing {} /&lt;BR /&gt;| rex mode=sed field=tab_res "s/}//g"&lt;BR /&gt;| rex mode=sed field=tab_res "s/{//g"&lt;BR /&gt;| eval fields=split(tab_res," ")&lt;BR /&gt;| mvexpand fields&lt;BR /&gt;|&amp;nbsp; table fields&lt;BR /&gt;&lt;BR /&gt;---&amp;gt; here I have a table with 3rows, 1 column:&lt;BR /&gt;date_minute:34,host:h_a,index:prod&lt;BR /&gt;date_minute:39,host:h_b,index:prod&lt;BR /&gt;date_minute:44,host:h_c:index:prod&lt;BR /&gt;&lt;BR /&gt;but I need to split in a dynamic way the rows into columns not knowing how much fields or lines I will have.&lt;BR /&gt;Nice would be to have something like this pseudo-code:&lt;BR /&gt;| split_into_columns delim=","&amp;nbsp; "header:cell_content"&lt;BR /&gt;&lt;BR /&gt;Output&lt;BR /&gt;date_minute&amp;nbsp;&amp;nbsp; host&amp;nbsp;&amp;nbsp; index &amp;nbsp;&lt;BR /&gt;34&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; h_a&amp;nbsp;&amp;nbsp;&amp;nbsp; prod&lt;BR /&gt;39&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; h_b&amp;nbsp;&amp;nbsp;&amp;nbsp; prod&lt;BR /&gt;44&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; h_c&amp;nbsp;&amp;nbsp;&amp;nbsp; prod&lt;/P&gt;&lt;P&gt;I tried to split at delim "," (did not work!) and transpose the table.....not working....&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 22:40:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-table-from-key-value-series/m-p/633072#M219912</guid>
      <dc:creator>fechnert</dc:creator>
      <dc:date>2023-03-02T22:40:20Z</dc:date>
    </item>
    <item>
      <title>Re: Make table from key-value serie</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-table-from-key-value-series/m-p/633080#M219914</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;'s answer will do what you need it to but you just need to rename the "fields" column as _raw first to get the extract command to pick it up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rename fields as _raw
| extract kvdelim=":" pairdelim=","
| fields - _raw&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This SPL and the SPL you have shared above is going to play up if the summary indexes feeding this search contain brackets, colons or commas.&amp;nbsp; It might be worth stripping those characters out in Macro X.&lt;BR /&gt;&lt;BR /&gt;Here is a run anywhere for future reference:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval sample = "date_minute:34,host:h_a,index:prod|date_minute:39,host:h_b,index:prod|date_minute:44,host:h_c,index:prod"
| makemv sample delim="|"
| mvexpand sample
| fields - _time
| rename sample as fields
| rename fields as _raw
| extract kvdelim=":" pairdelim=","
| fields - _raw &lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 03 Mar 2023 00:03:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-table-from-key-value-series/m-p/633080#M219914</guid>
      <dc:creator>Tom_Lundie</dc:creator>
      <dc:date>2023-03-03T00:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Make table from key-value serie</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-table-from-key-value-series/m-p/633083#M219916</link>
      <description>&lt;P&gt;Thank you!.&lt;/P&gt;&lt;P&gt;The key for solving this was the rename command to _raw!&lt;/P&gt;&lt;P&gt;But I have to remove the old fields completley - otherwise the table output (| table *&amp;nbsp; ---needed to display a stastic table ) will display ALL fields, _time, host, sourcetype, old_index etc.&lt;/P&gt;&lt;P&gt;I added just before the split-command:&lt;/P&gt;&lt;PRE&gt;| table tab_res&lt;BR /&gt;| fields tab_res&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 00:13:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-table-from-key-value-series/m-p/633083#M219916</guid>
      <dc:creator>fechnert</dc:creator>
      <dc:date>2023-03-03T00:13:08Z</dc:date>
    </item>
  </channel>
</rss>

