elasticsearch 日志存储到elasticsearch的条件输出(每个filebeat主机名的索引)
我有几个安装了filebeat的web服务器,我希望每个主机有多个索引 我当前的配置看起来像elasticsearch 日志存储到elasticsearch的条件输出(每个filebeat主机名的索引),elasticsearch,logstash,logstash-grok,logstash-configuration,elasticsearch,Logstash,Logstash Grok,Logstash Configuration,我有几个安装了filebeat的web服务器,我希望每个主机有多个索引 我当前的配置看起来像 input { beats { ports => 1337 } } filter { grok { match => { "message" => "%{COMBINEDAPACHELOG}"} } geoip { source => "clientip" } } output { elasticsearch { if
input {
beats {
ports => 1337
}
}
filter {
grok {
match => { "message" => "%{COMBINEDAPACHELOG}"}
}
geoip {
source => "clientip"
}
}
output {
elasticsearch {
if [beat][hostname] == "luna"
{
hosts => "10.0.1.1:9200"
manage_template => true
index => "lunaindex-%{+YYYY.MM.dd}"
document_type => "apache"
}
}
}
但是,上述配置会导致
给定的配置无效。原因:应为#,=>中的一个
第22行第6列(字节346)
这就是if语句发生的地方。有什么帮助吗
我想有一个嵌套的格式作为上述
if [beat][hostname] == "lina"
{
index = lina
}
else if [beat][hostname] == "lona"
{
index = lona
}
等等。有什么帮助吗?解决方案可以是:
在每个filebeat配置文件中,在ProsperSector部分定义文档类型:
文件类型:luna
在管道配置文件中,检查类型字段
如果[type]=“luna”
希望这有帮助 要访问任何内部字段,必须用%{}将其括起来 试试这个
%{[beat][hostname]}
有关更多解释,请参阅
更新:
将%{[beat][hostname]}与==一起使用将不起作用,请尝试
if "lina" in [beat][hostname]{
index = lina
}
该线程是旧的,但希望有人会发现这是有用的。插件定义中不允许使用条件,因此会出现错误。条件必须包括如下所示的整个定义。另外,有关详细信息,请参见
output {
if [beat][hostname] == "luna" {
elasticsearch {
hosts => "10.0.1.1:9200"
manage_template => true
index => "lunaindex-%{+YYYY.MM.dd}"
document_type => "apache"
}
} else{
elasticsearch {
// alternate configuration
}
}
}
这不起作用,因为在我的例子中,这两种类型都是“apache”如果你不想更改类型,你可以添加如下标记:在filebeat配置文件中,在“浏览”部分添加:标记:[“luna”]在你的日志存储管道中检查标记:如果[tags]中的“luna”这是一个好主意,实际上会让它成功!所以它是有用的?我尝试了这个,但它没有工作-我仍然得到相同的错误我尝试了以下“输出{if%{[beat][hostname]}==”test1“{elasticsearch{hosts=>”10.0.1.1:9200“manage_template=>true index=>”testing-%{+yyyyy.MM.dd}”文档类型=>“apache”}if语句中仍然有一个错误