使用netstat -lntp来看看有侦听在网络某端口的进程。当然,也可以使用 lsof。

[求助]filebeat->logstash->es,不同的来源的日志,logstash解释生成不同的index

Logstash | 作者 Lincoln | 发布于2017年05月13日 | 阅读数:11254

elkstack架构构如下图所示,
1)[需求]3个业务系统(svr_sys1、svr_sys2、svr_sys3),在es中分别产生3个index,依次对应
      svr_sys1的索引为index_sys1、
     svr_sys2的索引为index_sys2、
     svr_sys3的索引为index_sys3

elkstack架构.png

2)filebeat由业务系统导入logstah,通过document_type参数据指定,配置信息如下所示
  • srv_sys1

#=========================== Filebeat prospectors =============================
filebeat.prospectors:

- input_type: log

# Paths that should be crawled and fetched. Glob based paths.
paths:
- /srv/logs/*.log
document_type: srv_sys1

#----------------------------- Logstash output --------------------------------
output.logstash:
# The Logstash hosts
hosts: ["10.20.20.50:5044"]

  • srv_sys2

#=========================== Filebeat prospectors =============================
filebeat.prospectors:
- input_type: log
paths:
- /srv/logs/*.log
document_type: srv_sys2
#----------------------------- Logstash output --------------------------------
output.logstash:
# The Logstash hosts
hosts: ["10.20.20.50:5044"]

  • srv_sys3

#=========================== Filebeat prospectors =============================
filebeat.prospectors:
- input_type: log
paths:
- /srv/logs/*.log
document_type: srv_sys2
#----------------------------- Logstash output --------------------------------
output.logstash:
# The Logstash hosts
hosts: ["10.20.20.50:5044"]

3)logstash的.conf文件的outpout通过if语句判断生成不同的index,配置信息如下:
input {
beats {
port => 5044
}
}

output{
if [type] =="srv_sys1" {
elasticsearh {
hosts => ["60.70.80.190:9200","60.70.80.191:9200"]
index => "index_sys1-%{+YYYY.MM.dd}"
document_type => "log"
}
}
if [type] =="srv_sys2" {
elasticsearh {
hosts => ["60.70.80.190:9200","60.70.80.191:9200"]
index => "index_sys2-%{+YYYY.MM.dd}"
document_type => "log"
}
}
if [type] =="srv_sys3" {
elasticsearh {
hosts => ["60.70.80.190:9200","60.70.80.191:9200"]
index => "index_sys3-%{+YYYY.MM.dd}"
document_type => "log"
}
}
}
[问题]es 只能创建一个index:index_sys3,其他2个无法成功创建
 
已邀请:

leighton_buaa

赞同来自: PhoebM

你试试 if - else
if EXPRESSION {
...
} else if EXPRESSION {
...
} else {
...
}

medcl - 今晚打老虎。

赞同来自: 谭雁宏

filebeat的配置文件,
document_type和path要对其。

testelk - 92年小萝莉 运维开发 求约

赞同来自:

问题解决了么?这么大一个社区,竟然没有高手?

rockybean - Elastic Certified Engineer, ElasticStack Fans,公众号:ElasticTalk

赞同来自:

对于 index 的设定,可以使用logstash @metadata 的方法来设定
 
https://www.elastic.co/blog/logstash-metadata
 
这样可以简化 logstash 的配置文件,将索引名的设定前置到 filter 中完成

PhoebM - 生活很美好,万一被人误会肯定有自己的原因,受不了就解释,不想解释就看淡些,自己何苦为难自己

赞同来自:

您的问题解决了吗,遇到了这个问题

guoguo

赞同来自:

用配
1.png


2.png

置文件"filebeat.yml"中的fields设置一字段“index”,然后logstash配置中读取“index的值就可以了

要回复问题请先登录注册