我很新的logstash和弹性搜索。我试图在elasticsearch和平面文件中存储日志文件。我知道logstash支持这两种输出。但他们是同时处理?或者是通过工作定期完成的?可以logstash同时处理多个输出吗?
4
A
回答
5
是的,您可以通过在托运人配置中使用“add_tag”命令标记和克隆您的输入来完成此操作。
input
{
tcp { type => "linux" port => "50000" codec => plain { charset => "US-ASCII" } }
tcp { type => "apache_access" port => "50001" codec => plain { charset => "US-ASCII" } }
tcp { type => "apache_error" port => "50002" codec => plain { charset => "US-ASCII" } }
tcp { type => "windows_security" port => "50003" codec => plain { charset => "US-ASCII" } }
tcp { type => "windows_application" port => "50004" codec => plain { charset => "US-ASCII" } }
tcp { type => "windows_system" port => "50005" codec => plain { charset => "US-ASCII" } }
udp { type => "network_equipment" port => "514" codec => plain { charset => "US-ASCII" } }
udp { type => "firewalls" port => "50006" codec => plain }
}
filter
{
grok { match => [ "host", "%{IPORHOST:ipaddr}(:%{NUMBER})?" ] }
mutate { replace => [ "fqdn", "%{ipaddr}" ] }
dns { reverse => [ "fqdn", "fqdn" ] action => "replace" }
if [type] == "linux" { clone { clones => "linux.log" add_tag => "savetofile" } }
if [type] == "apache_access" { clone { clones => "apache_access.log" add_tag => "savetofile" } }
if [type] == "apache_error" { clone { clones => "apache_error.log" add_tag => "savetofile" } }
if [type] == "windows_security" { clone { clones => "windows_security.log" add_tag => "savetofile" } }
if [type] == "windows_application" { clone { clones => "windows_application.log" add_tag => "savetofile" } }
if [type] == "windows_system" { clone { clones => "windows_system.log" add_tag => "savetofile" } }
if [type] == "network_equipment" { clone { clones => "network_%{fqdn}.log" add_tag => "savetofile" } }
if [type] == "firewalls" { clone { clones => "firewalls.log" add_tag => "savetofile" } }
}
output
{
#stdout { debug => true }
#stdout { codec => rubydebug }
redis { host => "1.1.1.1" data_type => "list" key => "logstash" }
}
并在您的主logstash比如你可以这样做:
input {
redis {
host => "1.1.1.1"
data_type => "list"
key => "logstash"
type=> "redis-input"
# We use the 'json' codec here because we expect to read json events from redis.
codec => json
}
}
output
{
if "savetofile" in [tags] {
file {
path => [ "/logs/%{fqdn}/%{type}" ] message_format => "%{message}"
}
}
else { elasticsearch { host => "2.2.2.2" }
}
}
0
仅供参考,你可以学习The life of logstash event有关logstash事件。
输出工作者模型当前是单个线程。输出将按照它们在配置文件中定义的顺序接收事件。
但是输出可能决定在发布它们之前临时缓冲事件。例如:输出缓冲2或3个事件,然后只写入文件。
相关问题
- 1. 我可以在Haskell中同时处理多个文件吗?
- 2. Windows PHP-FPM可以同时处理多个请求吗?
- 3. Scala可以同时处理多个消息吗?
- 4. ASP.NET工作线程可以同时处理多个请求吗?
- 5. Logstash多输入多输出
- 6. PHP可以同时或一个一个地处理多个请求吗?
- 7. 配置Logstash Loggly输出以使用Loggly的批处理API
- 8. 是表单按钮可以同时处理400个点击吗?
- 9. Selenium 2 Webdriver可以同时处理两个webelements吗?
- 10. 单个Apache服务器可以同时处理Tomcat和PHP吗?
- 11. ReLU可以处理负面输入吗?
- 12. Logstash模式处理多个匹配
- 13. 内核可以通过多线程同时处理两个系统调用吗?
- 14. ProcessingJS可以同时具有多个键输入吗?
- 15. R OpenCPU可以同时处理多少个请求
- 16. 可以处理多点触控吗?
- 17. Can Keras可以处理不同大小的输入图像吗?
- 18. 多个Logstash输出取决于collectd
- 19. 我可以输出多个文件到标准输出并分别处理它们吗?
- 20. 预处理后gcc可以输出C代码吗?
- 21. ESX可以处理多个文件管理器实例吗?
- 22. 可以为同一输入写几个输出吗?
- 23. 同位素过滤可以处理几百个项目和多个类别吗?
- 24. 我可以在处理ajax页面时输出/刷新数据到屏幕吗?
- 25. 我可以在同一台服务器上运行多个logstash实例吗?
- 26. 哪些scikit学习工具可以处理多元输出?
- 27. 一个ResultSet可以处理多个表吗?
- 28. 你可以在一个Using块中处理多个对象吗?
- 29. Logstash单输入和多输出
- 30. Java可以处理Expando吗?
在你的例子中,logstash会输出指定的“savetofile”日志到磁盘和其他日志到elasticsearch。是否有可能同时输出相同的日志到两个输出? –