<?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 generate timely fake event and compare with real event in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-timely-fake-event-and-compare-with-real-event/m-p/497767#M138633</link>
    <description>&lt;P&gt;Hello all, how do I create a timely dummy event (without using "|lookup" external file) to compare with the real generated events to show as a chart. &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;These logs are generated every 3 hours&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;_raw event example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2017-09-04 02:07:00,630 LOG - Code for SERVICE is :1

2017-09-04 05:10:08,450 LOG - Code for SERVICE is :0

2017-09-04 11:05:44,230 LOG - Code for SERVICE is :0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And sometimes the event is not created, as the example shows the event for 08 am didn't occur, but I need to map it as well.&lt;/P&gt;

&lt;P&gt;Current search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search
| rex  "extracted event_time from _raw"
| eval Status = case(like(_raw, "%SERVICE is :0%"), "Success", like(_raw, "%SERVICE is :%"), "Failed")
| eval _time=strftime(strptime(event_time, "%Y-%m-%d %H:%M:%S"), "%Y/%m/%d %H:%M")
| chart count(Status) over _time by Status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Desired Result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  _time         Success  Failed   No Event
2017/09/04  02:07    0    1         0
2017/09/04  05:10    0    1         0
2017/09/04  08:00   0     0         1
2017/09/04  11:05    0    1         0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I did use "| timechart" but the method doesn't show the exact event time.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Thu, 03 Oct 2019 15:34:23 GMT</pubDate>
    <dc:creator>egonstep</dc:creator>
    <dc:date>2019-10-03T15:34:23Z</dc:date>
    <item>
      <title>How to generate timely fake event and compare with real event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-timely-fake-event-and-compare-with-real-event/m-p/497767#M138633</link>
      <description>&lt;P&gt;Hello all, how do I create a timely dummy event (without using "|lookup" external file) to compare with the real generated events to show as a chart. &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;These logs are generated every 3 hours&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;_raw event example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2017-09-04 02:07:00,630 LOG - Code for SERVICE is :1

2017-09-04 05:10:08,450 LOG - Code for SERVICE is :0

2017-09-04 11:05:44,230 LOG - Code for SERVICE is :0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And sometimes the event is not created, as the example shows the event for 08 am didn't occur, but I need to map it as well.&lt;/P&gt;

&lt;P&gt;Current search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search
| rex  "extracted event_time from _raw"
| eval Status = case(like(_raw, "%SERVICE is :0%"), "Success", like(_raw, "%SERVICE is :%"), "Failed")
| eval _time=strftime(strptime(event_time, "%Y-%m-%d %H:%M:%S"), "%Y/%m/%d %H:%M")
| chart count(Status) over _time by Status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Desired Result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  _time         Success  Failed   No Event
2017/09/04  02:07    0    1         0
2017/09/04  05:10    0    1         0
2017/09/04  08:00   0     0         1
2017/09/04  11:05    0    1         0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I did use "| timechart" but the method doesn't show the exact event time.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2019 15:34:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-timely-fake-event-and-compare-with-real-event/m-p/497767#M138633</guid>
      <dc:creator>egonstep</dc:creator>
      <dc:date>2019-10-03T15:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate timely fake event and compare with real event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-timely-fake-event-and-compare-with-real-event/m-p/497768#M138634</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search
 | rex  "extracted event_time from _raw"
 | eval Status = case(like(_raw, "%SERVICE is :0%"), "Success", like(_raw, "%SERVICE is :%"), "Failed")
 | eval _time=strftime(strptime(event_time, "%Y-%m-%d %H:%M:%S"), "%Y/%m/%d %H:%M")
 | timechart count(Status) by Status | addtotals
 | eval "No Event"=if(Total&amp;gt;0, 0, 1) | fields - Total
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Oct 2019 19:45:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-timely-fake-event-and-compare-with-real-event/m-p/497768#M138634</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2019-10-03T19:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate timely fake event and compare with real event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-timely-fake-event-and-compare-with-real-event/m-p/497769#M138635</link>
      <description>&lt;P&gt;Check out the &lt;CODE&gt;makecontinuous&lt;/CODE&gt; command:&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Makecontinuous"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Makecontinuous&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/625019/how-to-use-makecontinuous-in-combination-with-stat.html"&gt;https://answers.splunk.com/answers/625019/how-to-use-makecontinuous-in-combination-with-stat.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2019 02:37:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-timely-fake-event-and-compare-with-real-event/m-p/497769#M138635</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-10-04T02:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate timely fake event and compare with real event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-timely-fake-event-and-compare-with-real-event/m-p/497770#M138636</link>
      <description>&lt;P&gt;Thanks for your response, I did try to use your code but"| timechart" doesn't get the event_time date, return the counts for all as 0&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2019 14:14:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-timely-fake-event-and-compare-with-real-event/m-p/497770#M138636</guid>
      <dc:creator>egonstep</dc:creator>
      <dc:date>2019-10-04T14:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate timely fake event and compare with real event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-timely-fake-event-and-compare-with-real-event/m-p/497771#M138637</link>
      <description>&lt;P&gt;Thanks, yeah I did use the "| makecontinuous" command, but it doesn't show the exact time for the chart&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2019 14:15:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-timely-fake-event-and-compare-with-real-event/m-p/497771#M138637</guid>
      <dc:creator>egonstep</dc:creator>
      <dc:date>2019-10-04T14:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate timely fake event and compare with real event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-timely-fake-event-and-compare-with-real-event/m-p/497772#M138638</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;

&lt;P&gt;So I did some code that returns the desired result.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search
| rex "retrieve message from _raw "
| eval Time=strftime(_time,"%Y/%m/%d %H:%M:%S") 
| convert timeformat="%Y/%m/%d - %H" ctime(_time) as defaultDate
| table defaultDate Time message
| append
  [| gentimes start=08/01/17:14:00:00 increment=3h
   | convert timeformat="%Y/%m/%d - %H" ctime(starttime) as defaultDate
   | eval message="No Event"
   | table defaultDate message
        | search "base search"
        | tail 1
        | convert timeformat="%Y/%m/%d" ctime(_time) AS c_time
        | fields c_time
        | rename c_time as query] &amp;lt;= defaultDate]
| dedup defaultDate
| eval Time=if(isnull(Time), 'defaultDate', Time)
| eval Status = if(like(message, "%SERVICE is :0%"), "Success", if(like(message,"%SERVICE is :%"), "Failed", "No Event"))
| fields - defaultDate
| table Time Status
| chart count(Status) over Time by Status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The subsearch remove fake events where "earliest time from the _raw events &amp;lt;= defaultDate"&lt;/P&gt;

&lt;P&gt;Feel free to improve the query.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2019 14:46:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-timely-fake-event-and-compare-with-real-event/m-p/497772#M138638</guid>
      <dc:creator>egonstep</dc:creator>
      <dc:date>2019-10-04T14:46:41Z</dc:date>
    </item>
  </channel>
</rss>

