Hi Team,
I defined 4 integer fields in index template(if1,if2,if3 and if4), and ship serveral events to Elasticsearch by logstash. I found that these 4 interger fields are displayed as 'string' type in Kibana, which is unexpected.
Please help take a look and advice how to correct this issue.
- Index template
{ "template": "kvaudit", "index_patterns": ["kvaudit*"], "settings": { "index": { "number_of_shards": "1", "codec": "best_compression", "number_of_replicas": "0" } }, "mappings": { "doc": { "properties": { "@version": { "type": "keyword" } } } }, "beat": { "properties": { "version": { "type": "keyword" } } }, "fields": { "properties": { "at": {"type": "keyword"}, "ktf1": {"type": "keyword"}, "kf1": {"type": "keyword"}, "kf2": {"type": "keyword"}, "kf3": {"type": "keyword"}, "if1": { "type": "integer"}, "if2": { "type": "integer"}, "if3": { "type": "integer"}, "if4": { "type": "integer"}}} }
- logstash.conf
input { file{ path => "C:/elkstack/elasticsearch-7.0.1-windows-x86_64/data/integertest.csv" start_position => "beginning" mode => "tail" sincedb_path => "C:/elkstack/elasticsearch-7.0.1-windows-x86_64/sincedb/sincedb.txt" } } filter { csv { columns => [ "at", "ktf1", "kf1", "kf2", "kf3", "if1", "if2", "if3", "if4"] separator => "," skip_header => "true" } ruby { code => " hash = event.to_hash hash.each do |k, v| if(v != nil && v.kind_of?(String) && v.length > 2 && v[0,1] == '[' && v[v.length-1,1] == ']') event.set(k, v[1, v.length-2].split(',')) end end " } } output { elasticsearch { action => "index" hosts => "localhost:9200" index => "kvaudit" manage_template => true template => "C:/elkstack/elasticsearch-7.0.1-windows-x86_64/mapping/kvaudit2.json" template_name=> "kvaudit2.json" template_overwrite => true } stdout { codec => rubydebug {metadata => true}} }
- the data shipped to ES
at,ktf1,kf1,kf2,kf3,if1,if2,if3,if4 SAVE,performance,perf,,perf_guideline,1,2,3,4 SAVE,"[performance,liveprofile,talentflag]","[obj,comp,sysoverallperformance,sysoverallpotential]","[obj,comp]","[sysoverallperformance,sysoverallpotential]",2,3,4,5 SAVE,"[performance,liveproifle]","[obj,sysoverallperformance,sysoverallpotential]",obj,"[obj,sysoverallperformance,sysoverallpotential]",1,2,3,4
- But in kibana, the data type for 4 fields if1, if2, if3 and if4 are string, which is not consittent with what I defined in index template.
Anyone can take a look?