测试完成后,如何自动杀死Logstash代理? [英] How to automatically kill a logstash agent when tests are done?

查看:97
本文介绍了测试完成后,如何自动杀死Logstash代理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a logstash agent that monitors our automatic tests' log dumps -

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

at the beginning of each bulk of tests, an agent is started, listens to a specific folder, and at the end it should stop.

问题就在最后-我需要以某种方式告知Logstash代理测试已完成并杀死自己..

The problem is at the end - i need to somehow signal the logstash agent that the tests are done and kill itself..

我该怎么做? 配置代理的方式是什么,以便当它从测试中看到某个日志消息时会杀死自己?

How can I do that? What is the way to configure the agent so that when it sees a certain log message from the tests it kills himself?

我的配置文件:

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" }
}

推荐答案

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

One option would be to put a line at the end of your log such as:

END TEST

然后,您可以创建一个LogStash"kill"脚本,该脚本在到达该行时由LogStash执行.

You can then create a LogStash "kill" script which is executed by LogStash when it hits that line.

例如:

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

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

这篇关于测试完成后,如何自动杀死Logstash代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆