如何为不同的日志从相同的 filebeat 到 logstash 使用不同的索引名称
How to have different index name for different log from same filebeat to logstash
我设置了ELK的版本(7.3.1)。不同虚拟机上的 filebeat(7.3.1)。
我在安装了 Filebeat 的虚拟机上有多个日志。
我想为不同的日志使用不同的索引名称。
我尝试了一种方法,但不起作用,配置文件如下
filebeat.yml
filebeat.inputs:
- type: log
enabled: true
paths:
- /data01/-----/LOG1/forecaster.log
fields:
log_type: type1
- type: log
enabled: true
paths:
- /data01/-----/LOG2/forecaster.log
fields:
log_type: type2
- type: log
enabled: true
paths:
- /data01/-----/LOG3/forecaster.log
fields:
log_type: type3
logstash.conf
input {
beats {
type => "filebeat"
port => "5044"
}
}
filter {
#If log line contains tab character followed by 'at' then we will tag that entry as stacktrace
if [message] =~ "\tat" {
grok {
match => ["message", "^(\tat)"]
add_tag => ["stacktrace"]
}
}
}
output {
stdout {
codec => rubydebug
}
if ([fields][log_type] == "type1") {
elasticsearch {
hosts => ["IP:9200"]
index => "log1"
}
}
if ([fields][log_type] == "type2") {
elasticsearch {
hosts => ["IP:9200"]
index => "log2"
}
}
if ([fields][log_type] == "type3") {
elasticsearch {
hosts => ["IP:9200"]
index => "log3"
}
}
}
使用上面的配置,在分析EL和filebeat的日志后,从filebeat中获取日志文件,并发送到正在处理的logstash,但不会发送到elasticsearch。
我需要帮助弄清楚什么是 wrong/missing 才能完成这项工作
谢谢
似乎 filebeat 配置中字段部分的缩进不正确,您缺少两个 space 个字符
filebeat.inputs:
- type: log
enabled: true
paths:
- /data01/-----/LOG1/forecaster.log
fields:
log_type: type1 <-- fis this line
- type: log
enabled: true
paths:
- /data01/-----/LOG2/forecaster.log
fields:
log_type: type2 <-- fis this line
- type: log
enabled: true
paths:
- /data01/-----/LOG3/forecaster.log
fields:
log_type: type3 <-- fis this line
我设置了ELK的版本(7.3.1)。不同虚拟机上的 filebeat(7.3.1)。 我在安装了 Filebeat 的虚拟机上有多个日志。 我想为不同的日志使用不同的索引名称。 我尝试了一种方法,但不起作用,配置文件如下
filebeat.yml
filebeat.inputs:
- type: log
enabled: true
paths:
- /data01/-----/LOG1/forecaster.log
fields:
log_type: type1
- type: log
enabled: true
paths:
- /data01/-----/LOG2/forecaster.log
fields:
log_type: type2
- type: log
enabled: true
paths:
- /data01/-----/LOG3/forecaster.log
fields:
log_type: type3
logstash.conf
input {
beats {
type => "filebeat"
port => "5044"
}
}
filter {
#If log line contains tab character followed by 'at' then we will tag that entry as stacktrace
if [message] =~ "\tat" {
grok {
match => ["message", "^(\tat)"]
add_tag => ["stacktrace"]
}
}
}
output {
stdout {
codec => rubydebug
}
if ([fields][log_type] == "type1") {
elasticsearch {
hosts => ["IP:9200"]
index => "log1"
}
}
if ([fields][log_type] == "type2") {
elasticsearch {
hosts => ["IP:9200"]
index => "log2"
}
}
if ([fields][log_type] == "type3") {
elasticsearch {
hosts => ["IP:9200"]
index => "log3"
}
}
}
使用上面的配置,在分析EL和filebeat的日志后,从filebeat中获取日志文件,并发送到正在处理的logstash,但不会发送到elasticsearch。
我需要帮助弄清楚什么是 wrong/missing 才能完成这项工作
谢谢
似乎 filebeat 配置中字段部分的缩进不正确,您缺少两个 space 个字符
filebeat.inputs:
- type: log
enabled: true
paths:
- /data01/-----/LOG1/forecaster.log
fields:
log_type: type1 <-- fis this line
- type: log
enabled: true
paths:
- /data01/-----/LOG2/forecaster.log
fields:
log_type: type2 <-- fis this line
- type: log
enabled: true
paths:
- /data01/-----/LOG3/forecaster.log
fields:
log_type: type3 <-- fis this line