让我解释一下我现有的结构,我有4个服务器(Web服务器,API服务器,数据库服务器,SSIS服务器),并且在所有4个服务器上安装了filebeat和winlog,从那里我在我的日志堆栈中获得了所有日志,但这里是我在消息正文中获得的每个日志,对于一些消息,我很难编写正确的GROK模式,有没有什么我可以从Kibana获得模式(仅供参考,我现在将所有日志存储在elasticsearch中,我可以通过Kibana查看)。
我的Logstash配置是这样的-
1. Api-Pipeline
input {
beats {
host => "IP Address where my filebeat (API Server) is running"
port => 5044
}
}
2. DB Pipeline
input {
beats {
host => "IP Address where my filebeat (Database Server) is running"
port => 5044
}
}
当我只使用端口时,它工作了,当我添加主机时,它就停止工作了。有人能帮我一下吗。
下面是我正在努力实现的
这里我做了修改,它能工作吗,因为我需要编写冗长的过滤器,这就是为什么我想要在单独的文件中
Filebeat.yml on API Server
-----------------------------------------------------------------------------------------
filebeat.inputs:
- type: log
source: 'ApiServerName' // MyAPIServerName(Same Server Where I have installed filebeat)
enabled: true
paths:
- C:\Windows\System32\LogFiles\SMTPSVC1\*.log
- E:\AppLogs\*.json
scan_frequency: 10s
ignore_older: 24h
filebeat.config.modules:
path: C:\Program Files\Filebeat\modules.d\iis.yml
reload.enabled: false
setup.template.settings:
index.number_of_shards: 3
setup.kibana:
host: "kibanaServerName:5601"
output.logstash:
hosts: ["logstashServerName:5044"]
Logstash Configuration
----------------------------------------------------------------
Pipeline.yml
- pipeline.id: beats-server
config.string: |
input { beats { port => 5044 } }
output {
if [source] == 'APISERVERNAME' {
pipeline { send_to => apilog }
} else if [source] == 'DBSERVERNAME' {
pipeline { send_to => dblog }
}
else{
pipeline { send_to => defaultlog }
}
}
- pipeline.id: apilog-processing
path.config: "/Logstash/config/pipelines/apilogpipeline.conf"
- pipeline.id: dblog-processing
path.config: "/Logstash/config/pipelines/dblogpipeline.conf"
- pipeline.id: defaultlog-processing
path.config: "/Logstash/config/pipelines/defaultlogpipeline.conf"
1. apilogpipeline.conf
----------------------------------------------------------
input {
pipeline {
address => apilog
}
}
output {
file {
path => ["C:/Logs/apilog_%{+yyyy_MM_dd}.log"]
}
}
2. dbilogpipeline.conf
---------------------------------------------------------
input {
pipeline {
address => dblog
}
}
output {
file {
path => ["C:/Logs/dblog_%{+yyyy_MM_dd}.log"]
}
}
3. defaultlogpipeline.conf
---------------------------------------------------------
input {
pipeline {
address => defaultlog
}
}
output {
file {
path => ["C:/Logs/defaultlog_%{+yyyy_MM_dd}.log"]
}
}
发布于 2020-06-16 20:18:52
相反,连接到Filebeat的不是Logstash,而是将数据发送到Logstash的Filebeat。因此,在您的输入部分中,主机需要是运行Logstash的主机的名称。
beats {
host => "logstash-host"
port => 5044
}
然后,在您的Filebeat配置中,您需要像这样配置Logstash output:
output.logstash:
hosts: ["logstash-host:5044"]
由于您有多个Filebeat源,并希望对每个源应用专用管道,因此您可以在每个Filebeat配置(例如source: db
、source: api-server
等)中定义一个custom field or tag,然后在Logstash中可以基于这些值应用不同的逻辑。
filebeat.inputs:
- type: log
fields:
source: 'APISERVERNAME'
fields_under_root: true
在Logstash中,您可以利用conditionals或pipeline to pipeline communication来根据事件数据应用不同的逻辑。
在最新的链接上,你可以看到一个distributor pattern的例子,这几乎就是你想要的。
https://stackoverflow.com/questions/62407849
复制相似问题