<?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 separate the value into two different fields using like function in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312175#M93512</link>
    <description>&lt;P&gt;The problem is that you have to go from most unique to less unique order in your case statement.  The way that you have it now, the first match is so generic, it gobbles up the other more-specific cases on the first line and in a case statement, the first match wins.  So we just re-order your &lt;CODE&gt;case&lt;/CODE&gt; statement like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;myquery
|eval Description=case(like(Description,"% MSSQL 20%"), "Microsoft Sql server Database",
                       like(Description,"%MSSQL%"    ), "MySQL Database",
                                                true(), "OTHER/UNKNOWN/ERROR")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 06 Apr 2017 14:49:46 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-04-06T14:49:46Z</dc:date>
    <item>
      <title>how to separate the value into two different fields using like function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312169#M93506</link>
      <description>&lt;P&gt;For example i have the field ,&lt;/P&gt;

&lt;P&gt;description field like KM - PROD - MSSQL 2008 VA&lt;BR /&gt;
                                    DC - PROD - MSSQL 2012 VA&lt;BR /&gt;
                                     KM - WDC - MSSQL VA&lt;/P&gt;

&lt;P&gt;Here i need to use like function in description  &lt;/P&gt;

&lt;P&gt;myquery|eval Description=case(LIKE(Description,"%MSSQL%"),"MySQL Database",like (Description,"% MSSQL 20%"),"Microsoft Sql server Database")).&lt;/P&gt;

&lt;P&gt;But here iam getting only MySQL Database and the values with "DC - PROD - MSSQL 2012 VA" was not segregated like Microsoft Sql server Database.&lt;BR /&gt;
I am also using this like function for filtering some more values like oracle etc in this.&lt;BR /&gt;
Please suggest me a way to do this . &lt;/P&gt;

&lt;P&gt;Thanks ,&lt;BR /&gt;
ums&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 09:59:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312169#M93506</guid>
      <dc:creator>umsundar2015</dc:creator>
      <dc:date>2017-04-06T09:59:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to separate the value into two different fields using like function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312170#M93507</link>
      <description>&lt;P&gt;If I understand correctly you just want to group your databases by type, in that case you can use the case statement with match like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval databaseType = case(
    match(Description, "MySQL"), "MySQL Database",
    match(Description, "MSSQL"), "Microsoft Sql server Database",
    match(Description, "Oracle"), "Oracle Database",
    1==1, "Unknown Database"
)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is that what you are looking for or did I miss something?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
J&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 10:34:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312170#M93507</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2017-04-06T10:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to separate the value into two different fields using like function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312171#M93508</link>
      <description>&lt;P&gt;@umsundar2015, your first condition is always true. You need to define case conditions in a way that your it matches only one of the conditions or else it will always pick the first one. Test out with the following run anywhere search (change DBType to test various values):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval DBType="KM - PROD - MSSQL 2008 VA"
| eval Description=case(like(DBType,"%MSSQL VA"),"MySQL Database",like(DBType,"%MSSQL 20%VA"),"Microsoft Sql server Database")
| table DBType Description
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: define default condition in case block in case DB Pattern is not matched using true() or 1==1 condition and set DB to "Unknown DB"&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 10:37:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312171#M93508</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-04-06T10:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to separate the value into two different fields using like function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312172#M93509</link>
      <description>&lt;P&gt;Hi umsundar2015,&lt;BR /&gt;
why you don't extract fields from your events using something like this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;^(?&amp;lt;Field1&amp;gt;[^ ]*)\s-\s(?&amp;lt;Field2&amp;gt;[^ ]*)\s-\s(?&amp;lt;Field3&amp;gt;.*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(you can test it at &lt;A href="https://regex101.com/r/fjv7TF/1"&gt;https://regex101.com/r/fjv7TF/1&lt;/A&gt;)&lt;BR /&gt;
And after you can run searches on the single fields.&lt;BR /&gt;
To correctly address your field, instead to use like function (that's slow!) you could create a lookup containing all the values of your DB and the description to show:&lt;BR /&gt;
lookup &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;DB,Description
MSSQL 2008 VA,Microsoft Sql server Database
MSSQL 2012 VA,Microsoft Sql server Database
MSSQL VA,MySQL Database
........
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;so you can add lookup values to your searches obtaining something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your_search
| lookup databases DB OUTPUT Description
| table _time description
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 10:44:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312172#M93509</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-04-06T10:44:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to separate the value into two different fields using like function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312173#M93510</link>
      <description>&lt;P&gt;thanks you ,&lt;/P&gt;

&lt;P&gt;But if i write match function , i have to write many match functions .Because i have many values related to that and the above is just an example.&lt;/P&gt;

&lt;P&gt;Pls suggest me  different way &lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 12:29:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312173#M93510</guid>
      <dc:creator>umsundar2015</dc:creator>
      <dc:date>2017-04-06T12:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to separate the value into two different fields using like function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312174#M93511</link>
      <description>&lt;P&gt;thank you ,&lt;/P&gt;

&lt;P&gt;This is not working , i tried this but all the values are getting populated in MYSQL only &lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 12:30:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312174#M93511</guid>
      <dc:creator>umsundar2015</dc:creator>
      <dc:date>2017-04-06T12:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to separate the value into two different fields using like function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312175#M93512</link>
      <description>&lt;P&gt;The problem is that you have to go from most unique to less unique order in your case statement.  The way that you have it now, the first match is so generic, it gobbles up the other more-specific cases on the first line and in a case statement, the first match wins.  So we just re-order your &lt;CODE&gt;case&lt;/CODE&gt; statement like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;myquery
|eval Description=case(like(Description,"% MSSQL 20%"), "Microsoft Sql server Database",
                       like(Description,"%MSSQL%"    ), "MySQL Database",
                                                true(), "OTHER/UNKNOWN/ERROR")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Apr 2017 14:49:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312175#M93512</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-04-06T14:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: how to separate the value into two different fields using like function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312176#M93513</link>
      <description>&lt;P&gt;If your Description field has always the same format (VALUE1 - VALUE2 - DBTYPE)  you could simply do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval databaseType = mvindex(split(Description, "-"), 2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or use regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=Description "\-(?&amp;lt;databaseType&amp;gt;[^\-]+)$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And then play around with the databaseType field to get rid of numeric values, etc.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 15:31:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312176#M93513</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2017-04-06T15:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to separate the value into two different fields using like function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312177#M93514</link>
      <description>&lt;P&gt;Perhaps also you meant &lt;CODE&gt;MYSQL&lt;/CODE&gt; instead of &lt;CODE&gt;MSSQL&lt;/CODE&gt; for the &lt;CODE&gt;MySQL Database&lt;/CODE&gt; entry?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 18:30:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312177#M93514</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-04-06T18:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: how to separate the value into two different fields using like function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312178#M93515</link>
      <description>&lt;P&gt;@umsundar2015.... You dont need first two lines, instead your base search will be present. I have used makeresults just as an example which you can use for testing...  Keep replacing the second line above with various DB types and test. Once you find correct conditions, you can put the 3rd and 4th line back in your base search.&lt;/P&gt;

&lt;P&gt;If following is your MySQL Server name(as per your example), you can replace the same and test out the above query.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval DBType="KM - WDC - MSSQL VA"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Apr 2017 03:33:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312178#M93515</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-04-07T03:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to separate the value into two different fields using like function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312179#M93516</link>
      <description>&lt;P&gt;Hi Woodcock,&lt;/P&gt;

&lt;P&gt;Thank you so much .&lt;BR /&gt;
This works the way which i expected .&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 06:53:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-separate-the-value-into-two-different-fields-using-like/m-p/312179#M93516</guid>
      <dc:creator>umsundar2015</dc:creator>
      <dc:date>2017-04-07T06:53:57Z</dc:date>
    </item>
  </channel>
</rss>

