Problem setting "data" type


(Samuele Colmi) #1

Hello everyone!
I'm trying to index a .csv file with Logstash.
One of the field of the file is a string that rappresent a date ("yyyy-MM-dd HH:mm"), and i want to convert this field into a date type at the momento of uploading.
The filter i'm using is:

filter{
date{
match => ["logdate", "yyyy-MM-dd HH:mm"]
}
mutate {convert => ["start", "date"]}
}

but it's not working, it upload the "start" field as a string.
Does anyone have any ideas?


(Magnus Bäck) #2

Unless configured otherwise with the target option the date filter writes the parsed timestamp to the @timestamp field.


(Samuele Colmi) #3

and how do I use the target option to configure it?
thank you so much!


(Magnus Bäck) #4

Set the date filter's target option to "start".

https://www.elastic.co/guide/en/logstash/current/plugins-filters-date.html#plugins-filters-date-target

Note that the start field in your index has already been mapped as a string. Once set, the mapping of a field in an index can't be changed. If possible, delete the index and start over.


(Samuele Colmi) #5

it worked!
thank you so much!


(system) #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.