<?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 How to get subset of lines from log in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-subset-of-lines-from-log/m-p/595876#M207416</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;We have requirement where we have to get the start till end log of one process and when we get the log we can see the logs of other process as well which is running in parallel. So we want to get the lines of only the process which we have to work on. The process number changes at every run.&lt;/P&gt;&lt;P&gt;Sample Log:&lt;/P&gt;&lt;P&gt;2022-02-14 02:30:00,046 [Worker-3] DEBUG User job started&lt;BR /&gt;2022-02-14 02:30:00,063 [Worker-3] DEBUG Calling importData&lt;BR /&gt;2022-02-14 02:30:00,063 [Worker-3] DEBUG Initializing External DB connection&lt;BR /&gt;2022-02-14 02:30:00,065 [Worker-2] DEBUG another process started&lt;BR /&gt;2022-02-14 02:30:00,067 [Worker-3] DEBUG url before binding&lt;BR /&gt;2022-02-14 02:30:00,082 [Worker-2] DEBUG ExistingAccount&lt;BR /&gt;2022-02-14 02:30:00,083 [Worker-2] DEBUG query is array&lt;BR /&gt;2022-02-14 02:30:00,097 [Worker-2] DEBUG Done.... assigning access for account&lt;BR /&gt;2022-02-14 02:30:00,524 [Worker-2] DEBUG closing connection&lt;BR /&gt;2022-02-14 02:30:00,547 [Worker-2] Task Complete&lt;BR /&gt;2022-02-14 02:30:00,560 [Worker-3] DEBUG inside finally...&lt;BR /&gt;2022-02-14 02:30:00,567 [Worker-3] DEBUG sending Notification Email&lt;BR /&gt;2022-02-14 02:30:00,567 [Worker-3] DEBUG User job ended&lt;/P&gt;&lt;P&gt;we have used below search to get above log :&lt;/P&gt;&lt;P&gt;index=test sourcetype=debugLog | transaction startswith="User job started" endswith="User job ended"&lt;/P&gt;&lt;P&gt;we want the output as below. So how we can add extra logic to above search to get below output?&lt;/P&gt;&lt;P&gt;2022-02-14 02:30:00,046 [Worker-3] DEBUG User job started&lt;BR /&gt;2022-02-14 02:30:00,063 [Worker-3] DEBUG Calling importData&lt;BR /&gt;2022-02-14 02:30:00,063 [Worker-3] DEBUG Initializing External DB connection&lt;BR /&gt;2022-02-14 02:30:00,067 [Worker-3] DEBUG url before binding&lt;BR /&gt;2022-02-14 02:30:00,560 [Worker-3] DEBUG inside finally...&lt;BR /&gt;2022-02-14 02:30:00,567 [Worker-3] DEBUG sending Notification Email&lt;BR /&gt;2022-02-14 02:30:00,567 [Worker-3] DEBUG User job ended&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 29 Apr 2022 05:46:17 GMT</pubDate>
    <dc:creator>Splunklearning2</dc:creator>
    <dc:date>2022-04-29T05:46:17Z</dc:date>
    <item>
      <title>How to get subset of lines from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-subset-of-lines-from-log/m-p/595876#M207416</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;We have requirement where we have to get the start till end log of one process and when we get the log we can see the logs of other process as well which is running in parallel. So we want to get the lines of only the process which we have to work on. The process number changes at every run.&lt;/P&gt;&lt;P&gt;Sample Log:&lt;/P&gt;&lt;P&gt;2022-02-14 02:30:00,046 [Worker-3] DEBUG User job started&lt;BR /&gt;2022-02-14 02:30:00,063 [Worker-3] DEBUG Calling importData&lt;BR /&gt;2022-02-14 02:30:00,063 [Worker-3] DEBUG Initializing External DB connection&lt;BR /&gt;2022-02-14 02:30:00,065 [Worker-2] DEBUG another process started&lt;BR /&gt;2022-02-14 02:30:00,067 [Worker-3] DEBUG url before binding&lt;BR /&gt;2022-02-14 02:30:00,082 [Worker-2] DEBUG ExistingAccount&lt;BR /&gt;2022-02-14 02:30:00,083 [Worker-2] DEBUG query is array&lt;BR /&gt;2022-02-14 02:30:00,097 [Worker-2] DEBUG Done.... assigning access for account&lt;BR /&gt;2022-02-14 02:30:00,524 [Worker-2] DEBUG closing connection&lt;BR /&gt;2022-02-14 02:30:00,547 [Worker-2] Task Complete&lt;BR /&gt;2022-02-14 02:30:00,560 [Worker-3] DEBUG inside finally...&lt;BR /&gt;2022-02-14 02:30:00,567 [Worker-3] DEBUG sending Notification Email&lt;BR /&gt;2022-02-14 02:30:00,567 [Worker-3] DEBUG User job ended&lt;/P&gt;&lt;P&gt;we have used below search to get above log :&lt;/P&gt;&lt;P&gt;index=test sourcetype=debugLog | transaction startswith="User job started" endswith="User job ended"&lt;/P&gt;&lt;P&gt;we want the output as below. So how we can add extra logic to above search to get below output?&lt;/P&gt;&lt;P&gt;2022-02-14 02:30:00,046 [Worker-3] DEBUG User job started&lt;BR /&gt;2022-02-14 02:30:00,063 [Worker-3] DEBUG Calling importData&lt;BR /&gt;2022-02-14 02:30:00,063 [Worker-3] DEBUG Initializing External DB connection&lt;BR /&gt;2022-02-14 02:30:00,067 [Worker-3] DEBUG url before binding&lt;BR /&gt;2022-02-14 02:30:00,560 [Worker-3] DEBUG inside finally...&lt;BR /&gt;2022-02-14 02:30:00,567 [Worker-3] DEBUG sending Notification Email&lt;BR /&gt;2022-02-14 02:30:00,567 [Worker-3] DEBUG User job ended&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 05:46:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-subset-of-lines-from-log/m-p/595876#M207416</guid>
      <dc:creator>Splunklearning2</dc:creator>
      <dc:date>2022-04-29T05:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to get subset of lines from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-subset-of-lines-from-log/m-p/595879#M207417</link>
      <description>&lt;P&gt;If I understand correctly, in your example you would want to have only the lines from Worker-3 without the lines from Worker-2, right?&lt;/P&gt;&lt;P&gt;You need to extract this field and use it in your transaction command to distinguish separate worker runs.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 05:52:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-subset-of-lines-from-log/m-p/595879#M207417</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-04-29T05:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to get subset of lines from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-subset-of-lines-from-log/m-p/595880#M207418</link>
      <description>&lt;P&gt;Yes your understanding is correct. but the process number will be different everytime. Any sample command will be very helpful.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 05:54:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-subset-of-lines-from-log/m-p/595880#M207418</guid>
      <dc:creator>Splunklearning2</dc:creator>
      <dc:date>2022-04-29T05:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to get subset of lines from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-subset-of-lines-from-log/m-p/595884#M207421</link>
      <description>&lt;P&gt;Ideally, parsing and field extraction should have been done as part of data onboarding so you should have the field "ready to use". But let's assume it hadn't been done.&lt;/P&gt;&lt;P&gt;So you have to parse the field from the event on your own. Assuming that the process name is always "worker-X", you can use&lt;/P&gt;&lt;PRE&gt;index=test sourcetype=debugLog&lt;BR /&gt;| rex "\[worker-(?&amp;lt;workerID&amp;gt;\d+)\]"&lt;BR /&gt;transaction workerID startswith="User job started" endswith="User job ended"&lt;/PRE&gt;&lt;P&gt;You can, alternatively, parse out anything that's between the brackets and use that value. Like&lt;/P&gt;&lt;PRE&gt;index=test sourcetype=debugLog&lt;BR /&gt;| rex "\[(?&amp;lt;ProcessID+)\]"&lt;BR /&gt;transaction ProcessID startswith="User job started" endswith="User job ended"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 06:33:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-subset-of-lines-from-log/m-p/595884#M207421</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-04-29T06:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to get subset of lines from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-subset-of-lines-from-log/m-p/595901#M207431</link>
      <description>&lt;P&gt;I tried both the command but didn't worked.&lt;/P&gt;&lt;PRE&gt;index=test sourcetype=debugLog&lt;BR /&gt;| rex "\[worker-(?&amp;lt;workerID&amp;gt;\d+)\]"&lt;BR /&gt;transaction workerID startswith="User job started" endswith="User job ended"&lt;/PRE&gt;&lt;P&gt;in this I have to add | before transaction else it was failing. When I added | and ran the command it's giving 0 event. Can you explain what this command will do?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Other command is failing with REX error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 07:32:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-subset-of-lines-from-log/m-p/595901#M207431</guid>
      <dc:creator>Splunklearning2</dc:creator>
      <dc:date>2022-04-29T07:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to get subset of lines from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-subset-of-lines-from-log/m-p/595939#M207442</link>
      <description>&lt;P&gt;OK. I missed the pipe sign before the second line.&lt;/P&gt;&lt;PRE&gt;index=test sourcetype=debugLog&lt;BR /&gt;| rex "\[Worker-(?&amp;lt;workerID&amp;gt;\d+)\]"&lt;BR /&gt;| transaction workerID startswith="User job started" endswith="User job ended"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 12:47:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-subset-of-lines-from-log/m-p/595939#M207442</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-04-29T12:47:27Z</dc:date>
    </item>
  </channel>
</rss>

