Convert string format to date using filter in logstash


(Elastic-for-me) #1

filter {
mutate {
add_field => {
"docid" => "%{projectname}%{systemtypeid}%{username}-%{+dd-MM-YYYY}"
"daymonthyear" => "%{+dd-MM-YYYY}"
}
}

I get two variable docid (which I am using as my document_id =>
second is daymonthyear. it gets inserted in to index but type of that filed is string. How do I make it to date.

I just want that variable to be date format in my index.

I try many different option none works as I don't even know how to do it.

Try this under filter but it won't even start logstash.
date {
match => '["daymonthyear", "dd-MM-YYYY"]
}


(Elastic-for-me) #2

I just found typo and it works now.

here is config

filter {
mutate {
add_field => {
"docid" => "%{projectname}%{systemtypeid}%{username}-%{+dd-MM-YYYY}"
"daymonthyear" => "%{+dd-MM-YYYY}"
}
} # Mutate
date {
match => ["daymonthyear", "dd-MM-YYYY"]
target => "daymonthyear"
}
}

this creates two new variable (filed) and one of them is type date.