<?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 extract these fields from my sample data? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201329#M58329</link>
    <description>&lt;P&gt;I am able to get C_drive and the related value correctly in a field. But how do I get E_drive also with the same rex command? I may have couple of other servers which has more drives, how do i dynamically get the drive info with a regex?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 10:29:45 GMT</pubDate>
    <dc:creator>anoopambli</dc:creator>
    <dc:date>2020-09-29T10:29:45Z</dc:date>
    <item>
      <title>How to extract these fields from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201324#M58324</link>
      <description>&lt;P&gt;I have raw data like this,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;09:00:06 08/01/2016 good    TSMONW46PRDV    [TSMONW46PRDV][AP] Disk Space   Disk/File System/[C]/percent full=45.745, Disk/File System/[E]/percent full=34.595  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to extract field from this so that I can get result like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[C]/percent full=45.745
[E]/percent full=34.595
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What is the best suited option for this? eval or regex? Any help is really appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 14:45:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201324#M58324</guid>
      <dc:creator>anoopambli</dc:creator>
      <dc:date>2016-08-01T14:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract these fields from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201325#M58325</link>
      <description>&lt;P&gt;Here's the regex for the C percent full.. This will only extract the numbers, so it will look like this.. &lt;/P&gt;

&lt;P&gt;C_Full = 45.745 &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;(?P&amp;lt;C_Full&amp;gt;(?&amp;lt;=C\]\/percent\sfull\=)\d{2}\.\d+)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Here's the regex for the E percent full &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;(?P&amp;lt;E_Full&amp;gt;(?&amp;lt;=E\]\/percent\sfull\=)\d{2}\.\d+)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 14:50:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201325#M58325</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2016-08-01T14:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract these fields from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201326#M58326</link>
      <description>&lt;P&gt;Like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex max_match=0 "File System\/(?&amp;lt;drive&amp;gt;[^,]+)" | mvexpand drive | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Aug 2016 14:51:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201326#M58326</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-01T14:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract these fields from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201327#M58327</link>
      <description>&lt;P&gt;Also, if you want to get really good with regular expressions then you should check out &lt;CODE&gt;&lt;A href="https://community.splunk.com/www.regex101.com" target="test_blank"&gt;www.regex101.com&lt;/A&gt;&lt;/CODE&gt; and play around. Once you get familiar with Lookaheads and Lookbehinds then it's pretty straight forward &lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 14:54:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201327#M58327</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2016-08-01T14:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract these fields from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201328#M58328</link>
      <description>&lt;P&gt;One note. It is rare Splunk needs &lt;STRONG&gt;lookbehind&lt;/STRONG&gt; or &lt;STRONG&gt;lookahead&lt;/STRONG&gt; of regex.  And, &lt;STRONG&gt;lookahead&lt;/STRONG&gt; and &lt;STRONG&gt;lookbhind&lt;/STRONG&gt; are more expensive in resource usage. So, if you do not need to use them, you would like to avoid using them.&lt;/P&gt;

&lt;P&gt;C_Full = 45.745&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?P&amp;lt;C_Full&amp;gt;(?&amp;lt;=C\]\/percent\sfull\=)\d{2}\.\d+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Assuming the number could be bigger than 100 &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
could be;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"C\]/percent\s+full=(?P&amp;lt;C_Full&amp;gt;\d{2,}\.\d+)" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So, &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex  "C\]/percent\s+full=(?P&amp;lt;C_Full&amp;gt;\d{2,}\.\d+)" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Aug 2016 16:59:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201328#M58328</guid>
      <dc:creator>Masa</dc:creator>
      <dc:date>2016-08-01T16:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract these fields from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201329#M58329</link>
      <description>&lt;P&gt;I am able to get C_drive and the related value correctly in a field. But how do I get E_drive also with the same rex command? I may have couple of other servers which has more drives, how do i dynamically get the drive info with a regex?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:29:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201329#M58329</guid>
      <dc:creator>anoopambli</dc:creator>
      <dc:date>2020-09-29T10:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract these fields from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201330#M58330</link>
      <description>&lt;P&gt;I'm not sure where you read this, but this is not true. Lookaheads/lookbehinds can be used if needed with little impact to search performance.. Obviously there are exceptions to this rule, such as indexing a massive amount of data in a short period of time.. So, it could potentially be an issue in some circumstances, but this case, I doubt it.. I actually posted a question about this last year &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;So in my limited experience, deploying one lookahead was unnoticeable&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/294477/will-lookaheadslookbehinds-hurt-search-performance.html"&gt;https://answers.splunk.com/answers/294477/will-lookaheadslookbehinds-hurt-search-performance.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Also, why create a regular expression to account for disk usage greater than 100%? It's not needed&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 17:41:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201330#M58330</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2016-08-01T17:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract these fields from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201331#M58331</link>
      <description>&lt;P&gt;I just tested this by creating a regular expression with a lookbehind then ran a search in verbose mode, I then inspected the job and it took 44.368 seconds. I then modified that extraction by removing the lookbehind and that same exact search took 44.329 seconds, so the lookbehind was 39ms slower which is insignificant..  &lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 17:55:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201331#M58331</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2016-08-01T17:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract these fields from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201332#M58332</link>
      <description>&lt;P&gt;You could create one field with many values or you could create many fields with one value, it's all preference. &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;1 field with many values would look like this&lt;/STRONG&gt; &lt;/P&gt;

&lt;P&gt;Where &lt;CODE&gt;Drive&lt;/CODE&gt; will be your field.. The advantages of this would be, you only have 1 field.. The disadvantages are that it could be difficult to isolate one drive when querying, such as when using &lt;CODE&gt;... | stats count by&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;Drive = [C]/percent full=45.745&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;Drive = [E]/percent full=34.595&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Many fields with 1 value would look like this&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;C_Drive&lt;/CODE&gt; = 45.745&lt;CODE&gt;&lt;BR /&gt;
&lt;/CODE&gt;D_Drive&lt;CODE&gt;= 34.595&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The advantage of this would be that it's super easy to manipulate the fields in your searching. So if you only wanted to see the drive space on a single host, your search would look like this &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=foo hostname=anoopambli C_Drive="*" OR D_Drive="*"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;So depending on what route you want to go, I can help build your regular expression. &lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 18:13:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201332#M58332</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2016-08-01T18:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract these fields from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201333#M58333</link>
      <description>&lt;P&gt;Thanks skoelpin for the info.&lt;/P&gt;

&lt;P&gt;I was talking about general regex cost, and if no need to use lookahead/lookbehind, that's better. Yes, scalability is in my concern.  Indexing performance with lookahead/lookbehind with 1MB each event. &lt;BR /&gt;
More like, why you suggest to use &lt;STRONG&gt;lookahead/lookbehind&lt;/STRONG&gt; when you do not need to use them. &lt;/P&gt;

&lt;P&gt;I'm fine with using &lt;STRONG&gt;lookahead/lookbehiind&lt;/STRONG&gt; for this specific splunk answer. That's why up up-voted this before I added my comment. My comment is just a suggestion. If you think that's wrong. That's fine with me, too.  &lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 18:44:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201333#M58333</guid>
      <dc:creator>Masa</dc:creator>
      <dc:date>2016-08-01T18:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract these fields from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201334#M58334</link>
      <description>&lt;P&gt;Wow those are big events!! &lt;/P&gt;

&lt;P&gt;Mine are 1-2 KB's each, so I could see how lookbehinds could potentially be an issue for you &lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 18:52:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201334#M58334</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2016-08-01T18:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract these fields from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201335#M58335</link>
      <description>&lt;P&gt;@anoopambli , was this able to help you? If so, could you accept the answer?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 14:44:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201335#M58335</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2016-08-02T14:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract these fields from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201336#M58336</link>
      <description>&lt;P&gt;Good call pulling out just the value!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 19:02:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-these-fields-from-my-sample-data/m-p/201336#M58336</guid>
      <dc:creator>sloshburch</dc:creator>
      <dc:date>2016-08-02T19:02:36Z</dc:date>
    </item>
  </channel>
</rss>

