elasticsearch logstash 自定义output template无效
大神们为什么我写的脚本 自定义template回无效呢 脚本如下:
input {
stdin {
}
jdbc {
# mysql 数据库链接,sange为数据库名
jdbc_connection_string => ""
# 用户名和密码
jdbc_user => ""
jdbc_password => ""
# 驱动
jdbc_driver_library => "/some/config-dir/mysql-connector-java-5.1.36.jar"
# 驱动类名
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_paging_enabled => "true"
jdbc_page_size => "50000"
# 执行的sql 文件路径+名称
# statement_filepath => "/home/hadoop/logstash-5.2.1/etc/product.sql"
statement => "SELECT * FROM (SELECT items.id, items.name, items.title, items.warehouseType, items.unitPriceDesc, attachments.filePath, DATE_FORMAT(FROM_UNIXTIME(items.updateTime), '%Y-%m-%d %H:%i:%s') AS update_time FROM items left join attachments on attachments.id = items.showImageId WHERE items.delete = 0) AS temp WHERE temp.update_time >= :sql_last_value"
# 设置监听间隔 各字段含义(由左至右)分、时、天、月、年,全部为*默认含义为每分钟都更新
schedule => "* * * * *"
# 索引类型
type => "jdbc"
}
}
filter {
json {
source => "message"
remove_field => ["message"]
}
}
output {
if [type] == "jdbc" {
elasticsearch {
hosts => ["es:9200"]
index => "items"
document_id => "%{id}"
manage_template => false
template_name => "items-test"
template => "/some/config-dir/items-test.json"
}
}
stdout {
codec => json_lines
}
}
下面的是items-test.json文件内容
{
"template" : "items-*",
"settings" : {
"index.refresh_interval" : "15s"
},
"mappings" : {
"jdbc" : {
"_all" : {"enabled" : true},
"dynamic_templates" : [ {
"string_fields" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : {
"type" : "string", "index" : "not_analyzed", "omit_norms" : true,"doc_values": true,"ignore_unmapped" : true
}
}
} ],
"properties" : {
"@version": { "type": "string", "index": "not_analyzed" },
"@timestamp": { "type": "date", "index": "not_analyzed", "doc_values": true, "format": "dateOptionalTime" },
"id": { "type": "long"},
"name": { "type": "string", "analyzer":"ik_max_word", "search_analyzer":"ik_max_word", "include_in_all":"true"},
"title": { "type": "string", "analyzer":"ik_max_word", "search_analyzer":"ik_max_word", "include_in_all":"true"},
"warehouseType" : { "type" : "long" },
"unitPriceDesc" : { "type" : "long" },
"filePath" : { "type" : "long" }
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论