title: Know when logstash has finished processing everything in its pipelines
body: <p>I have a relatively complicated logstash pipeline setup, with some pipelines feeding into others, splitting events, making http calls to external services, and sometimes feeding an event back into the pipeline it came from. (There is logic to prevent an infinite loop).</p>
  
  <p>I'm trying to write some integration tests that feed test event(s) into a running logstash, wait for logstash to finish processing them completely (including any extra events they spawned), then check that the resulting output is as expected. </p>
  
  <p>This logstash instance shouldn't be receiving any additional input from elsewhere, so I think it would be sufficient to check that it was "idle" (ignoring any events to do with the xpack monitoring).</p>
  
  <p>I think the pipleine stats monitoring API is probably what I want to use - <a href="https://www.elastic.co/guide/en/logstash/current/node-stats-api.html#pipeline-stats" rel="nofollow noreferrer">https://www.elastic.co/guide/en/logstash/current/node-stats-api.html#pipeline-stats</a> - but I'm unsure. If the values for "in" and "out" for every pipeline are equal, does that mean I can be certain that there's nothing more "in flight"? Or is it possible for these counters to be out of sync for some other reason e.g. event splitting, event filtering?</p>
  
  <p>Discussions at <a href="https://discuss.elastic.co/t/pipeline-stats-api-in-out-filtered/163742" rel="nofollow noreferrer">https://discuss.elastic.co/t/pipeline-stats-api-in-out-filtered/163742</a> (and following the links) appear to suggest that "in" and "out" will always appear in sync, with a bug suggesting this shouldn't be the case - <a href="https://github.com/elastic/logstash/issues/8752" rel="nofollow noreferrer">https://github.com/elastic/logstash/issues/8752</a> - and a related bug shows a situation where in and out are different - <a href="https://github.com/elastic/logstash/issues/8753" rel="nofollow noreferrer">https://github.com/elastic/logstash/issues/8753</a> </p>