<?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 use events only from 'active' host? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-events-only-from-active-host/m-p/527050#M148771</link>
    <description>&lt;LI-CODE lang="markup"&gt;| makeresults | eval events="2020-10-07 11:13:29.283	app1	IDLE	 	 
2020-10-07 11:28:09.284	app1	IDLE	 	 
2020-10-07 11:51:17.138	app2	IDLE	 	 
2020-10-08 01:55:27.816	app1	 		app2	standby
2020-10-08 01:55:40.591	app2	 		app1	active
2020-10-08 13:37:01.284	app1	IDLE	 	 
2020-10-09 12:11:13.786	app2	IDLE	 	 
2020-10-12 09:01:49.119	app1	 		app2	active
2020-10-12 09:12:30.444	app2	 		app1	standby
2020-10-12 10:43:59.461	app2	IDLE	 	 
2020-10-12 10:57:41.298	app1	IDLE	 	 "
| rex field=events max_match=0 "(?&amp;lt;event&amp;gt;.+)[\r\n]*"
| mvexpand event
| fields - events
| rex field=event mode=sed "s/\t/,/g s/,,/,/g"
| rex field=event "(?&amp;lt;time&amp;gt;[^,]+),(?&amp;lt;host&amp;gt;[^,]+),(?&amp;lt;prev&amp;gt;[^,]+),(?&amp;lt;server&amp;gt;[^,]+),(?&amp;lt;server_state&amp;gt;.*)"
| fields - event _time
| eval _time=strptime(time,"%Y-%m-%d %H:%M:%S.%Q")
| fields - time
| eval active_server=if(server_state="active",server,null)
| eval active_state=if(server_state="active",server_state,null)
| streamstats latest(active_server) as active_server latest(active_state) as active_state
| eval server=if(prev="IDLE",active_server,server)
| eval server_state=if(prev="IDLE",active_state,server_state)
| fields - active_server active_state&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 29 Oct 2020 10:15:43 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2020-10-29T10:15:43Z</dc:date>
    <item>
      <title>How to use events only from 'active' host?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-events-only-from-active-host/m-p/527001#M148749</link>
      <description>&lt;P&gt;I have 2 different data set:&lt;/P&gt;&lt;P&gt;1. host and prevStatus field with IDLE value&lt;/P&gt;&lt;P&gt;2. server (same values as host) and server state with active/standby values.&lt;/P&gt;&lt;P&gt;I would like to use prevStatus events ONLY from the active server.&amp;nbsp; My base search is something like&lt;/P&gt;&lt;P&gt;index=indx (host=app1 OR host app2) (prevStatus=IDLE OR (server_state=active OR server_state=standby))&lt;BR /&gt;&lt;BR /&gt;How do I mark all the prevStatus events so, that they have the current server_state field on them, so that I can then just filter&lt;/P&gt;&lt;P&gt;prevStatus=IDLE AND host=server AND server_state=active?&lt;/P&gt;&lt;P&gt;I think I need to use streamstats, but I did not quite get it there.&lt;/P&gt;&lt;P&gt;Example data table below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;_time			host	prevStatus	server	server_state
2020-10-07 11:13:29.283	app1	IDLE	 	 
2020-10-07 11:28:09.284	app1	IDLE	 	 
2020-10-07 11:51:17.138	app2	IDLE	 	 
2020-10-08 01:55:27.816	app1	 		app2	standby
2020-10-08 01:55:40.591	app2	 		app1	active
2020-10-08 13:37:01.284	app1	IDLE	 	 
2020-10-09 12:11:13.786	app2	IDLE	 	 
2020-10-12 09:01:49.119	app1	 		app2	active
2020-10-12 09:12:30.444	app2	 		app1	standby
2020-10-12 10:43:59.461	app2	IDLE	 	 
2020-10-12 10:57:41.298	app1	IDLE&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I need something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;_time			host	prevStatus	server	server_state
2020-10-07 11:13:29.283	app1	IDLE	 	 
2020-10-07 11:28:09.284	app1	IDLE	 	 
2020-10-07 11:51:17.138	app2	IDLE	 	 
2020-10-08 01:55:27.816	app1	 		app2	standby
2020-10-08 01:55:40.591	app2	 		app1	active
2020-10-08 13:37:01.284	app1	IDLE	 	app1	active 
2020-10-09 12:11:13.786	app2	IDLE	 	app1	active
2020-10-12 09:01:49.119	app1	 		app2	active
2020-10-12 09:12:30.444	app2	 		app1	standby
2020-10-12 10:43:59.461	app2	IDLE	 	app2	active
2020-10-12 10:57:41.298	app1	IDLE	 	app2	active&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 29 Oct 2020 06:04:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-events-only-from-active-host/m-p/527001#M148749</guid>
      <dc:creator>JykkeDaMan</dc:creator>
      <dc:date>2020-10-29T06:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to use events only from 'active' host?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-events-only-from-active-host/m-p/527050#M148771</link>
      <description>&lt;LI-CODE lang="markup"&gt;| makeresults | eval events="2020-10-07 11:13:29.283	app1	IDLE	 	 
2020-10-07 11:28:09.284	app1	IDLE	 	 
2020-10-07 11:51:17.138	app2	IDLE	 	 
2020-10-08 01:55:27.816	app1	 		app2	standby
2020-10-08 01:55:40.591	app2	 		app1	active
2020-10-08 13:37:01.284	app1	IDLE	 	 
2020-10-09 12:11:13.786	app2	IDLE	 	 
2020-10-12 09:01:49.119	app1	 		app2	active
2020-10-12 09:12:30.444	app2	 		app1	standby
2020-10-12 10:43:59.461	app2	IDLE	 	 
2020-10-12 10:57:41.298	app1	IDLE	 	 "
| rex field=events max_match=0 "(?&amp;lt;event&amp;gt;.+)[\r\n]*"
| mvexpand event
| fields - events
| rex field=event mode=sed "s/\t/,/g s/,,/,/g"
| rex field=event "(?&amp;lt;time&amp;gt;[^,]+),(?&amp;lt;host&amp;gt;[^,]+),(?&amp;lt;prev&amp;gt;[^,]+),(?&amp;lt;server&amp;gt;[^,]+),(?&amp;lt;server_state&amp;gt;.*)"
| fields - event _time
| eval _time=strptime(time,"%Y-%m-%d %H:%M:%S.%Q")
| fields - time
| eval active_server=if(server_state="active",server,null)
| eval active_state=if(server_state="active",server_state,null)
| streamstats latest(active_server) as active_server latest(active_state) as active_state
| eval server=if(prev="IDLE",active_server,server)
| eval server_state=if(prev="IDLE",active_state,server_state)
| fields - active_server active_state&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 29 Oct 2020 10:15:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-events-only-from-active-host/m-p/527050#M148771</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2020-10-29T10:15:43Z</dc:date>
    </item>
  </channel>
</rss>

