如何在测试完成时自动杀死logstash代理?

如何在测试完成时自动杀死logstash代理?,logstash,Logstash,我有一个logstash代理监控我们自动测试的日志转储- 在每一批测试开始时,都会启动一个代理,侦听一个特定的文件夹,最后应该停止 问题就在最后-我需要以某种方式向logstash代理发出信号,表明测试已经完成,然后自杀 我该怎么做? 如何配置代理,使其在看到来自测试的特定日志消息时自杀 我的配置文件: input { file { type => "cloudify-logs" path => "<path_to_test_class_folder>

我有一个logstash代理监控我们自动测试的日志转储-

在每一批测试开始时,都会启动一个代理,侦听一个特定的文件夹,最后应该停止

问题就在最后-我需要以某种方式向logstash代理发出信号,表明测试已经完成,然后自杀

我该怎么做? 如何配置代理,使其在看到来自测试的特定日志消息时自杀

我的配置文件:

input {

  file {
    type => "cloudify-logs"
    path => "<path_to_test_class_folder>/*"
    tags => [ "<suite_name>" , "<test_name>" , "<build_number>" , "<version>" ]
  }
}

output {
  stdout { debug => true debug_format => "json"}
  redis { host => "<host>" data_type => "list" key => "logstash" }
}
输入{
文件{
类型=>“cloudify日志”
路径=>“/*”
标记=>[“”,“”,“”,“”,“”]
}
}
输出{
标准输出{debug=>true debug_格式=>“json”}
redis{host=>“”数据类型=>“列表”键=>“logstash”}
}

一种选择是在日志末尾放一行,例如:

END TEST
然后,您可以创建一个LogStash“kill”脚本,该脚本在到达该行时由LogStash执行

例如:

filter
{
    if [message] =~ "^END TEST"
    {
        mutate
        {
            add_tag => ["end"]
        }
    }
}

output
{
    if "end" in [tags]
    {
        exec
        {
            command => "kill_logstash.sh"
        }
    }
}

如何启动logstash?有了这个:java-jar logstash-1.1.13.jar agent-f logstash-shipper.conf-l logstash-shipper log.txt&尝试使用java服务包装器:相反,您的方法是使用一个自定义过滤器来执行检测和执行System.exit(),它工作得很好。杀死LogStash代理的正确方法是使用LogStash出口插件:
if[tags]{exit{pause\u second=>10 exit\u code=>0}