Kibana Visualization Error using scripted Date field

I have a scripted Date field (called "yyyy_mm_dd") in Kibana 7.7.0


Date date = new Date(doc['ts'].value.millis); 
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();

When I try to build an Aggregation using "Date Histogram" in Kibana and select "yyyy_mm_dd" as the field , I get errors. The Kibana logs are not very elaborate

error  [02:00:15.308]  Error: Internal Server Error
    at HapiResponseAdapter.toError (kibana-7.7.0-darwin-x86_64/src/core/server/http/router/response_adapter.js:130:19)
    at HapiResponseAdapter.toHapiResponse (kibana-7.7.0-darwin-x86_64/src/core/server/http/router/response_adapter.js:84:19)
    at HapiResponseAdapter.handle (kibana-7.7.0-darwin-x86_64/src/core/server/http/router/response_adapter.js:79:17)
    at Router.handle (kibana-7.7.0-darwin-x86_64/src/core/server/http/router/router.js:162:34)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Hi, do you have any error on the browser console? if so could you post that error?
Can you please also post also the response error?
I've tested locally and seems that is a missing date casting somewhere.
A temporary workaround is to change the scripted field to return the date in millis like

return cal.getTimeInMillis();

could you please also open a GH issue for that?

Thanks so much

Hi Marco
Sorry for the delay in my response. I have attached the screen shot of the error displayed in the Kibana web console when I use the scripted field as the "date field" in the Date Histogram

Thanks for your recommendation for using return cal.getTimeInMillis();. You idea worked beautifully. Thank you , thank you, thank you !

Hi Marco

I logged a ticket as per your request

Thanks for your help


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