<?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 server name, HealthState, and HoggingTrheadCount from txt file in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-server-name-HealthState-and-HoggingTrheadCount-from-txt/m-p/374856#M169671</link>
    <description>&lt;P&gt;I am hoping something like&lt;/P&gt;

&lt;P&gt;Server                   HealthState           ThreadCount&lt;BR /&gt;
coreServer1         Health_OK             0&lt;BR /&gt;
coreServer2         Health_OK             0&lt;/P&gt;

&lt;P&gt;If that is possible.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 19:21:01 GMT</pubDate>
    <dc:creator>wilcoxj</dc:creator>
    <dc:date>2020-09-29T19:21:01Z</dc:date>
    <item>
      <title>Extract server name, HealthState, and HoggingTrheadCount from txt file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-server-name-HealthState-and-HoggingTrheadCount-from-txt/m-p/374854#M169669</link>
      <description>&lt;P&gt;I was thinking that I could do a rex to grab everything up to the newline but I am trying to categorize the below output into three fields.&lt;BR /&gt;
Server, Health, and ThreadCount.  I think a rex would do it but I am still new at writing rex/regex.  Please assist or direct me to what I should try.&lt;/P&gt;

&lt;P&gt;Date = "03-May-2018 07:04:31 -0400"&lt;BR /&gt;
From = ""&lt;BR /&gt;
To = ", "&lt;BR /&gt;
Subject = "Daily Server Health Report"&lt;BR /&gt;
CC = ""&lt;BR /&gt;
mailbox = "INBOX"&lt;BR /&gt;
size = 51929&lt;BR /&gt;
____________________  Message Body  ____________________&lt;BR /&gt;
coreServer1&lt;BR /&gt;
   HealthState                                  HEALTH_OK&lt;BR /&gt;
   HoggingThreadCount                           0&lt;BR /&gt;
coreServer2&lt;BR /&gt;
   HealthState                                  HEALTH_OK&lt;BR /&gt;
   HoggingThreadCount                           0&lt;BR /&gt;
coreServer3&lt;BR /&gt;
   HealthState                                  HEALTH_WARN,[ThreadPool has stuck threads]&lt;BR /&gt;
   HoggingThreadCount                           1&lt;BR /&gt;
fsServer1&lt;BR /&gt;
   HealthState                                  HEALTH_OK&lt;BR /&gt;
   HoggingThreadCount                           0&lt;BR /&gt;
fsServer2&lt;BR /&gt;
   HealthState                                  HEALTH_OK&lt;BR /&gt;
   HoggingThreadCount                           0&lt;BR /&gt;
fsServer3&lt;BR /&gt;
   HealthState                                  HEALTH_OK&lt;BR /&gt;
   HoggingThreadCount                           0&lt;BR /&gt;
genServer1&lt;BR /&gt;
   HealthState                                  HEALTH_OK&lt;BR /&gt;
   HoggingThreadCount                           0&lt;BR /&gt;
genServer2&lt;BR /&gt;
   HealthState                                  HEALTH_OK&lt;BR /&gt;
   HoggingThreadCount                           0&lt;BR /&gt;
ociServer1&lt;BR /&gt;
   HealthState                                  HEALTH_OK&lt;BR /&gt;
   HoggingThreadCount                           0&lt;BR /&gt;
ociServer2&lt;BR /&gt;
   HealthState                                  HEALTH_OK&lt;BR /&gt;
   HoggingThreadCount                           0&lt;BR /&gt;
ociServer3&lt;BR /&gt;
   HealthState                                  HEALTH_OK&lt;BR /&gt;
   HoggingThreadCount                           0&lt;BR /&gt;
sourceServer1&lt;BR /&gt;
   HealthState                                  HEALTH_OK&lt;BR /&gt;
   HoggingThreadCount                           0&lt;BR /&gt;
sourceServer2&lt;BR /&gt;
   HealthState                                  HEALTH_OK&lt;BR /&gt;
   HoggingThreadCount                           0 &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:20:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-server-name-HealthState-and-HoggingTrheadCount-from-txt/m-p/374854#M169669</guid>
      <dc:creator>wilcoxj</dc:creator>
      <dc:date>2020-09-29T19:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: Extract server name, HealthState, and HoggingTrheadCount from txt file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-server-name-HealthState-and-HoggingTrheadCount-from-txt/m-p/374855#M169670</link>
      <description>&lt;P&gt;Do you want to keep those in a single event?&lt;BR /&gt;
If you do field extraction, you might get a field "servername", but it would contain multiple values, e.g. (fsServer1, ociServer2, etc).&lt;BR /&gt;
Can you show us how you would like your result to look like?&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 15:17:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-server-name-HealthState-and-HoggingTrheadCount-from-txt/m-p/374855#M169670</guid>
      <dc:creator>xpac</dc:creator>
      <dc:date>2018-05-03T15:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: Extract server name, HealthState, and HoggingTrheadCount from txt file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-server-name-HealthState-and-HoggingTrheadCount-from-txt/m-p/374856#M169671</link>
      <description>&lt;P&gt;I am hoping something like&lt;/P&gt;

&lt;P&gt;Server                   HealthState           ThreadCount&lt;BR /&gt;
coreServer1         Health_OK             0&lt;BR /&gt;
coreServer2         Health_OK             0&lt;/P&gt;

&lt;P&gt;If that is possible.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:21:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-server-name-HealthState-and-HoggingTrheadCount-from-txt/m-p/374856#M169671</guid>
      <dc:creator>wilcoxj</dc:creator>
      <dc:date>2020-09-29T19:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: Extract server name, HealthState, and HoggingTrheadCount from txt file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-server-name-HealthState-and-HoggingTrheadCount-from-txt/m-p/374857#M169672</link>
      <description>&lt;P&gt;Hi @wilcoxj&lt;/P&gt;

&lt;P&gt;Please see this Regex &amp;amp; also i think you need to break this event properly into mutiple events.&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/4881iB5B4D579376F5F08/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;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 17:49:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-server-name-HealthState-and-HoggingTrheadCount-from-txt/m-p/374857#M169672</guid>
      <dc:creator>PowerPacked</dc:creator>
      <dc:date>2018-05-03T17:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: Extract server name, HealthState, and HoggingTrheadCount from txt file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-server-name-HealthState-and-HoggingTrheadCount-from-txt/m-p/374858#M169673</link>
      <description>&lt;P&gt;You could break your mail into multiple events, as @PowerPacked suggested. Alternatively, you could do do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval test="Date = '03-May-2018 07:04:31 -0400'
From = ''
To = ', '
Subject = 'Daily Server Health Report'
CC = ''
mailbox = 'INBOX'
size = 51929
Message Body 
coreServer1
HealthState HEALTH_OK
HoggingThreadCount 0
coreServer2
HealthState HEALTH_OK
HoggingThreadCount 0
coreServer3
HealthState HEALTH_WARN,[ThreadPool has stuck threads]
HoggingThreadCount 1
fsServer1
HealthState HEALTH_OK
HoggingThreadCount 0
fsServer2
HealthState HEALTH_OK
HoggingThreadCount 0
fsServer3
HealthState HEALTH_OK
HoggingThreadCount 0
genServer1
HealthState HEALTH_OK
HoggingThreadCount 0
genServer2
HealthState HEALTH_OK
HoggingThreadCount 0
ociServer1
HealthState HEALTH_OK
HoggingThreadCount 0
ociServer2
HealthState HEALTH_OK
HoggingThreadCount 0
ociServer3
HealthState HEALTH_OK
HoggingThreadCount 0
sourceServer1
HealthState HEALTH_OK
HoggingThreadCount 0
sourceServer2
HealthState HEALTH_OK
HoggingThreadCount 0"
| rex max_match=0 field=test "(?&amp;lt;allevents&amp;gt;\S+\nHealthState\s+\S+\nHoggingThreadCount\s+\d+)"
| fields _time allevents
| mvexpand allevents
| rex field=allevents "^(?&amp;lt;Server&amp;gt;.*?)\s+HealthState\s+(?&amp;lt;HealthState&amp;gt;.*?)\s+HoggingThreadCount\s+(?&amp;lt;ThreadCount&amp;gt;.*?)$"
| table _time Server HealthState ThreadCount
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope that helps - if it does I'd be happy if you would upvote/accept this answer, so others could profit from it. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 17:54:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-server-name-HealthState-and-HoggingTrheadCount-from-txt/m-p/374858#M169673</guid>
      <dc:creator>xpac</dc:creator>
      <dc:date>2018-05-03T17:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: Extract server name, HealthState, and HoggingTrheadCount from txt file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-server-name-HealthState-and-HoggingTrheadCount-from-txt/m-p/374859#M169674</link>
      <description>&lt;P&gt;How would I break up an IMAP message into multiple records?  Would I have to create a custom props.conf or transforms.conf?&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 19:38:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-server-name-HealthState-and-HoggingTrheadCount-from-txt/m-p/374859#M169674</guid>
      <dc:creator>wilcoxj</dc:creator>
      <dc:date>2018-05-03T19:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extract server name, HealthState, and HoggingTrheadCount from txt file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-server-name-HealthState-and-HoggingTrheadCount-from-txt/m-p/374860#M169675</link>
      <description>&lt;P&gt;Yes, exactly.&lt;BR /&gt;
You could put this in a custom &lt;CODE&gt;props.conf&lt;/CODE&gt;:&lt;/P&gt;

&lt;P&gt;[yoursourcetype]&lt;BR /&gt;
LINE_BREAKER = ((?:Body\s*)|(?:HoggingThreadCount \d+))([\r\n]+)&lt;/P&gt;

&lt;P&gt;You can see it work here:&lt;BR /&gt;
&lt;A href="https://regex101.com/r/iygoQ2/3"&gt;https://regex101.com/r/iygoQ2/3&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I've inserted empty lines and ##### where the events would get broken.&lt;/P&gt;

&lt;P&gt;You must however be aware of the following:&lt;BR /&gt;
- The part before your first data (the mail headers) would be a single event on it's own, you would have to either live with that or build another props entry to drop it&lt;BR /&gt;
- This will be done to all your data from the same sourcetype&lt;BR /&gt;
- You will loose the data from the header, especially the timestamp&lt;/P&gt;

&lt;P&gt;Depending on the requirements, you might be better off with one or the other solution.&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 19:51:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-server-name-HealthState-and-HoggingTrheadCount-from-txt/m-p/374860#M169675</guid>
      <dc:creator>xpac</dc:creator>
      <dc:date>2018-05-03T19:51:41Z</dc:date>
    </item>
  </channel>
</rss>

