如何将sql返回的字段用于logstash if语句


Sql语句
statement => "select ref_id,index_name,type,content from t_backup_es_data where backup_id >= :sql_last_value"

返回的类型列的值具有建议和报价

if[%{type}] == "quotation" {
elasticsearch {
hosts => "localhost:9200"
index => "%{index_name}"
document_type => "%{type}"
document_id => "%{ref_id}"
manage_template => true
template_overwrite => true
template => "../config/quotationMapping.json"
}   
}else if[%{type}] == "proposal" {
elasticsearch {
hosts => "localhost:9200"
index => "%{index_name}"
document_type => "%{type}"
document_id => "%{ref_id}"
manage_template => true
template_overwrite => true
template => "../config/proposalMapping.json"
}
}

这个配置不起作用,你有什么建议?

假设您使用的是JDBC输入插件,则文档状态为:

结果集中的列被转换为事件中的字段

我会从stdout输出开始,看看您有什么。ELK堆栈过去曾使用"type"作为内部字段,因此它可能与重命名查询中的列一样简单。

最新更新