<?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 Include field name in table? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-Include-field-name-in-table/m-p/602019#M209534</link>
    <description>&lt;P&gt;I'm not sure I follow.&lt;/P&gt;&lt;P&gt;You want a single search to stats&lt;/P&gt;&lt;P&gt;1) overall count by kxalgo&lt;/P&gt;&lt;P&gt;2) overall count by pkalog&lt;/P&gt;&lt;P&gt;3) overall count by cipher&lt;/P&gt;&lt;P&gt;4) overall count by mac&lt;/P&gt;&lt;P&gt;Which would mean for different independent stats?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jun 2022 06:55:19 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2022-06-16T06:55:19Z</dc:date>
    <item>
      <title>How to Include field name in table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Include-field-name-in-table/m-p/601953#M209509</link>
      <description>&lt;P&gt;Hello! I have learned so much from this community over the years but there is one query I am trying to write that I cannot figure out.&lt;/P&gt;
&lt;P&gt;I have a number of logs each containing four fields, each of those fields have a unique set of a few values. I am trying to do a count for each unique value and put it in a three column table including the field name, value, and count. I know I can hard-code all the values to give them a category/field name but as these values change over time I would rather not have to do that if possible.&lt;/P&gt;
&lt;P&gt;Log examples&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;key exchange algo: dh-group-exchange-sha256, public key algo: ssh-dss, cipher algo: aes128-cbc, mac algo: sha256

key exchange algo: ecdh-sha2-nistp256, public key algo: ssh-rsa, cipher algo: aes256-ctr, mac algo: sha256&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Desired result:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;field&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;cipher&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;count&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;keyExchange&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;dh-group-exchange-sha256&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;##&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;keyExchange&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;ecdh-sha2-nistp256&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;##&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;publicKey&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;ssh-dss&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;##&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;publicKey&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;ssh-rsa&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;##&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;etc.&lt;/P&gt;
&lt;P&gt;Is there a way to do this besides hard-coding a field for each cipher?&lt;/P&gt;
&lt;P&gt;For reference, here is how I am pulling the two column list of cipher | count without the field name:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;base search
| eval cipher=keyExchange.";".publicKey
| makemv delim=";" cipher
| stats count by cipher&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;This also works for two columns but appears to be a bit slower&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| eval cipher = mvappend(keyExchange,publicKey)
| mvexpand cipher
| stats count by cipher&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 21:01:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Include-field-name-in-table/m-p/601953#M209509</guid>
      <dc:creator>bbeebe</dc:creator>
      <dc:date>2022-06-15T21:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: Include field name in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Include-field-name-in-table/m-p/601978#M209517</link>
      <description>&lt;LI-CODE lang="markup"&gt;| extract pairdelim="," kvdelim=":"
| untable _time algo cipher
| eval algo_cipher=algo."|".cipher
| stats count by algo_cipher
| eval algo=mvindex(split(algo_cipher,"|"),0)
| eval cipher=mvindex(split(algo_cipher,"|"),1)
| table algo cipher count&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 15 Jun 2022 20:40:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Include-field-name-in-table/m-p/601978#M209517</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-06-15T20:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: Include field name in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Include-field-name-in-table/m-p/601993#M209523</link>
      <description>&lt;P&gt;Thanks for the reply. This returns the algos and ciphers but also every other extracted field as well so the table looks something like this:&lt;/P&gt;&lt;TABLE border="1" width="97.85353535353535%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%"&gt;algo&lt;/TD&gt;&lt;TD width="50%"&gt;cipher&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;cipher_algo&lt;/TD&gt;&lt;TD width="50%"&gt;aes256-ctr&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;date&lt;/TD&gt;&lt;TD width="50%"&gt;20220515&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;date_hour&lt;/TD&gt;&lt;TD width="50%"&gt;14&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;date_mday&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;host&lt;/TD&gt;&lt;TD&gt;xxxxx&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;index&lt;/TD&gt;&lt;TD&gt;xxxxx&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;key_exchange_algo&lt;/TD&gt;&lt;TD&gt;ecdh-sha2-nistp256&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are ~35 fields per result returned, I don't know enough about what you suggested to troubleshoot. Is there another way to do it if I already have the four fields extracted or do you need to use the paridelim &amp;amp; kvdelim to get the field names included?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 22:36:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Include-field-name-in-table/m-p/601993#M209523</guid>
      <dc:creator>bbeebe</dc:creator>
      <dc:date>2022-06-15T22:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: Include field name in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Include-field-name-in-table/m-p/602003#M209527</link>
      <description>&lt;P&gt;Perhaps you could share the actual event so we can see what you are actually dealing with - it might help with getting a more accurate solution?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 06:03:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Include-field-name-in-table/m-p/602003#M209527</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-06-16T06:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to Include field name in table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Include-field-name-in-table/m-p/602019#M209534</link>
      <description>&lt;P&gt;I'm not sure I follow.&lt;/P&gt;&lt;P&gt;You want a single search to stats&lt;/P&gt;&lt;P&gt;1) overall count by kxalgo&lt;/P&gt;&lt;P&gt;2) overall count by pkalog&lt;/P&gt;&lt;P&gt;3) overall count by cipher&lt;/P&gt;&lt;P&gt;4) overall count by mac&lt;/P&gt;&lt;P&gt;Which would mean for different independent stats?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 06:55:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Include-field-name-in-table/m-p/602019#M209534</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-06-16T06:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: Include field name in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Include-field-name-in-table/m-p/602025#M209539</link>
      <description>&lt;P&gt;If you already have the fields extracted e.g. *_algo, try this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| table _time *_algo
| untable _time algo cipher
| eval algo_cipher=algo."|".cipher
| stats count by algo_cipher
| eval algo=mvindex(split(algo_cipher,"|"),0)
| eval cipher=mvindex(split(algo_cipher,"|"),1)
| table algo cipher count&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 16 Jun 2022 07:20:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Include-field-name-in-table/m-p/602025#M209539</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-06-16T07:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Include field name in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Include-field-name-in-table/m-p/602158#M209599</link>
      <description>&lt;P&gt;This did it perfectly, wow. I really appreciate your time, going to dive a bit deeper into untable and mvindex to see what you did there.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 20:40:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Include-field-name-in-table/m-p/602158#M209599</guid>
      <dc:creator>bbeebe</dc:creator>
      <dc:date>2022-06-16T20:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to Include field name in table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Include-field-name-in-table/m-p/602160#M209600</link>
      <description>&lt;P&gt;Essentially its four independent "stats" counts for each field put into one table. I could get all the results in a table with the values and their count but wanted to add a column with the field name as well. ITWhisperer provided a solution for that.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 20:44:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Include-field-name-in-table/m-p/602160#M209600</guid>
      <dc:creator>bbeebe</dc:creator>
      <dc:date>2022-06-16T20:44:59Z</dc:date>
    </item>
  </channel>
</rss>

