问题描述
您好,我在计算机上运行的logstash具有此配置:
input {
exec {
command => "powershell -executionpolicy unrestricted -f scripts/windows/process.ps1 command logstash"
interval => 30
type => "process_data"
codec => line
tags => [ logstash" ]
}
}
output
{
if "sometype-logs" in [tags] {
elasticsearch {
action => "index"
doc_as_upsert => true
index => "sometype-logs-%{+YYYY.MM.dd}"
hosts => "locahost:9200"
template_overwrite => true
}
} else {
elasticsearch {
action => "index"
doc_as_upsert => true
index => "%{type}"
hosts => "localhost:9200"
template_overwrite => true
}
}
为什么索引名是“%type”而不是“ process_data”?
解决方法
可能只是关于语法的一些东西。要使用数据的某些字段,必须使用此语法
%{[somefield]}
(请参阅本文档page上的示例)
因此,您可以尝试以下方法:
"%{[type]}"
代替
"%{type}"