Hello, i am very new to logstash. I want to import the entries in a file to the elastic.
first I created the index on elastic :
{
"mytype-template": {
"template": "mytype-*",
"settings": {
"refresh_interval": "60s"
},
"mappings": {
"mytype": {
"_source": {
"enabled": true
},
"_all": {
"enabled": true
},
"properties": {
"timestamp": {
"type": "date",
"format": "dateTime",
"doc_values": true
},
"state": {
"type": "string",
"index": "not_analyzed",
"doc_values": true
},
"msisdn": {
"type": "string",
"index": "not_analyzed"
}
*** other fields
}
}
}
}
}
Sample lines in the file : 20170808155336480|Success|tel:a tel number|other fields...
*20170808155416380|Success|tel:a tel number|other fields...
I want to import the contents of the file to elastic after some transformation.
So, I created the below config file.
my config file is this
input {
file {
type => "mytpe"
path => "/path/*.edr"
start_position => "beginning"
}
}
filter {
if [type] == "mytpe" {
csv {
separator => "|"
columns => ["timestamp","state","msisdn"]
}
date {
match => [ "timestamp", "yyyyMMddHHmmssSSS" ]
target => "timestamp"
}
}
}
output {
if [type] == “mytpe” {
elasticsearch {
hosts => ["localhost:9200"]
index => "mytpe-write"
document_type => "mytpe"
}
stdout { codec => json }
}
}
Logstash is able to import the entries to elastic but when I query them I saw that there are additional fields like "path","type","@version","@timestamp" ,"message". Also in elastic search logs I see this log:
[2017-08-11T11:43:23,647][INFO ][o.e.c.m.MetaDataMappingService] [r5XrGDs] [mytype-2017.08/EPv0T8MzR0CL0tTuhSlFSQ] update_mapping [mytype]
I don't want my mappings updated. Is there a way to prevent the additional fields to be imported?
Note : I tried to modify config with the mutate filter (after date filter) but this time nothing happened. No data were imported.
mutate {
remove_field => ["path"]
remove_field => ["@version"]
remove_field => ["host"]
remove_field => ["message"]
remove_field => ["type"]
remove_field => ["@timestamp"]
}
Any help would be appreciated.
Thanks