<?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: custom text to the results in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/custom-text-to-the-results/m-p/671439#M18068</link>
    <description>&lt;P&gt;That won't work as expected.&amp;nbsp; If File is "XYZ_*" then Consumer will be set to "" because of the last &lt;FONT face="courier new,courier"&gt;eval&lt;/FONT&gt; statement.&amp;nbsp; For instances like this, use the &lt;FONT face="courier new,courier"&gt;case&lt;/FONT&gt; function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;base search 
| rex field User | rex field Folder | rex field File
| eval Consumer = case(match(File, "^xyz"), "Core",
                       match(File,"^ABC"),"Core",
                       match(File,"^MNP"),"Non-Core",
                       1==1,"Others")
| table File Consumer&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Dec 2023 14:53:33 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2023-12-11T14:53:33Z</dc:date>
    <item>
      <title>custom text to the results</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/custom-text-to-the-results/m-p/671258#M18054</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;from the logs, i have extracted the below data(table1). I would like to add another column as in Table2 with custom keyword if filename begins xyz then "Core".&lt;/P&gt;
&lt;P&gt;Please could you suggest what splunk query or logic we could apply?&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Splunk Query:&lt;/STRONG&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;base search | rex field User | rex field Folder | rex filed File
| table User  Folder File&lt;/LI-CODE&gt;
&lt;P&gt;Table1:&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="211"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;User&lt;/TD&gt;
&lt;TD width="64"&gt;Folder&lt;/TD&gt;
&lt;TD width="83"&gt;File&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;ABC&lt;/TD&gt;
&lt;TD&gt;first&lt;/TD&gt;
&lt;TD&gt;xyz07122023&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Table 2: Required Output&lt;/P&gt;
&lt;TABLE width="275"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;User&lt;/TD&gt;
&lt;TD width="64"&gt;Folder&lt;/TD&gt;
&lt;TD width="83"&gt;File&lt;/TD&gt;
&lt;TD width="64"&gt;Consumer&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;ABC&lt;/TD&gt;
&lt;TD&gt;first&lt;/TD&gt;
&lt;TD&gt;xyz07122023&lt;/TD&gt;
&lt;TD&gt;Core&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Fri, 08 Dec 2023 15:04:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/custom-text-to-the-results/m-p/671258#M18054</guid>
      <dc:creator>selvam_sekar</dc:creator>
      <dc:date>2023-12-08T15:04:05Z</dc:date>
    </item>
    <item>
      <title>Re: custom text to the results</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/custom-text-to-the-results/m-p/671270#M18055</link>
      <description>&lt;P&gt;Use the &lt;FONT face="courier new,courier"&gt;eval&lt;/FONT&gt; command to add a field ("column").&amp;nbsp; The &lt;FONT face="courier new,courier"&gt;match&lt;/FONT&gt; function will compare a field to a string/regular expression.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;base search 
| rex field User | rex field Folder | rex field File
| eval Consumer = if(match(File, "^xyz"), "Core", "")
| table User Folder File Consumer&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2023 15:10:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/custom-text-to-the-results/m-p/671270#M18055</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-12-08T15:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: custom text to the results</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/custom-text-to-the-results/m-p/671428#M18066</link>
      <description>&lt;P&gt;Thanks, it worked as expected.&lt;/P&gt;&lt;P&gt;If we have 3 or multiple matches, do we required to write individual eval as mentioned below?&lt;/P&gt;&lt;P&gt;for example,&lt;/P&gt;&lt;TABLE border="0" width="128" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="58.2188px" height="12px"&gt;File&amp;nbsp;&lt;/TD&gt;&lt;TD width="84.9792px" height="12px"&gt;Consumer&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="58.2188px" height="12px"&gt;XYZ_*&lt;/TD&gt;&lt;TD width="84.9792px" height="12px"&gt;Core&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="58.2188px" height="12px"&gt;ABC_*&lt;/TD&gt;&lt;TD width="84.9792px" height="12px"&gt;Core&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="58.2188px" height="12px"&gt;MNP_*&lt;/TD&gt;&lt;TD width="84.9792px" height="12px"&gt;Non-Core&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="58.2188px" height="12px"&gt;RST&lt;/TD&gt;&lt;TD width="84.9792px" height="12px"&gt;Non-Core&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SPL:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;base search 
| rex field User | rex field Folder | rex field File
| eval Consumer = if(match(File, "^xyz"), "Core", "")
| eval Consumer = if(match(File,"^ABC"),"Core","")
| eval Consumer = if(match(File,"^MNP"),"Non-Core","")
| table File Consumer&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 10:00:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/custom-text-to-the-results/m-p/671428#M18066</guid>
      <dc:creator>selvam_sekar</dc:creator>
      <dc:date>2023-12-11T10:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: custom text to the results</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/custom-text-to-the-results/m-p/671439#M18068</link>
      <description>&lt;P&gt;That won't work as expected.&amp;nbsp; If File is "XYZ_*" then Consumer will be set to "" because of the last &lt;FONT face="courier new,courier"&gt;eval&lt;/FONT&gt; statement.&amp;nbsp; For instances like this, use the &lt;FONT face="courier new,courier"&gt;case&lt;/FONT&gt; function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;base search 
| rex field User | rex field Folder | rex field File
| eval Consumer = case(match(File, "^xyz"), "Core",
                       match(File,"^ABC"),"Core",
                       match(File,"^MNP"),"Non-Core",
                       1==1,"Others")
| table File Consumer&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 14:53:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/custom-text-to-the-results/m-p/671439#M18068</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-12-11T14:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: custom text to the results</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/custom-text-to-the-results/m-p/671444#M18070</link>
      <description>&lt;P&gt;Excellent! Many thanks.&lt;/P&gt;&lt;P&gt;is it possible if we make the non-matching of&amp;nbsp; the below files to map "Others".&lt;/P&gt;&lt;P&gt;for example,&lt;/P&gt;&lt;P&gt;other than file name starts with xyz, ABC, MNP&amp;nbsp; as Others.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 14:25:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/custom-text-to-the-results/m-p/671444#M18070</guid>
      <dc:creator>selvam_sekar</dc:creator>
      <dc:date>2023-12-11T14:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: custom text to the results</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/custom-text-to-the-results/m-p/671448#M18071</link>
      <description>&lt;P&gt;See my updated reply.&amp;nbsp; The last clause of this &lt;FONT face="courier new,courier"&gt;case&lt;/FONT&gt; function handles non-matches.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 14:54:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/custom-text-to-the-results/m-p/671448#M18071</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-12-11T14:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: custom text to the results</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/custom-text-to-the-results/m-p/671453#M18073</link>
      <description>&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 15:15:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/custom-text-to-the-results/m-p/671453#M18073</guid>
      <dc:creator>selvam_sekar</dc:creator>
      <dc:date>2023-12-11T15:15:51Z</dc:date>
    </item>
  </channel>
</rss>

