<?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: My two individual searches are working, but why am I unable to combine all extracted fields using append, appendcols, or join? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271736#M81802</link>
    <description>&lt;P&gt;Yes.&lt;BR /&gt;
Extract it as JobStartorEnd and then use CASE statement&lt;/P&gt;

&lt;P&gt;| eval status = CASE(like(JobStartorEnd,"%Starting%"),"Start",1==1,"Ending")&lt;/P&gt;</description>
    <pubDate>Tue, 13 Dec 2016 01:16:22 GMT</pubDate>
    <dc:creator>nabeel652</dc:creator>
    <dc:date>2016-12-13T01:16:22Z</dc:date>
    <item>
      <title>My two individual searches are working, but why am I unable to combine all extracted fields using append, appendcols, or join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271729#M81795</link>
      <description>&lt;P&gt;I have 2 jobs running daily (DailyDayJob, DailyNightJob) that logs to a common file.&lt;BR /&gt;
The logs are as given below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2016-12-09 03:21:19 INFO  DailyDayJob:39 Starting day job before purge
2016-12-09 03:28:10 INFO  DailyDayJob:41 Daily day job completed

2016-12-09 23:21:19 INFO  DailyNightJob:49 Starting night job before purge
2016-12-09 23:27:19 INFO  DailyNightJob:51 Daily night job completed
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want the output in the following format:&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/2223i2F1C7C479B18D9B3/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;BR /&gt;
The individual queries are working,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="*Batch_Logs*" "*Starting*" 
| rex field=_raw "(?P&amp;lt;startDate&amp;gt;\d{4}\-\d{2}\-\d{2})\s(?P&amp;lt;startTime&amp;gt;\d{2}\:\d{2}\:\d{2})(?P&amp;lt;batchJobDescription&amp;gt;.*)" 

source="*Batch_Logs*" "*completed*" 
    | rex field=_raw "(?P&amp;lt;endDate&amp;gt;\d{4}\-\d{2}\-\d{2})\s(?P&amp;lt;endTime&amp;gt;\d{2}\:\d{2}\:\d{2})(?P&amp;lt;batchJobDescription&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;When I try append/appendcols/join, Only startDate and startTime gets extracted. endDate,endTime do not get extracted, nor am I able to see events with 'completed'&lt;/STRONG&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="*Batch_Logs*" "*Starting*"  | rex field=_raw "(?P&amp;lt;startDate&amp;gt;\d{4}\-\d{2}\-\d{2})\s(?P&amp;lt;startTime&amp;gt;\d{2}\:\d{2}\:\d{2})(?P&amp;lt;batchJobDescription&amp;gt;.*)" | append 
    [search source="*Batch_Logs*" "*completed*" 
    | rex field=_raw "(?P&amp;lt;endDate&amp;gt;\d{4}\-\d{2}\-\d{2})\s(?P&amp;lt;endTime&amp;gt;\d{2}\:\d{2}\:\d{2})(?P&amp;lt;batchJobDescription&amp;gt;.*)"]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What am I doing wrong? Please tell me the correct query to get the format in the table, and also to calculate duration.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2016 22:04:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271729#M81795</guid>
      <dc:creator>namrithadeepak</dc:creator>
      <dc:date>2016-12-12T22:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: My two individual searches are working, but why am I unable to combine all extracted fields using append, appendcols, or join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271730#M81796</link>
      <description>&lt;P&gt;Hi &lt;BR /&gt;
Your queries don't show where "Date" and "Job Name" columns are coming from. It looks like the best way would be to use transaction command if you have something like JobID. It would automatically calculate duration.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2016 22:39:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271730#M81796</guid>
      <dc:creator>nabeel652</dc:creator>
      <dc:date>2016-12-12T22:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: My two individual searches are working, but why am I unable to combine all extracted fields using append, appendcols, or join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271731#M81797</link>
      <description>&lt;P&gt;Use this for transactions. this regex is created from your data. Will show jobs starting and completing status and duration. You can easily modify the output using transformation commands. Cheers &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="data.log"  |  rex field=_raw "(?\d{4}-\d{2}-\d{2})\s+(?\d{2}:\d{2}:\d{2})\s+INFO\s+(?\w+):(?\d+)\s.*(?(Starting|completed))" | transaction JobID keeporphans=true | table JobDate JobTime JobType JobStartOrEnd duration
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Dec 2016 23:14:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271731#M81797</guid>
      <dc:creator>nabeel652</dc:creator>
      <dc:date>2016-12-12T23:14:27Z</dc:date>
    </item>
    <item>
      <title>Re: My two individual searches are working, but why am I unable to combine all extracted fields using append, appendcols, or join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271732#M81798</link>
      <description>&lt;P&gt;Don't know why the fieldnames are being removed from the query. However, you can add the fieldnames in the regex yourself.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2016 23:54:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271732#M81798</guid>
      <dc:creator>nabeel652</dc:creator>
      <dc:date>2016-12-12T23:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: My two individual searches are working, but why am I unable to combine all extracted fields using append, appendcols, or join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271733#M81799</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="*Batch_Logs*" "*Starting*" OR "*completed*"
| rex "^(?&amp;lt;timestamp&amp;gt;\d{4}-\d{2}-\d{3}\s\d{2}:\d{2}:\d{2})\s\w+\s+(?&amp;lt;JobName&amp;gt;[^:]+)"
| eval action=if(searchmatch("*Starting*"),"start","end")
| eval Datejob=strftime(_time,"%m/%d/%Y")." ".JobName
| chart values(timestamp) over Datejob by action
| rex field=Datejob "(?&amp;lt;Date&amp;gt;\S+)\s(?&amp;lt;JobName&amp;gt;.+)"
| rex field=start "(?&amp;lt;startDate&amp;gt;\S+)\s(?&amp;lt;startTime&amp;gt;.+)"
| rex field=end "(?&amp;lt;endDate&amp;gt;\S+)\s(?&amp;lt;endTime&amp;gt;.+)"
| eval Duration=strptime(end,"%Y-%m-%d %H:%M:%S")-strptime(start,"%Y-%m-%d %H:%M:%S")
| talbe Date JobName startDate startTime endDate endTime Duration
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Dec 2016 00:32:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271733#M81799</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-12-13T00:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: My two individual searches are working, but why am I unable to combine all extracted fields using append, appendcols, or join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271734#M81800</link>
      <description>&lt;P&gt;Thankyou very much.&lt;/P&gt;

&lt;P&gt;I would prefer to have two separate fields, startTime and endTime (in the place of JobStartorEnd).&lt;BR /&gt;
Is there anyway of doing that?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2016 01:01:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271734#M81800</guid>
      <dc:creator>namrithadeepak</dc:creator>
      <dc:date>2016-12-13T01:01:32Z</dc:date>
    </item>
    <item>
      <title>Re: My two individual searches are working, but why am I unable to combine all extracted fields using append, appendcols, or join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271735#M81801</link>
      <description>&lt;P&gt;Thankyou for the response.&lt;/P&gt;

&lt;P&gt;Is there anyway of having two separate searches? I will be handing over the dashboard code to another team with no transition, and it will be easier to maintain if the search queries are separate.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2016 01:03:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271735#M81801</guid>
      <dc:creator>namrithadeepak</dc:creator>
      <dc:date>2016-12-13T01:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: My two individual searches are working, but why am I unable to combine all extracted fields using append, appendcols, or join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271736#M81802</link>
      <description>&lt;P&gt;Yes.&lt;BR /&gt;
Extract it as JobStartorEnd and then use CASE statement&lt;/P&gt;

&lt;P&gt;| eval status = CASE(like(JobStartorEnd,"%Starting%"),"Start",1==1,"Ending")&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2016 01:16:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271736#M81802</guid>
      <dc:creator>nabeel652</dc:creator>
      <dc:date>2016-12-13T01:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: My two individual searches are working, but why am I unable to combine all extracted fields using append, appendcols, or join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271737#M81803</link>
      <description>&lt;P&gt;You can use the same query with different base search to get data for different jobs.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; source="*Batch_Logs*" "*Starting*" OR "*completed*" "*DailyDayJob*" | ..rest of the search
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; source="*Batch_Logs*" "*Starting*" OR "*completed*" "*DailyNightJob*" | ..rest of the search
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Dec 2016 01:18:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271737#M81803</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-12-13T01:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: My two individual searches are working, but why am I unable to combine all extracted fields using append, appendcols, or join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271738#M81804</link>
      <description>&lt;P&gt;However, if you go with the regex I provided you don't need to: This is the output:&lt;/P&gt;

&lt;P&gt;JobDate        JobTime      JobType        JobStartOrEnd&lt;BR /&gt;
12/12/2016  3:21:19    DailyDayJob     Starting&lt;BR /&gt;
9/12/2016   23:27:19       DailyNightJob      completed&lt;BR /&gt;
9/12/2016   23:21:19       DailyNightJob      Starting&lt;BR /&gt;
9/12/2016   3:28:10    DailyDayJob    completed&lt;BR /&gt;
9/12/2016   3:21:19    DailyDayJob    Starting&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2016 01:26:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/My-two-individual-searches-are-working-but-why-am-I-unable-to/m-p/271738#M81804</guid>
      <dc:creator>nabeel652</dc:creator>
      <dc:date>2016-12-13T01:26:05Z</dc:date>
    </item>
  </channel>
</rss>

