<?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: Help need to format output in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-need-to-format-output/m-p/283741#M175638</link>
    <description>&lt;P&gt;ehudb,&lt;/P&gt;

&lt;P&gt;It worked fine:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main sourcetype=app-gmr eventtype=start_job OR eventtype=end_job
| table _time ssnservice eventtype jobId JobExecID
| join jobId [ search index=main sourcetype=app-gmr INFO job read was already scheduled 
| rex field=_raw "\]: {} (?.*) with id (?\d+) " ] | **stats earliest(_time) as start latest(_time) as end** by JobExecID
&lt;/CODE&gt;&lt;/PRE&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/2449i383C0415EDB835B8/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;But how can I format the _time to  "readable" value?&lt;/P&gt;

&lt;P&gt;I tried:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main sourcetype=app-gmr eventtype=start_job OR eventtype=end_job
| table _time ssnservice eventtype jobId JobExecID
| join jobId [ search index=ssn sourcetype=app-gmr INFO job read was already scheduled
| rex field=_raw "\]: {} (?.*) with id (?\d+) " ]
| stats earliest(strftime(_time,"%F %H:%M:%S:%3N")) as start latest(strftime(_time,"%F %H:%M:%S:%3N")) as end by JobExecID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I got:&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/2450i74F1052E04BCE47F/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Feb 2017 22:19:33 GMT</pubDate>
    <dc:creator>GersonGarcia</dc:creator>
    <dc:date>2017-02-09T22:19:33Z</dc:date>
    <item>
      <title>Help need to format output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-need-to-format-output/m-p/283739#M175636</link>
      <description>&lt;P&gt;All,&lt;/P&gt;

&lt;P&gt;I have this search:&lt;/P&gt;

&lt;P&gt;index=main sourcetype=app-gmr eventtype=start_job OR eventtype=end_job&lt;BR /&gt;
| table _time eventtype jobId JobExecID&lt;BR /&gt;
| join jobId [ search index=main sourcetype=app-gmr INFO job read was already scheduled&lt;BR /&gt;
| rex field=_raw "]: {} (?.*) with id (?\d+) "&lt;BR /&gt;
| stats count by jobname jobId | fields - count ]&lt;/P&gt;

&lt;P&gt;It generates the following result:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://community.splunk.com/storage/temp/183208-screen-shot-2017-02-09-at-111404-am.jpg" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;I need help to format this output to have one line per JobExecId with &lt;STRONG&gt;_time&lt;/STRONG&gt; in 2 columns &lt;STRONG&gt;star&lt;/STRONG&gt; and &lt;STRONG&gt;end&lt;/STRONG&gt; in the same line&lt;/P&gt;

&lt;P&gt;Something like:&lt;/P&gt;

&lt;P&gt;Jobname jobid JobExecID start end&lt;/P&gt;

&lt;P&gt;Thank you,&lt;/P&gt;

&lt;P&gt;Gerson &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:46:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-need-to-format-output/m-p/283739#M175636</guid>
      <dc:creator>GersonGarcia</dc:creator>
      <dc:date>2020-09-29T12:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: Help need to format output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-need-to-format-output/m-p/283740#M175637</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|stats earliest(_time) as start latest(_time) as end by JobExecID 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Feb 2017 21:37:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-need-to-format-output/m-p/283740#M175637</guid>
      <dc:creator>ehudb</dc:creator>
      <dc:date>2017-02-09T21:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: Help need to format output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-need-to-format-output/m-p/283741#M175638</link>
      <description>&lt;P&gt;ehudb,&lt;/P&gt;

&lt;P&gt;It worked fine:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main sourcetype=app-gmr eventtype=start_job OR eventtype=end_job
| table _time ssnservice eventtype jobId JobExecID
| join jobId [ search index=main sourcetype=app-gmr INFO job read was already scheduled 
| rex field=_raw "\]: {} (?.*) with id (?\d+) " ] | **stats earliest(_time) as start latest(_time) as end** by JobExecID
&lt;/CODE&gt;&lt;/PRE&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/2449i383C0415EDB835B8/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;But how can I format the _time to  "readable" value?&lt;/P&gt;

&lt;P&gt;I tried:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main sourcetype=app-gmr eventtype=start_job OR eventtype=end_job
| table _time ssnservice eventtype jobId JobExecID
| join jobId [ search index=ssn sourcetype=app-gmr INFO job read was already scheduled
| rex field=_raw "\]: {} (?.*) with id (?\d+) " ]
| stats earliest(strftime(_time,"%F %H:%M:%S:%3N")) as start latest(strftime(_time,"%F %H:%M:%S:%3N")) as end by JobExecID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I got:&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/2450i74F1052E04BCE47F/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 22:19:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-need-to-format-output/m-p/283741#M175638</guid>
      <dc:creator>GersonGarcia</dc:creator>
      <dc:date>2017-02-09T22:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: Help need to format output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-need-to-format-output/m-p/283742#M175639</link>
      <description>&lt;P&gt;Formatting the time to human readable:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|convert ctime(start) |convert ctime(end)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Overall:&lt;/P&gt;

&lt;P&gt;index=main sourcetype=app-gmr eventtype=start_job OR eventtype=end_job&lt;BR /&gt;
 | table _time ssnservice eventtype jobId JobExecID&lt;BR /&gt;
 | join jobId [ search index=main sourcetype=app-gmr INFO job read was already scheduled &lt;BR /&gt;
 | rex field=_raw "]: {} (?.&lt;EM&gt;) with id (?\d+) " ] | **stats earliest(_time) as start latest(_time) as end&lt;/EM&gt;* by JobExecID&lt;BR /&gt;
    |convert ctime(start) |convert ctime(end)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:49:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-need-to-format-output/m-p/283742#M175639</guid>
      <dc:creator>ehudb</dc:creator>
      <dc:date>2020-09-29T12:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: Help need to format output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-need-to-format-output/m-p/283743#M175640</link>
      <description>&lt;P&gt;That worked, thank you very much:&lt;/P&gt;

&lt;P&gt;index=main sourcetype=app-gmr eventtype=start_job OR eventtype=end_job &lt;BR /&gt;
| table _time ssnservice eventtype jobId JobExecID &lt;BR /&gt;
| join jobId [ search index=main sourcetype=app-gmr INFO job read was already scheduled &lt;BR /&gt;
| rex field=_raw "]: {} (?.*) with id (?\d+) " ] &lt;BR /&gt;
| stats earliest(_time) as start latest(_time) as end by JobExecID &lt;BR /&gt;
|convert ctime(start) |convert ctime(end)&lt;/P&gt;

&lt;P&gt;Sorry to take advantage of you, I really appreciate your help. The output will have (obviously) the same time for &lt;STRONG&gt;start&lt;/STRONG&gt; and &lt;STRONG&gt;end&lt;/STRONG&gt; when there is no &lt;STRONG&gt;start_job&lt;/STRONG&gt; or &lt;STRONG&gt;end_job&lt;/STRONG&gt; records in the output, for example:&lt;/P&gt;

&lt;P&gt;2258760     02/09/2017 03:02:30.352     02/09/2017 03:02:30.352&lt;BR /&gt;
2258779     02/09/2017 02:59:30.369     02/09/2017 02:59:30.369 &lt;BR /&gt;
...&lt;BR /&gt;
2261282     02/09/2017 14:00:00.110     02/09/2017 14:00:00.110&lt;BR /&gt;
2261296     02/09/2017 14:05:00.070     02/09/2017 14:05:00.070&lt;/P&gt;

&lt;P&gt;Is there any way I could have NOT_STARTED or NOT_ENDED if there is no &lt;STRONG&gt;start_job&lt;/STRONG&gt; or &lt;STRONG&gt;end_job&lt;/STRONG&gt; records.&lt;/P&gt;

&lt;P&gt;This is way to advance to me and I am learning a lot.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:46:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-need-to-format-output/m-p/283743#M175640</guid>
      <dc:creator>GersonGarcia</dc:creator>
      <dc:date>2020-09-29T12:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: Help need to format output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-need-to-format-output/m-p/283744#M175641</link>
      <description>&lt;P&gt;I'm happy to help the learning process &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;There are many approaches to your question.&lt;BR /&gt;
One way of them, we can create new time fields based on the start\end type&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval starttime=if(eventtype="start_job",_time,null()),  endtime=if(eventtype="end_job",_time,null())
|stats earliest(starttime) as start lastest(endtime) as end by JobExecID
|eval job_status=case(isnull(start),"NOT_STARTED",isnull(end),"NOT_ENDED",true(),"Started-Ended")
|convert ctime(start) ctime(end)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Overall query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=main sourcetype=app-gmr eventtype=start_job OR eventtype=end_job
 | table _time ssnservice eventtype jobId JobExecID
 | join jobId [ search index=ssn sourcetype=app-gmr INFO job read was already scheduled
 | rex field=_raw "\]: {} (?.*) with id (?\d+) " ]
    |eval starttime=if(eventtype="start_job",_time,null()),  endtime=if(eventtype="end_job",_time,null())
    |stats earliest(starttime) as start lastest(endtime) as end by JobExecID
    |eval job_status=case(isnull(start),"NOT_STARTED",isnull(end),"NOT_ENDED",true(),"Started-Ended")
    |convert ctime(start) ctime(end)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Feb 2017 11:58:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-need-to-format-output/m-p/283744#M175641</guid>
      <dc:creator>ehudb</dc:creator>
      <dc:date>2017-02-10T11:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: Help need to format output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-need-to-format-output/m-p/283745#M175642</link>
      <description>&lt;P&gt;It worked, Thank you very much I really appreciate it.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 17:09:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-need-to-format-output/m-p/283745#M175642</guid>
      <dc:creator>GersonGarcia</dc:creator>
      <dc:date>2017-02-10T17:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: Help need to format output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-need-to-format-output/m-p/283746#M175643</link>
      <description>&lt;P&gt;Excellent!&lt;BR /&gt;
If that worked you can mark the answer as successful. &lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 17:15:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-need-to-format-output/m-p/283746#M175643</guid>
      <dc:creator>ehudb</dc:creator>
      <dc:date>2017-02-10T17:15:08Z</dc:date>
    </item>
  </channel>
</rss>

