<?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: Multiple events - datetime field in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Multiple-events-datetime-field/m-p/430896#M75415</link>
    <description>&lt;P&gt;Hello, Thanks for this, I can get the times, but I am having trouble correlating the time from the "DOWN" event and the "UP" event. They are on separate lines in the output of search. I will check your next post,&lt;BR /&gt;
thanks&lt;/P&gt;</description>
    <pubDate>Thu, 25 Apr 2019 21:16:32 GMT</pubDate>
    <dc:creator>eholz1</dc:creator>
    <dc:date>2019-04-25T21:16:32Z</dc:date>
    <item>
      <title>Multiple events - datetime field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Multiple-events-datetime-field/m-p/430891#M75410</link>
      <description>&lt;P&gt;Hello, I am trying to find out how to calculate the duration between a device returning from&lt;BR /&gt;
a "DOWN" state. My search looks for UP/DOWN events on a per Device ID&lt;BR /&gt;
I can have multiple up/down events for a given device ID. I have a DateTime field for when the device went down, and when it came&lt;BR /&gt;
back up via Status=UP or Status=DOWN&lt;BR /&gt;
here is my search: &lt;CODE&gt;index=device_index sourcetype=device-syslog-ng DeviceID=626 | dedup DateTime&lt;/CODE&gt;&lt;BR /&gt;
this search returns two UP/DOWN events for this ID - I would like to see a duration = deviceUP-deviceDown, my date time field is&lt;BR /&gt;
2019/04/20 18:05:03, etc the device could be down for a day or two, so I need the date field there.  I have seen transaction and stats usage but cannot see how to relate the datetime for the event based on status of up/down. The _time value does not represent the actual time the device went up or down, but the time entered into splunk.. I can have multiple UP/DOWN events for one device, etc.&lt;/P&gt;

&lt;P&gt;any suggestions?&lt;BR /&gt;
Thanks so much,&lt;BR /&gt;
eholz1&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2019 22:43:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Multiple-events-datetime-field/m-p/430891#M75410</guid>
      <dc:creator>eholz1</dc:creator>
      <dc:date>2019-04-24T22:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple events - datetime field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Multiple-events-datetime-field/m-p/430892#M75411</link>
      <description>&lt;P&gt;Date time strings cannot be subtracted from each other.  You have to convert them into integers using &lt;CODE&gt;strptime&lt;/CODE&gt; first.  This will give you the down time in seconds.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval duration = strptime(deviceUP, "%Y/%m/%d %H:%M:%S") - strptime(deviceDown, "%Y/%m/%d %H:%M:%S") | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Apr 2019 13:06:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Multiple-events-datetime-field/m-p/430892#M75411</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-04-25T13:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple events - datetime field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Multiple-events-datetime-field/m-p/430893#M75412</link>
      <description>&lt;P&gt;Hello Rich,&lt;/P&gt;

&lt;P&gt;Wow, thanks for this! I do have one question: my deviceUP and my deviceDown are on separate lines in the output of the search,&lt;BR /&gt;
would I use a "where" clause to grab the UP - Down times? my initial search returns two lines (events) one for the UP, and one for the DOWN.&lt;/P&gt;

&lt;P&gt;I will do the conversion, etc.&lt;/P&gt;

&lt;P&gt;Thanks again,&lt;BR /&gt;
Eholz1,&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2019 14:28:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Multiple-events-datetime-field/m-p/430893#M75412</guid>
      <dc:creator>eholz1</dc:creator>
      <dc:date>2019-04-25T14:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple events - datetime field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Multiple-events-datetime-field/m-p/430894#M75413</link>
      <description>&lt;P&gt;another question:&lt;BR /&gt;
my search gives me 4 lines for my device, 4 events, cycling from Down to Up for the devices. I have the time via strptime formatting&lt;BR /&gt;
but I cannot see how to subtract the time from Down event from the time for UP event, Here is the search:&lt;BR /&gt;
index=cacti_index sourcetype=cacti-syslog-ng DeviceID=626 Status="UP" OR Status="DOWN" | dedup DateTime | rename DateTime as time2 | eval timeRng = strptime(time2,"%Y/%m/%d %H:%M:%S")&lt;/P&gt;

&lt;P&gt;I dedup the DateTime because for this device I has 3 up events and 2 down events&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Eholz1&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2019 19:01:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Multiple-events-datetime-field/m-p/430894#M75413</guid>
      <dc:creator>eholz1</dc:creator>
      <dc:date>2019-04-25T19:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple events - datetime field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Multiple-events-datetime-field/m-p/430895#M75414</link>
      <description>&lt;P&gt;Try &lt;CODE&gt;stats&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;... | stats latest(deviceUP) as deviceUP, latest(deviceDown) as deviceDown by DeviceID | eval duration = strptime(deviceUP, "%Y/%m/%d %H:%M:%S") - strptime(deviceDown, "%Y/%m/%d %H:%M:%S") | ...&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2019 21:11:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Multiple-events-datetime-field/m-p/430895#M75414</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-04-25T21:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple events - datetime field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Multiple-events-datetime-field/m-p/430896#M75415</link>
      <description>&lt;P&gt;Hello, Thanks for this, I can get the times, but I am having trouble correlating the time from the "DOWN" event and the "UP" event. They are on separate lines in the output of search. I will check your next post,&lt;BR /&gt;
thanks&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2019 21:16:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Multiple-events-datetime-field/m-p/430896#M75415</guid>
      <dc:creator>eholz1</dc:creator>
      <dc:date>2019-04-25T21:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple events - datetime field</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Multiple-events-datetime-field/m-p/430897#M75416</link>
      <description>&lt;P&gt;Thanks again, &lt;BR /&gt;
Here is my basic search&lt;BR /&gt;
index=cacti_index sourcetype=cacti-syslog-ng DeviceID=626  | dedup DateTime | rename DateTime as time2 | eval timeRng = strptime(time2,"%Y/%m/%d %H:%M:%S")&lt;BR /&gt;
| eval time1=if(Status="DOWN",strptime(time2,"%Y/%m/%d %H:%M:%S"),"")&lt;/P&gt;

&lt;P&gt;time1 is the time went down, timeRng (for the up device) is the time it went "UP". I am not seeing how to relate the two time values, up/down&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2019 21:29:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Multiple-events-datetime-field/m-p/430897#M75416</guid>
      <dc:creator>eholz1</dc:creator>
      <dc:date>2019-04-25T21:29:54Z</dc:date>
    </item>
  </channel>
</rss>

