<?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: What is the Splunk SPL for matching same values and output to an additional column with a newly defined value? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/What-is-the-Splunk-SPL-for-matching-same-values-and-output-to-an/m-p/394140#M95628</link>
    <description>&lt;P&gt;Hi @ vnravikumar&lt;/P&gt;

&lt;P&gt;This one worked too with slight adjustment with my need. I am going to up-vote this as well. Thanks.&lt;/P&gt;</description>
    <pubDate>Fri, 22 Feb 2019 13:24:57 GMT</pubDate>
    <dc:creator>mbasharat</dc:creator>
    <dc:date>2019-02-22T13:24:57Z</dc:date>
    <item>
      <title>What is the Splunk SPL for matching same values and output to an additional column with a newly defined value?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/What-is-the-Splunk-SPL-for-matching-same-values-and-output-to-an/m-p/394134#M95622</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a field named OS&lt;/P&gt;

&lt;P&gt;This field is populating multiple values such as below after running the following SPL:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup Host.csv
| stats dc(host) as Count by OS
| fields - Count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;WINDOWS NT
WINDOWS SERVER 2003
WINDOWS SERVER 2008
WINDOWS SERVER 2012
LINUX
LINUX 6.7
LINUX 7.0
SOLARIS 9
SOLARIS 10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want an additional column in results that if:&lt;/P&gt;

&lt;P&gt;All the Windows above should display Windows&lt;BR /&gt;
All the Linux above, should display Linux&lt;BR /&gt;
and so on in an additional column like below:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/6563iA94F0F466EA37CFE/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;How? I tried to use eval and case but seems like not getting it or having a long day.&lt;/P&gt;

&lt;P&gt;Thanks in-advance&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 19:47:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/What-is-the-Splunk-SPL-for-matching-same-values-and-output-to-an/m-p/394134#M95622</guid>
      <dc:creator>mbasharat</dc:creator>
      <dc:date>2019-02-21T19:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: What is the Splunk SPL for matching same values and output to an additional column with a newly defined value?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/What-is-the-Splunk-SPL-for-matching-same-values-and-output-to-an/m-p/394135#M95623</link>
      <description>&lt;P&gt;Based on OS values you posted in question, something like this would work (assuming first letter in the OS value is OS Group)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup Host.csv
| stats dc(host) as Count by OS
| fields - Count
| eval OS_Group=mvindex(split(OS," "),0)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you know that available OS values are Static, you can do this eval-case implementation&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup Host.csv
| stats dc(host) as Count by OS
| fields - Count
| eval OS_Group=case(match(OS,"LINUX"),"Linux", match(OS,"WINDOWS"), "Windows", match(OS,"SOLARIS"), "Solaris",...other matches will come here..., true(),"Default Group Value Here")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Feb 2019 19:57:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/What-is-the-Splunk-SPL-for-matching-same-values-and-output-to-an/m-p/394135#M95623</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2019-02-21T19:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: What is the Splunk SPL for matching same values and output to an additional column with a newly defined value?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/What-is-the-Splunk-SPL-for-matching-same-values-and-output-to-an/m-p/394136#M95624</link>
      <description>&lt;P&gt;@ somesoni2&lt;/P&gt;

&lt;P&gt;Is it possible to do something like this for matching before and after?&lt;/P&gt;

&lt;P&gt;| inputlookup Host.csv&lt;BR /&gt;
| stats dc(host) as Count by OS&lt;BR /&gt;
| fields - Count&lt;BR /&gt;
| eval OS_Group = case(match(OS,"%LINUX%"),"Linux", match(OS,"%WIN%"), "Windows", match(OS,"%SOL%"), "Solaris", true(),"OS")&lt;/P&gt;

&lt;P&gt;OR&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;| eval OS_Group = case(match(OS,"asterikLINUXasterik"),"Linux", match(OS,"asterikWINasterik"), "Windows", match(OS,"asterikSOLasterik"), "Solaris", true(),"OS")&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I have a long list of different versions of several OSs and I want an additional column so I can categorize them in an OS_Group and then use these for drop down filter menus.&lt;/P&gt;

&lt;P&gt;Also, What is this true() doing here?&lt;/P&gt;

&lt;P&gt;Thx&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 20:26:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/What-is-the-Splunk-SPL-for-matching-same-values-and-output-to-an/m-p/394136#M95624</guid>
      <dc:creator>mbasharat</dc:creator>
      <dc:date>2019-02-21T20:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: What is the Splunk SPL for matching same values and output to an additional column with a newly defined value?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/What-is-the-Splunk-SPL-for-matching-same-values-and-output-to-an/m-p/394137#M95625</link>
      <description>&lt;P&gt;If you're using &lt;CODE&gt;match&lt;/CODE&gt; function like I mentioned in my answer, you don't have to use a wildcard (e.g. &lt;CODE&gt;%&lt;/CODE&gt; OR &lt;CODE&gt;*&lt;/CODE&gt;). The &lt;CODE&gt;match(OS,"LINUX")&lt;/CODE&gt;  will check if value of field OS contains word LINUX (not doing exact match). You'd see the results when you actually run the search. It is same as &lt;CODE&gt;like(OS,"%LINUS%%")&lt;/CODE&gt; and &lt;CODE&gt;match(OS,".*LINUX.*")&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;The function true() (which is always true) is the condition I added to allow default value (means if value of field OS doesn't match any of your match, this value will be used).&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 20:53:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/What-is-the-Splunk-SPL-for-matching-same-values-and-output-to-an/m-p/394137#M95625</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2019-02-21T20:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: What is the Splunk SPL for matching same values and output to an additional column with a newly defined value?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/What-is-the-Splunk-SPL-for-matching-same-values-and-output-to-an/m-p/394138#M95626</link>
      <description>&lt;P&gt;Sounds good. I used second option and accomodated in my need. Worked great. Thanks @somesoni2 &lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 21:15:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/What-is-the-Splunk-SPL-for-matching-same-values-and-output-to-an/m-p/394138#M95626</guid>
      <dc:creator>mbasharat</dc:creator>
      <dc:date>2019-02-21T21:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: What is the Splunk SPL for matching same values and output to an additional column with a newly defined value?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/What-is-the-Splunk-SPL-for-matching-same-values-and-output-to-an/m-p/394139#M95627</link>
      <description>&lt;P&gt;Hi @mbasharat&lt;/P&gt;

&lt;P&gt;You can try this also&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup Host.csv 
| stats dc(host) as Count by OS 
| fields - Count 
| rex field=OS "(?P&amp;lt;os&amp;gt;^([\w\-]+))" 
| eval os = upper(substr(os,1,1)).lower(substr(os,2))
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Feb 2019 21:27:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/What-is-the-Splunk-SPL-for-matching-same-values-and-output-to-an/m-p/394139#M95627</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-02-21T21:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: What is the Splunk SPL for matching same values and output to an additional column with a newly defined value?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/What-is-the-Splunk-SPL-for-matching-same-values-and-output-to-an/m-p/394140#M95628</link>
      <description>&lt;P&gt;Hi @ vnravikumar&lt;/P&gt;

&lt;P&gt;This one worked too with slight adjustment with my need. I am going to up-vote this as well. Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 13:24:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/What-is-the-Splunk-SPL-for-matching-same-values-and-output-to-an/m-p/394140#M95628</guid>
      <dc:creator>mbasharat</dc:creator>
      <dc:date>2019-02-22T13:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: What is the Splunk SPL for matching same values and output to an additional column with a newly defined value?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/What-is-the-Splunk-SPL-for-matching-same-values-and-output-to-an/m-p/394141#M95629</link>
      <description>&lt;P&gt;Thanks. Please up vote.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 22:37:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/What-is-the-Splunk-SPL-for-matching-same-values-and-output-to-an/m-p/394141#M95629</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-02-22T22:37:14Z</dc:date>
    </item>
  </channel>
</rss>

