<?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: Extract from dynamic values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472507#M132967</link>
    <description>&lt;P&gt;What do you mean by extract? From your example, you want FooBar and foo_bar extracted as a value?&lt;/P&gt;

&lt;P&gt;Are you able to provide an actual data sample?&lt;/P&gt;</description>
    <pubDate>Fri, 14 Feb 2020 14:58:51 GMT</pubDate>
    <dc:creator>oscar84x</dc:creator>
    <dc:date>2020-02-14T14:58:51Z</dc:date>
    <item>
      <title>Extract from dynamic values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472506#M132966</link>
      <description>&lt;P&gt;I have a dynamic set of result data which I'd like to extract when the beginning of a line is the same across multiple values&lt;BR /&gt;
For instance based on this data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;FooBarBla
FooBar
FooBar_Brr
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'd like to end up with:  &lt;CODE&gt;FooBar&lt;/CODE&gt;&lt;BR /&gt;
Based on this set of data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;foo_bar_brr
foo_bar_grr
foo_bar_gr
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'd like to end up with:  &lt;CODE&gt;foo_bar&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The challenge I face is data is different all the time and it depends on a host input so I need do some sort of comparison between the lines and the extract the matching bit at the beginning of it. Any ideas how can I achieve this, if at all possible?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 13:59:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472506#M132966</guid>
      <dc:creator>neluvasilica</dc:creator>
      <dc:date>2020-02-14T13:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: Extract from dynamic values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472507#M132967</link>
      <description>&lt;P&gt;What do you mean by extract? From your example, you want FooBar and foo_bar extracted as a value?&lt;/P&gt;

&lt;P&gt;Are you able to provide an actual data sample?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 14:58:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472507#M132967</guid>
      <dc:creator>oscar84x</dc:creator>
      <dc:date>2020-02-14T14:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: Extract from dynamic values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472508#M132968</link>
      <description>&lt;P&gt;Let's assume I have this table:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard&amp;gt;
   &amp;lt;label&amp;gt;dedup/extract&amp;lt;/label&amp;gt;
   &amp;lt;row&amp;gt;
     &amp;lt;panel&amp;gt;
       &amp;lt;table&amp;gt;
         &amp;lt;search&amp;gt;
           &amp;lt;query&amp;gt;| makeresults 
 | eval sample="FooBarBla,FooBar,FooBar_Brr,foo_bar_brr,foo_bar_grr,foo_bar_gr" 
 | makemv delim="," sample | table sample
 &amp;lt;/query&amp;gt;
           &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
           &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
         &amp;lt;/search&amp;gt;
         &amp;lt;option name="count"&amp;gt;10&amp;lt;/option&amp;gt;
         &amp;lt;/table&amp;gt;
     &amp;lt;/panel&amp;gt;
   &amp;lt;/row&amp;gt;
    &amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How I can get FooBar and foo_bar extracted as values but without specifying FooBar and foo_bar in any regex? The match needs to be done based on the match at the beginning of each line.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:12:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472508#M132968</guid>
      <dc:creator>neluvasilica</dc:creator>
      <dc:date>2020-09-30T04:12:32Z</dc:date>
    </item>
    <item>
      <title>Re: Extract from dynamic values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472509#M132969</link>
      <description>&lt;P&gt;i'm little confused by your example. a bit more realistic event sample/example would be good&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 15:24:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472509#M132969</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2020-02-14T15:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: Extract from dynamic values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472510#M132970</link>
      <description>&lt;P&gt;You just have to find the right regex and that's why we'd like to see some real data. But for the example you're giving I can easily extract the two different terms with one regex as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | makeresults 
   | eval sample="FooBarBla,FooBar,FooBar_Brr,foo_bar_brr,foo_bar_grr,foo_bar_gr" 
   | makemv delim="," sample | table sample
   | rex field=sample "(?[f|F]oo\_?[b|B]ar)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Feb 2020 15:27:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472510#M132970</guid>
      <dc:creator>oscar84x</dc:creator>
      <dc:date>2020-02-14T15:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: Extract from dynamic values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472511#M132971</link>
      <description>&lt;P&gt;thank you. the use case I have is querying several Jenkins masters for their job_names.&lt;BR /&gt;
Some job_names start with let's say "Android" some with say "Application". So a search on a Jenkins master would retrieve:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Application_daily
Application_nighly
Application_test
Android_daily
Android_nighlty
Android_test
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My aim when queering the list above is to end up with 2 values:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Application
Android
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I don't want to use specific strings like Android and Application in the regex but rely on matching the beginning of each line instead. Hope this makes sense.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:12:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472511#M132971</guid>
      <dc:creator>neluvasilica</dc:creator>
      <dc:date>2020-09-30T04:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: Extract from dynamic values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472512#M132972</link>
      <description>&lt;P&gt;Like this? If there's ALWAYS an underscore after your value, that'll make it super easy to identify what you want to extract.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
  | eval sample="Application_daily,Application_nighly,Application_test,Android_daily,Android_nighlty,Android_test" 
  | makemv delim="," sample | table sample
  | rex field=sample "^(?&amp;lt;your_value&amp;gt;\w+)_.*"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Feb 2020 15:48:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472512#M132972</guid>
      <dc:creator>oscar84x</dc:creator>
      <dc:date>2020-02-14T15:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Extract from dynamic values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472513#M132973</link>
      <description>&lt;P&gt;Problem is don't know the value beforehand.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 16:02:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472513#M132973</guid>
      <dc:creator>neluvasilica</dc:creator>
      <dc:date>2020-02-14T16:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: Extract from dynamic values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472514#M132974</link>
      <description>&lt;P&gt;That doesn't matter. But there has to be SOME kind of a pattern to tell regex when to stop capturing. You need to define for the regex what it needs to look for. &lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 16:08:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472514#M132974</guid>
      <dc:creator>oscar84x</dc:creator>
      <dc:date>2020-02-14T16:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: Extract from dynamic values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472515#M132975</link>
      <description>&lt;P&gt;There is no specific word or value I can set unfortunately. The only pattern is searching thousands of values, starting with different and same characters. If beginning of the line is the same on multiple lines, stop when there is no longer a match and extract the value. Then carry on searching and do the same for the rest of the values.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 09:51:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472515#M132975</guid>
      <dc:creator>neluvasilica</dc:creator>
      <dc:date>2020-02-17T09:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: Extract from dynamic values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472516#M132976</link>
      <description>&lt;P&gt;UPDATED:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval sample="Application_daily#Application_nighly#Application_test#Android_daily#Android,nighlty#Android.test#ApplicationData#Application-Field#Application Registry" 
| makemv delim="#" sample 
| table sample 
| mvexpand sample 
| eval sample_mod = replace(sample,"(^..*?)([_\-\., ]|(?=[A-Z]))","\1_") 
| eval sample_header = mvindex(split(sample_mod,"_"),0) 
| eventstats count by sample_header
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I think that what was presented is covered.&lt;BR /&gt;
I use &lt;CODE&gt;eventstats&lt;/CODE&gt;  for clarity.&lt;BR /&gt;
Please change to &lt;CODE&gt;stats&lt;/CODE&gt; as appropriate.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 10:13:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472516#M132976</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-02-17T10:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: Extract from dynamic values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472517#M132977</link>
      <description>&lt;P&gt;thank you. having checked a few masters the common ones I can see are: "_", "-", ".", " "(whitespace)&lt;BR /&gt;
So, I think I can use multiple evals in conjunction with mvindex to achieve this. &lt;BR /&gt;
There are a few exceptions where there is no delimiter at all but only data like:&lt;BR /&gt;
ApplicationData&lt;BR /&gt;
ApplicationField&lt;BR /&gt;
ApplicationRegistry&lt;/P&gt;

&lt;P&gt;or duplicate values like:&lt;BR /&gt;
ApplicationDataApplicationData&lt;BR /&gt;
ApplicationFieldApplicationField&lt;BR /&gt;
but I'll think I'll have to deal with those on a case by case basis.&lt;BR /&gt;
Your suggestion definitely  points me in the right direction though.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 15:42:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472517#M132977</guid>
      <dc:creator>neluvasilica</dc:creator>
      <dc:date>2020-02-17T15:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: Extract from dynamic values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472518#M132978</link>
      <description>&lt;P&gt;sorry for the lack of response on this.thank you. that works great. &lt;BR /&gt;
I have a slight deviation from the standard dataset where the sample data would be like:&lt;BR /&gt;
"Application_daily#Application_nighly#Application_test#Android_daily#Android,nighlty#Android.test#ApplicationData#Application-Field#Application Registry#AUS_ApplicationRegistry#SysTest_Application#EDI_Application#"&lt;BR /&gt;
and I'd like sample_header to equal to Application from sample values like:#AUS_ApplicationRegistry#SysTest_Application#EDI_Application#&lt;/P&gt;

&lt;P&gt;I guess the best way to achieve this would be a conditional on the drop-down Jenkins host results.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:15:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472518#M132978</guid>
      <dc:creator>neluvasilica</dc:creator>
      <dc:date>2020-09-30T04:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: Extract from dynamic values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472519#M132979</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;....
| eval sample_mod = replace(sample,"(^..*?)([_\-\., ]|(?=[A-Z]))","\1_") 
| rex field=sample "(?&amp;lt;Application&amp;gt;Application)
| eval sample_header = mvindex(split(sample_mod,"_"),0) 
| eval sample_header=coalesce(Application,sample_header)
| eventstats count by sample_header
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In fact, the sample may be different.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 20:46:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-from-dynamic-values/m-p/472519#M132979</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-02-20T20:46:35Z</dc:date>
    </item>
  </channel>
</rss>

