设置参数 `node.name` 可以自定义 Elasticsearch 节点的名字。 此条 Tips 由 medcl 贡献。

logstash6.5.4 output 中的if判断不起作用

Logstash | 作者 xjar | 发布于2019年11月06日 | 阅读数:3102


input {
    stdin {}
    jdbc {
         # 多表同步时,表类型区分,建议命名为“库名_表名”,每个jdbc模块需对应一个type;
        type => "b_cover_bilibili"
          }
}
# output模块的type需和jdbc模块的type一致
    if [type] == "b_cover_bilibili" {
        elasticsearch {
             # host => "192.168.1.1"
             # port => "9200"
             # 配置ES集群地址
            hosts => ["127.0.0.1:9200"]
            index => "bindex"
             # 数据唯一索引(建议使用数据库KeyID)
            #document_id => "%{id}"
        }
    }
 
代码如上,当去掉if判断,数据可以写入es,加上之后,就没有写入。
已邀请:

zqc0512 - andy zhou

赞同来自:

你搞个全的吧 这个配置不全  output都没有,
多半是空格与TAB键的关系 这玩意格式要求很严格的。

zqc0512 - andy zhou

赞同来自:

 
output {
if [type] == "b_video" {
elasticsearch {
hosts => [ "127.0.0.1:9200" ]
index => "b_video_index"
}
}
stdout {
codec => json_lines
}
}

xjar

赞同来自:

WX20191107-112442.png

Memento - Memento

赞同来自:

你可以加上 if 后, 在 if 里添加控制台输出, 看看是什么问题;
 
if [type] == "xxx" {
stdout => rubydebug
}

xiaobai

赞同来自:

你好 请问一下你们解决了吗 怎么解决的

要回复问题请先登录注册