<?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 create an event every second in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222364#M65393</link>
    <description>&lt;P&gt;Hello Woodcock and thanks for your reply&lt;BR /&gt;
I am using Splunk to perform analyse on multiple files that have their own time reference. Let's say that each file begin a 0s and ends at 5 minutes&lt;BR /&gt;
When I use the timechart command on one single file, It is ok, there is an event per second.&lt;/P&gt;

&lt;P&gt;With several files, I think that Splunk is sorting all the events by time;&lt;BR /&gt;
If there is no event at 2s in file1 but there is an event at 2s in file2, no new event will be created. &lt;BR /&gt;
And my goal is to have an additionnal event for each file separately.&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;</description>
    <pubDate>Tue, 10 Nov 2015 09:00:29 GMT</pubDate>
    <dc:creator>clorne</dc:creator>
    <dc:date>2015-11-10T09:00:29Z</dc:date>
    <item>
      <title>How to create an event every second</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222362#M65391</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have a set of data occurring randomly and I would like to have an event every second.&lt;BR /&gt;
I am able to get that when I work with one single file and the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; timechart cont=true span=1s values(field1) as fields2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;==&amp;gt; an event is created each second with empty fields2 when needed.&lt;/P&gt;

&lt;P&gt;When I use this search on several files, it is not working anymore; I guess that Splunk works globally on all events and not by file anymore and I want to work source by source.&lt;/P&gt;

&lt;P&gt;Then I tried to work with bucket:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;bucket _time span=1s | stats values(field1) as values(fields2) by _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;==&amp;gt; no additional event is created.&lt;/P&gt;

&lt;P&gt;At this time I have defined a custom search command to create the desired additional events, but I would like to do it with Splunk search language.&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2015 09:51:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222362#M65391</guid>
      <dc:creator>clorne</dc:creator>
      <dc:date>2015-11-09T09:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an event every second</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222363#M65392</link>
      <description>&lt;P&gt;Because &lt;CODE&gt;timechart&lt;/CODE&gt; was desgined to produce nice line charts for visualization, it produces a &lt;CODE&gt;_time&lt;/CODE&gt; (x-axis) value for every second.  As you have discovered, all &lt;CODE&gt;bucket&lt;/CODE&gt; does is round (replace) the &lt;CODE&gt;_time&lt;/CODE&gt; value for each event to the span specified; it does not create events.  You could check out &lt;CODE&gt;eventgen&lt;/CODE&gt; but it would probably be much easier to figure out why &lt;CODE&gt;timechart&lt;/CODE&gt; is not working.  Does this not work for you?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| timechart cont=true span=1s values(field1) AS fields2 BY source
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Nov 2015 14:20:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222363#M65392</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-11-09T14:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an event every second</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222364#M65393</link>
      <description>&lt;P&gt;Hello Woodcock and thanks for your reply&lt;BR /&gt;
I am using Splunk to perform analyse on multiple files that have their own time reference. Let's say that each file begin a 0s and ends at 5 minutes&lt;BR /&gt;
When I use the timechart command on one single file, It is ok, there is an event per second.&lt;/P&gt;

&lt;P&gt;With several files, I think that Splunk is sorting all the events by time;&lt;BR /&gt;
If there is no event at 2s in file1 but there is an event at 2s in file2, no new event will be created. &lt;BR /&gt;
And my goal is to have an additionnal event for each file separately.&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2015 09:00:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222364#M65393</guid>
      <dc:creator>clorne</dc:creator>
      <dc:date>2015-11-10T09:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an event every second</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222365#M65394</link>
      <description>&lt;P&gt;You might be looking for &lt;CODE&gt;makecontinuous&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;bucket _time span=1s | stats values(field1) as values(fields2) by _time | makecontinuous
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See docs &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.1/SearchReference/Makecontinuous"&gt;here&lt;/A&gt;.&lt;/P&gt;

&lt;P&gt;But I must admit I don't see why woodcock's suggestion (splitting by the field that contains info on your source file) doesn't work for you. &lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2015 11:41:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222365#M65394</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2015-11-10T11:41:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an event every second</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222366#M65395</link>
      <description>&lt;P&gt;That is exactly what my command does; did you try it?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 03:21:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222366#M65395</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-11-11T03:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an event every second</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222367#M65396</link>
      <description>&lt;P&gt;Hello Woodcock and Jeffland,&lt;BR /&gt;
Sorry for my late reply, yesterday was off in France.&lt;/P&gt;

&lt;P&gt;Well I think that both commands timechart and bucket_time are working. My issue may be somewhere else.&lt;BR /&gt;
When Splunk runs one of these functions (timechart or stats), at the beginning only the values(fields1) is display and during the "finalizing" step, the new events are displayed.&lt;BR /&gt;
Until Timechart or stats do not reach the finalizing step, I can not see my additionnal events.&lt;BR /&gt;
I think that my issue with several files is that Splunk never reach the finalizing step because there are too many new events.&lt;/P&gt;

&lt;P&gt;I have the feeling that additionnal events are created also between the different sources.&lt;BR /&gt;
If source1 has events between 01-01-2000 01:00:00  till 01-01-2000 02:00:00 and source2 has events beginning on 05-01-2000 01:00:00, till 05-01-2000 05:00:00 then events will be created every second also between  01-01-2000 02:00:00 and  05-01-2000 01:00:00 creating too much events.&lt;BR /&gt;
I need more tests on smaller files to check that.&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 08:00:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222367#M65396</guid>
      <dc:creator>clorne</dc:creator>
      <dc:date>2015-11-12T08:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an event every second</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222368#M65397</link>
      <description>&lt;P&gt;Hello again,&lt;BR /&gt;
After further test:&lt;BR /&gt;
&lt;STRONG&gt;timechart cont=true span=1s values(field1) AS fields2 BY source&lt;/STRONG&gt; =&amp;gt; with the "By source" The fields2 remains empty. Is it really possible to use a BY clause with timechart ??&lt;/P&gt;

&lt;P&gt;Otherwise  I confirm that my issue is that additionnal events are created "between" the two source. Sometimes I get an error from Slpunk sometimes, Splunkd stops and I find some exception indication in the log files.&lt;/P&gt;

&lt;P&gt;So, do you think that there is a way to perform a continuous chart without adding events after the last events and before the first event, that means break the continuity between two sources ?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 10:16:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222368#M65397</guid>
      <dc:creator>clorne</dc:creator>
      <dc:date>2015-11-12T10:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an event every second</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222369#M65398</link>
      <description>&lt;P&gt;Yes, of course events will be created: 1 for every second, for every source, regardless of whether any actually source events exist there; that's what &lt;CODE&gt;timechart&lt;/CODE&gt; does!&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 16:28:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222369#M65398</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-11-12T16:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an event every second</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222370#M65399</link>
      <description>&lt;P&gt;Hello, &lt;BR /&gt;
As a conclusion, I will keep my custom command, because I want additionnal new events per source but I don't want  the continuity between two different source.&lt;BR /&gt;
But the two command are interesting&lt;/P&gt;

&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2015 08:42:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222370#M65399</guid>
      <dc:creator>clorne</dc:creator>
      <dc:date>2015-11-13T08:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an event every second</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222371#M65400</link>
      <description>&lt;P&gt;Describe your custom command and then click "Answer" so that people can learn about your solution.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2015 15:49:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222371#M65400</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-11-13T15:49:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an event every second</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222372#M65401</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;

&lt;P&gt;Here is the code that adds events every second when necessary and do not add event when there is a change of source.&lt;BR /&gt;
There is one field names &lt;STRONG&gt;EpochRoundTime&lt;/STRONG&gt; that stores the time in an integer format.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import splunk.Intersplunk as si

current_time=0
prev_time=0
storesource=""
storeevent=[]

//read the results into a variable
(results, dummyresults, settings) = si.getOrganizedResults()


//look into the set of results to identify if it is needed to add event
for i in range(len(results)):
    current_time=int(results[i]["EpochRoundTime"])

# check if we are working on the same source or if this is a new source (file)
if(storesource != results[i]["source"]):
    prev_time=0

storesource = results[i]["source"]

#for the first event of each source, do nothing
if(prev_time!=0):
    Stationadress = results[i-1]["StationAdress"]
    #if there is the need of an additionnal event, store it in a list
    if(current_time&amp;gt;prev_time+1):
        checktime= current_time-prev_time-1
        for j in range(0,current_time-prev_time-1):
            event={"EpochRoundTime":prev_time+1+j,"StationAdress":Stationadress,"VMEDLS_raw":"FAKE", "source":results[i]["source"]}
            storeevent.append(event)

prev_time= current_time

// Here all event have been prepared to be added in the results set
for i in range(len(storeevent)):
    results.append(index, storeevent[i])

//return the results back to Splunk 
si.outputResults(results)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Nov 2015 08:53:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-event-every-second/m-p/222372#M65401</guid>
      <dc:creator>clorne</dc:creator>
      <dc:date>2015-11-16T08:53:12Z</dc:date>
    </item>
  </channel>
</rss>

