Mark, maybe this will clarify more what I mean
this is my index template :
{
"order": 0,
"template": "incoming-aa*",
"settings": {
"index": {
"number_of_shards": "10",
"number_of_replicas": "1",
"refresh_interval": "5s"
}
},
"mappings": {
"incoming-aa": {
"properties": {
"source_in": {
"type": "text"
},
"source_location": {
"type": "geo_point"
},
"destination_out": {
"type": "text"
}
}
}
},
"aliases": {
"Incoming-ALL": {}
}
}
This is my logstash conf file :
input {
file {
path => "/home/*.csv"
type => "incoming-aa"
start_position => "beginning"
}
}
filter {
if [type] == "incoming-aa" {
# write to @metadata so I can use it in the output part
mutate { add_field => ["[@metadata][type]", "%{type}"] }
# split the lines
csv {
separator => ","
columns => ["source_in","source_location","destination_out"]
}
# remove unnecessary fields
mutate {
remove_field => ["@version", "host", "path", "message", "type"]
}
output {
if [@metadata][type] == "incoming-aa" {
elasticsearch {
hosts => ["10.100.200.100"]
action => "index"
index => "incoming-aa-%{+YYYY_MM}"
}
}
}
After ingestion, I check the mapping for that index and below is the result. The part starting and ending with "**" (I have put that there so you can see it better, in reality the asterisks are not there) was added by LS/ES, so the original mapping I set up in the index template was not used. An automatic mapping was done and it named it "logs".
This only happens when I remove the "type" field ! When I do not remove it, my mapping is used, but then the "type" field appears in Kibana and I don't want that.
Edit : Title of this discussion should change to "ELK 5.4 - LS reverts to automatic mapping when 'type' field is removed or renamed"
{
"incoming-aa-2017_06": {
"mappings": {
"incoming-aa": {
"properties": {
"source_in": {
"type": "text"
},
"source_location": {
"type": "geo_point"
},
"destination_out": {
"type": "text"
}
}
},
**"logs": {**
** "properties": {**
** "@timestamp": {**
** "type": "date"**
** },**
** "source_in": {**
** "type": "text",**
** "fields": {**
** "keyword": {**
** "type": "keyword",**
** "ignore_above": 256**
** }**
** }**
** },**
** "source_location": {**
** "type": "geo_point"**
** },**
** "destination_out": {**
** "type": "text",**
** "fields": {**
** "keyword": {**
** "type": "keyword",**
** "ignore_above": 256**
** }**
** }**
** }**
** }**
** }**
** }**
** }**
}