<?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 merge consecutive event values from a single field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-consecutive-event-values-from-a-single-field/m-p/429948#M122931</link>
    <description>&lt;P&gt;Hi sureshmurgan,&lt;BR /&gt;
Let me understand: you have fields in different logs: in some logs you have Deployment and in other logs you have Status, you never have both the fields in the same log, is it correct?&lt;/P&gt;

&lt;P&gt;In this case, try to use two different regexes, one for each field:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?ms)Initiating task ContentDownload\s\w+\s\w+\s(?P&amp;lt;Deployment&amp;gt;ScopeId[^}]*)
^\d*-\d*-\d*\s*\d*:\d*:\d*\.\d*\s\w*\s*(?P&amp;lt;Status&amp;gt;Unable.*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you have more Status Messages, you could put in the regex the initial words in OR.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jun 2019 12:24:24 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2019-06-21T12:24:24Z</dc:date>
    <item>
      <title>How to merge consecutive event values from a single field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-consecutive-event-values-from-a-single-field/m-p/429942#M122925</link>
      <description>&lt;P&gt;This is the requirement.&lt;BR /&gt;
We are collecting a log file that has the following events (along with others)in the same field named ADSite_Membership, these two lines occurs consecutively in the same order as I have given below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Initiating task ContentDownload for CI ScopeId_B4419992-1C14-4FC6-AB4E-D7730CD14853/DeploymentType_4a3a8593-e333-4bb4-a3f9-bb1ce19cf0eb.6 (BlueDom - User Interactive) for target: , consumer: {719C1F1E-63E2-46C6-9469-E38B881EEA5A}
Unable to get locations, no need to continue with download
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am trying to extract two separate fields from the above values but its not working, Here's the rex command I am using:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|rex field=ADSite_Membership "(?ms)Initiating task ContentDownload\s\w+\s\w+\s(?P&amp;lt;Deployment&amp;gt;ScopeId.*)\sfor.*(?P&amp;lt;Status&amp;gt;Initiating content download.*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(Note: Willard value 'star'  is not showing up in some sections of the rex command above)&lt;/P&gt;

&lt;P&gt;I am intending to extract : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ScopeId_B4419992-1C14-4FC6-AB4E-D7730CD14853/DeploymentType_4a3a8593-e333-4bb4-a3f9-bb1ce19cf0eb.6 (BlueDom - User Interactive) as Deployment
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Unable to get locations, no need to continue with a download as Status.&lt;/P&gt;

&lt;P&gt;How can I do that?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 11:48:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-consecutive-event-values-from-a-single-field/m-p/429942#M122925</guid>
      <dc:creator>sureshmurgan</dc:creator>
      <dc:date>2019-06-20T11:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge consecutive event values from a single field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-consecutive-event-values-from-a-single-field/m-p/429943#M122926</link>
      <description>&lt;P&gt;Hi sureshmurgan,&lt;BR /&gt;
try this regex&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?ms)Initiating task ContentDownload\s\w+\s\w+\s(?P&amp;lt;Deployment&amp;gt;ScopeId.*)\sfor.*\}\s*(?P&amp;lt;Status&amp;gt;.*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or using the rex command &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=ADSite_Membership "(?ms)Initiating task ContentDownload\s\w+\s\w+\s(?P&amp;lt;Deployment&amp;gt;ScopeId.*)\sfor.*\}\s*(?P&amp;lt;Status&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can test it at &lt;A href="https://regex101.com/r/AUKmB6/1"&gt;https://regex101.com/r/AUKmB6/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 12:27:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-consecutive-event-values-from-a-single-field/m-p/429943#M122926</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-06-20T12:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge consecutive event values from a single field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-consecutive-event-values-from-a-single-field/m-p/429944#M122927</link>
      <description>&lt;P&gt;Hi Giuseppe,&lt;BR /&gt;
I get to see Deployment field now but Status is still blank. I have tried both rex commands you had shared.&lt;/P&gt;

&lt;P&gt;Please note there could be many events in the field and we need to stop extracting only the two consecutive lines and should not go beyond that.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 13:04:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-consecutive-event-values-from-a-single-field/m-p/429944#M122927</guid>
      <dc:creator>sureshmurgan</dc:creator>
      <dc:date>2019-06-20T13:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge consecutive event values from a single field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-consecutive-event-values-from-a-single-field/m-p/429945#M122928</link>
      <description>&lt;P&gt;Hi sureshmurgan,&lt;BR /&gt;
Let me understand: Status is always blank or sometimes?&lt;BR /&gt;
If it's always blank, please share other examples to tune your regex.&lt;/P&gt;

&lt;P&gt;If instead, it's sometimes blank and you want to extract fields only when both the fields contain values, you could put a filter after the rex command:&lt;/P&gt;

&lt;P&gt;| search Deployment=* Status=*&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 13:13:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-consecutive-event-values-from-a-single-field/m-p/429945#M122928</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-06-20T13:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge consecutive event values from a single field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-consecutive-event-values-from-a-single-field/m-p/429946#M122929</link>
      <description>&lt;P&gt;Hi Giuseppe, Status is not showing any value at all. I have given explained it further with a sample. Please have a look and let me know if you need more information. Thanks for your help with this!&lt;/P&gt;

&lt;P&gt;I am searching events with the following values in the field ADSite_Membership,&lt;/P&gt;

&lt;P&gt;ADSite_Membership="Initiating task ContentDownload for CI*" OR ADSite_Membership="Initiating Content Download*" OR ADSite_Membership="Unable to get locations*"&lt;/P&gt;

&lt;P&gt;If I pull the events as is, I get the below results,&lt;/P&gt;

&lt;P&gt;2019-06-19 12:36:15.000 UK922061    Initiating task ContentDownload for CI ScopeId_B4419992-1C14-4FC6-AB4E-D7730CD14853/DeploymentType_4a3a8593-e333-4bb4-a3f9-bb1ce19cf0eb.6 (GP4.1.11 BlueCoatDecom - User Interactive) for target: , consumer: {CA8EDD4A-6D29-4CE0-90AD-0EB22011B165}&lt;/P&gt;

&lt;P&gt;2019-06-19 12:36:15.000 UK922061    Initiating task ContentDownload for CI ScopeId_B4419992-1C14-4FC6-AB4E-D7730CD14853/DeploymentType_28ce7e7a-307a-417b-baf1-70c6bf0889d9.10 (Intel GFX driver 6th 7th 8th Apollo Gemini (EUDM - ALL)) for target: , consumer: {FE0C1DDA-725A-4FF2-9E20-D78968FAC529}&lt;/P&gt;

&lt;P&gt;2019-06-20 12:58:02.414 UK922061    Unable to get locations, no need to continue with download&lt;/P&gt;

&lt;P&gt;2019-06-20 13:07:52.000 UK922061    Initiating task ContentDownload for CI ScopeId_B4419992-1C14-4FC6-AB4E-D7730CD14853/DeploymentType_28ce7e7a-307a-417b-baf1-70c6bf0889d9.10 (Intel GFX driver 6th 7th 8th Apollo Gemini (EUDM - ALL)) for target: , consumer: {546E275F-FE56-4EA8-A37B-41508E57148D}&lt;/P&gt;

&lt;P&gt;Requirement : If you look at the third row result, I have "Unable to get locations*" .  When we find this result, I want to extract it as Status and want to extract the ScopeId_* from the previous event as Deployment.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:58:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-consecutive-event-values-from-a-single-field/m-p/429946#M122929</guid>
      <dc:creator>sureshmurgan</dc:creator>
      <dc:date>2020-09-30T00:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge consecutive event values from a single field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-consecutive-event-values-from-a-single-field/m-p/429947#M122930</link>
      <description>&lt;P&gt;Here's little more information about the query and the result and what I want.&lt;/P&gt;

&lt;P&gt;Search : &lt;BR /&gt;
ADSite_Membership="Initiating task ContentDownload for CI*" OR ADSite_Membership="Initiating Content Download*" OR ADSite_Membership="Unable to get locations*"&lt;BR /&gt;
|table _time ADSite_Membership&lt;/P&gt;

&lt;P&gt;Search Result:&lt;BR /&gt;
2019-06-19 12:36:15.000 Initiating task ContentDownload for CI ScopeId_B4419992-1C14-4FC6-AB4E-D7730CD14853/DeploymentType_4a3a8593-e333-4bb4-a3f9-bb1ce19cf0eb.6 (GP4.1.11 BlueCoatDecom - User Interactive) for target: , consumer: {CA8EDD4A-6D29-4CE0-90AD-0EB22011B165}&lt;/P&gt;

&lt;P&gt;2019-06-19 12:36:15.000 Initiating task ContentDownload for CI ScopeId_B4419992-1C14-4FC6-AB4E-D7730CD14853/DeploymentType_28ce7e7a-307a-417b-baf1-70c6bf0889d9.10 (Intel GFX driver 6th 7th 8th Apollo Gemini (EUDM - ALL)) for target: , consumer: {FE0C1DDA-725A-4FF2-9E20-D78968FAC529}&lt;/P&gt;

&lt;P&gt;2019-06-20 12:58:02.414 Unable to get locations, no need to continue with download&lt;/P&gt;

&lt;P&gt;2019-06-20 13:07:52.000 Initiating task ContentDownload for CI ScopeId_B4419992-1C14-4FC6-AB4E-D7730CD14853/DeploymentType_28ce7e7a-307a-417b-baf1-70c6bf0889d9.10 (Intel GFX driver 6th 7th 8th Apollo Gemini (EUDM - ALL)) for target: , consumer: {546E275F-FE56-4EA8-A37B-41508E57148D}&lt;/P&gt;

&lt;P&gt;Requirement : If you look at the 3rd row, it has "Unable to get locations*". When we get it in results I want to extract that as Status and also I want to extract the value from previous event "ScopeId*" as Deployment&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:58:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-consecutive-event-values-from-a-single-field/m-p/429947#M122930</guid>
      <dc:creator>sureshmurgan</dc:creator>
      <dc:date>2020-09-30T00:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge consecutive event values from a single field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-consecutive-event-values-from-a-single-field/m-p/429948#M122931</link>
      <description>&lt;P&gt;Hi sureshmurgan,&lt;BR /&gt;
Let me understand: you have fields in different logs: in some logs you have Deployment and in other logs you have Status, you never have both the fields in the same log, is it correct?&lt;/P&gt;

&lt;P&gt;In this case, try to use two different regexes, one for each field:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?ms)Initiating task ContentDownload\s\w+\s\w+\s(?P&amp;lt;Deployment&amp;gt;ScopeId[^}]*)
^\d*-\d*-\d*\s*\d*:\d*:\d*\.\d*\s\w*\s*(?P&amp;lt;Status&amp;gt;Unable.*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you have more Status Messages, you could put in the regex the initial words in OR.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2019 12:24:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-consecutive-event-values-from-a-single-field/m-p/429948#M122931</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-06-21T12:24:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge consecutive event values from a single field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-consecutive-event-values-from-a-single-field/m-p/429949#M122932</link>
      <description>&lt;P&gt;Hi sureshmurgan,&lt;BR /&gt;
try this one&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Initiating task ContentDownload\s\w+\s\w+\s(?P&amp;lt;Deployment&amp;gt;ScopeId[^}]*)\}\s+\d*-\d*-\d*\s*\d*:\d*:\d*\.\d*\s\w*\s*(?P&amp;lt;Status&amp;gt;Unable.*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can test it at &lt;A href="https://regex101.com/r/m7xR0g/1"&gt;https://regex101.com/r/m7xR0g/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2019 12:32:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-consecutive-event-values-from-a-single-field/m-p/429949#M122932</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-06-21T12:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge consecutive event values from a single field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-consecutive-event-values-from-a-single-field/m-p/429950#M122933</link>
      <description>&lt;P&gt;The only way I can think of to pull this off is to use streamstats to merge to events (since you said they are consecutive) then stats to remove duplicate events.  I noticed the example you provided was in time ascending order, but this was built assuming the results are in time descending order:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ADSite_Membership="Initiating task ContentDownload for CI*" OR ADSite_Membership="Initiating Content Download*" OR ADSite_Membership="Unable to get locations*"
| table _time ADSite_Membership
| streamstats current=f window=1 last(ADSite_Membership) as prev_ADSite_Membership `comment("Use the ADSite_Membership field from the previous event")`
| eval status=case(like(prev_ADSite_Membership, "%Unable to get locations%"),prev_ADSite_Membership,1==1,null) `comment("Identify the status events and set the status field")`
| rex field=ADSite_Membership "Initiating task ContentDownload for CI (?&amp;lt;Deployment&amp;gt;ScopeId_.*?) for target" `comment("Extract the Deployment field")`
| search Deployment=*  `comment("Drop the source status events which will not have a Deployment field defined")`
| fields - prev_ADSite_Membership  `comment("Drop prev_ADSite_Membership from the fields list")`  
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Jun 2019 23:07:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-consecutive-event-values-from-a-single-field/m-p/429950#M122933</guid>
      <dc:creator>wenthold</dc:creator>
      <dc:date>2019-06-28T23:07:21Z</dc:date>
    </item>
  </channel>
</rss>

