<?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 Java SDK: Most efficient way to wait for a particular event in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Java-SDK-Most-efficient-way-to-wait-for-a-particular-event/m-p/426086#M7578</link>
    <description>&lt;P&gt;Some backstory:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;I am writing end-to-end automation for a microservice that writes events to Splunk.&lt;/LI&gt;
&lt;LI&gt;I use Java Splunk SDK version 1.6.3.0, which is the latest version stored on our artifactory&lt;/LI&gt;
&lt;LI&gt;After I drop files in a particular folder on S3, our service calls various internal APIs and logs the status to Splunk.&lt;/LI&gt;
&lt;LI&gt;After dropping the files, my automation needs to wait for a particular unique event to appear and then continues doing some internal validations.&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I would like to be able to wait for a specific event to appear on Splunk, with a timeout of some number of seconds in case the event never happens. Currently I do this with a &lt;EM&gt;for&lt;/EM&gt; loop and poll for the specified event to appear. However, I wonder if there might be a more efficient way to do this. &lt;/P&gt;

&lt;P&gt;Here's a sample of an event I need to wait for:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{   
&amp;lt;snip/&amp;gt;
     file_url:   https://some.website/somefile.json 
     id:     12345  
     level:  30 
     msg:    File processing succeeded  
     name:   myservicename
&amp;lt;snip/&amp;gt;
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And a sample query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex sourcetype=myservicename msg="File processing succeeded" file_url="https://some.website/somefile.json" id="12345"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In this example, &lt;EM&gt;index&lt;/EM&gt;, &lt;EM&gt;sourcetype&lt;/EM&gt;, and &lt;EM&gt;msg&lt;/EM&gt; are the same every time I run my test case. &lt;EM&gt;file_url&lt;/EM&gt; and &lt;EM&gt;id&lt;/EM&gt; are unique each time.&lt;/P&gt;

&lt;P&gt;What is the recommended way to wait for a particular event? What kind of query is recommended (blocking/etc)?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 22:56:42 GMT</pubDate>
    <dc:creator>teresap</dc:creator>
    <dc:date>2020-09-29T22:56:42Z</dc:date>
    <item>
      <title>Java SDK: Most efficient way to wait for a particular event</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Java-SDK-Most-efficient-way-to-wait-for-a-particular-event/m-p/426086#M7578</link>
      <description>&lt;P&gt;Some backstory:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;I am writing end-to-end automation for a microservice that writes events to Splunk.&lt;/LI&gt;
&lt;LI&gt;I use Java Splunk SDK version 1.6.3.0, which is the latest version stored on our artifactory&lt;/LI&gt;
&lt;LI&gt;After I drop files in a particular folder on S3, our service calls various internal APIs and logs the status to Splunk.&lt;/LI&gt;
&lt;LI&gt;After dropping the files, my automation needs to wait for a particular unique event to appear and then continues doing some internal validations.&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I would like to be able to wait for a specific event to appear on Splunk, with a timeout of some number of seconds in case the event never happens. Currently I do this with a &lt;EM&gt;for&lt;/EM&gt; loop and poll for the specified event to appear. However, I wonder if there might be a more efficient way to do this. &lt;/P&gt;

&lt;P&gt;Here's a sample of an event I need to wait for:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{   
&amp;lt;snip/&amp;gt;
     file_url:   https://some.website/somefile.json 
     id:     12345  
     level:  30 
     msg:    File processing succeeded  
     name:   myservicename
&amp;lt;snip/&amp;gt;
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And a sample query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex sourcetype=myservicename msg="File processing succeeded" file_url="https://some.website/somefile.json" id="12345"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In this example, &lt;EM&gt;index&lt;/EM&gt;, &lt;EM&gt;sourcetype&lt;/EM&gt;, and &lt;EM&gt;msg&lt;/EM&gt; are the same every time I run my test case. &lt;EM&gt;file_url&lt;/EM&gt; and &lt;EM&gt;id&lt;/EM&gt; are unique each time.&lt;/P&gt;

&lt;P&gt;What is the recommended way to wait for a particular event? What kind of query is recommended (blocking/etc)?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:56:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Java-SDK-Most-efficient-way-to-wait-for-a-particular-event/m-p/426086#M7578</guid>
      <dc:creator>teresap</dc:creator>
      <dc:date>2020-09-29T22:56:42Z</dc:date>
    </item>
  </channel>
</rss>

