You can extract the month fields using either dissect or grok. You can map an abbreviation of a month into a number using a translate filter. You can also use translate to map months to quarters.
======================================================================
output I am getting is
First scenario--> example
"start_date" : "Nov-19",
"startdatetarget" : "**2019**-10-31T18:30:00.000Z",
Nov 19 is 2019-10 (Oct)
as_of_date I am not getting any value for this
Second Scenario -->
"_source" : {
"actualclosedmonthtarget" : "**0019**-05-01T18:06:32.000Z",
"actual_closed_month" : "5/2/19",
"actual_closed_month_epoch" : -61557170008000
}
actual closed month value is 5/2/19 which is MM/DD/yy but target value is coming as 0019 instead of 2019.
The Java documentation says "For parsing, if the number of pattern letters is more than 2, the year is interpreted literally, regardless of the number of digits. So using the pattern "MM/dd/yyyy", "01/11/12" parses to Jan 11, 12 A.D."
The patterns in a date filter are tried in order. In this case the first one will work, so the second one is never tried. I would suggest (but have not tested) changing the order of entries.
match => [ "actual_closed_month", "MM/dd/yy", "MM-dd-yy", "MM/dd/yyyy" ]
Thanks for reply it worked.
But still I am not getting how to extract month.
I tried below code
date { match => [ "actual_closed_month" , "MM/dd/yy","MM-dd-yy","MM/dd/yyyy" ]
target => "actualclosedmonthtarget"}
grok { match => ["actualclosedmonthtarget", "^%{YEAR}-%{MONTH:actual_month}"]}
I am not getting proper response
"actual_epoch" : 1604255400000,
"actualclosedmonthtarget" : "2020-11-01T18:30:00.000Z",
"actual_month" : "1",
"actual_closed_month" : "11/2/20"
November month is coming as 1.
I am surprised that matches at all, since MONTH matches the name or abbreviation of a name. You could try MONTHNUM. If that still matches 1 then try `-%{MONTHNUM:actual_month}-"
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.