作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试设置一个单独的logstash worker ,该 worker 从一个amqp / rabbitmq队列中获取所有消息,过滤一些消息以发送到statsD,同时还将所有消息发送到 Elasticsearch 。以下实现仅不将任何消息发送到ElasticSearch。
input {
rabbitmq {
host => "amqp-host"
queue => "elasticsearch"
key => "elasticsearch"
exchange => "elasticsearch"
type => "all"
durable => true
auto_delete => false
exclusive => false
format => "json_event"
debug => false
}
}
filter {
grep {
add_tag => "grepped"
match => ["@message", "Execution of .*? took .* sec"]
}
grok {
tags => ["grepped"]
add_tag => "grokked"
pattern => "Execution of %{DATA:command_name} took %{DATA:response_time} sec"
}
mutate {
tags => ["grepped", "grokked"]
lowercase => [ "command_name" ]
add_tag => ["mutated"]
}
}
output {
elasticsearch_river {
type => "all"
rabbitmq_host => "amqp-host"
debug => false
durable => true
persistent => true
es_host => "es-host"
exchange => "logstash-elasticsearch"
exchange_type => "direct"
index => "logs-%{+YYYY.MM.dd}"
index_type => "%{@type}"
queue => "logstash-elasticsearch"
}
statsd {
type => "command-filter"
tags => ["grepped", "grokked", "mutated"]
host => "some.domain.local"
port => 1234
sender => ""
namespace => ""
timing => ["prefix.%{command_name}.suffix", "%{response_time}"]
increment => ["prefix.%{command_name}.suffix"]
}
}
最佳答案
clone过滤器派上了用场。以下是我生成的配置文件。
input {
rabbitmq {
host => "amqp-host"
queue => "elasticsearch"
key => "elasticsearch"
exchange => "elasticsearch"
type => "all"
durable => true
auto_delete => false
exclusive => false
format => "json_event"
debug => false
}
}
filter {
clone {
exclude_tags => ["cloned"]
clones => ["statsd", "elastic-search"]
add_tag => ["cloned"]
}
grep {
type => "statsd"
add_tag => "grepped"
match => ["@message", "Execution of .*Command took .* sec"]
}
grok {
type => "statsd"
tags => ["grepped"]
add_tag => "grokked"
pattern => "Execution of %{DATA:command_name}Command took %{DATA:response_time} sec"
}
mutate {
type => "statsd"
tags => ["grepped", "grokked"]
lowercase => [ "command_name" ]
add_tag => ["mutated"]
}
}
output {
elasticsearch_river {
type => "all"
rabbitmq_host => "amqp-host"
debug => false
durable => true
persistent => true
es_host => "es-host"
exchange => "logstash-elasticsearch"
exchange_type => "direct"
index => "logs-%{+YYYY.MM.dd}"
index_type => "%{@type}"
queue => "logstash-elasticsearch"
}
statsd {
type => "statsd"
tags => ["grepped", "grokked", "mutated"]
host => "some.host.local"
port => 1234
sender => ""
namespace => ""
timing => ["commands.%{command_name}.responsetime", "%{response_time}"]
increment => ["commands.%{command_name}.requests"]
}
}
关于elasticsearch - 如何在Logstash中使用过滤器设置1:N工作流程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17346575/
我是一名优秀的程序员,十分优秀!