在logstash的.conf文件中创建多个索引,需要进行以下步骤:
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "index_name1"
}
}
output {
if [type] == "error" {
elasticsearch {
hosts => ["localhost:9200"]
index => "error_index"
}
} else if [type] == "info" {
elasticsearch {
hosts => ["localhost:9200"]
index => "info_index"
}
} else {
elasticsearch {
hosts => ["localhost:9200"]
index => "default_index"
}
}
}
上述示例中,根据type
字段的值将日志分别发送到不同的索引:error_index
、info_index
和default_index
。
logstash -f logstash.conf
这将启动Logstash并加载配置文件logstash.conf
。
通过以上步骤,你可以在Logstash的.conf文件中创建多个索引,根据需要将日志数据发送到不同的索引中。请根据实际需求自定义索引名称、条件和插件配置。具体的配置和定制需求,可以参考Logstash官方文档(https://www.elastic.co/guide/en/logstash/current/index.html)。
领取专属 10元无门槛券
手把手带您无忧上云