Convert Date String Into Date Format

:slight_smile:

sorry to disturb @admlko but when i try 4/30/2019 1:35:16
M/dd/yyyy H:mm:ss it does not convert

My config file
input {
file {
path => "D:/kibanaproject/kesample.csv"
start_position => "beginning"
sincedb_path => "NUL"
}
}
filter {

if ([message] =~ "\bDate\b") {
drop { }
} else {

csv { 
	separator => "," 
	columns => ["Date","mobile","Telco","SCode","SMSLength","msg","Category"] 
}


date {

match => ["Date", "M/dd/yyyy H:mm:ss"]
target => "Date"
}
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "evening%{+dd.MM.YYYY}"
}
stdout {codec => json_lines }
}

Date,mobile,Telco,SCode,SMSLength,msg,Category
4/30/2019 1:35:16 ,923442122939,Telenor,8119,1,"Dear Customer, due to maintenance shutdown, the supply to your area (A/C #400005067403) may be affected on 30 Apr between 1PM-5PM. Inconvenience regretted.KE",Maintenance Shutdown

This is the sample record in which i test the config file

You have a space at the end of the [Date] field, so you need a trailing space in your date filter.

input {
file {
path => "D:/kibanaproject/kesample.csv"
start_position => "beginning"
sincedb_path => "NUL"
}
}
filter {
if ([message] =~ "\bDate\b") {
drop { }
} else {
csv {
separator => ","
columns => ["Date","mobile","Telco","SCode","SMSLength","msg","Category"]
}
date {
match => ["Date","M/dd/yyyy H:mm:ss"]
target => "Date"
}
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "night%{+dd.MM.YYYY}"
}
stdout {codec => json_lines }
}

i have remove spaces still result is the same

Date,mobile,Telco,SCode,SMSLength,msg,Category
4/30/2019 1:35:16 PM,923442122939,Telenor,8119,1,"Dear Customer, due to maintenance shutdown, the supply to your area (A/C #400005067403) may be affected on 30 Apr between 1PM-5PM. Inconvenience regretted.KE",Maintenance Shutdown

You would need to add "a" to the pattern to match the AM/PM.

Thanks a ton issue is resolved !!

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