Day of Week

I'm able to define scripted field like so in Kibana 4.2 and Elasticsearch 2.0:

doc['@timestamp'].getDayOfMonth()
doc['@timestamp'].getHourOfDay()

but can't figure out how to get the day of the week. I've tried:

doc['@timestamp'].getDayOfWeek()
doc['@timestamp'].dayOfWeek()

Which generates "Member method [getDayOfWeek] does not exist" in the error logs. Anyone able to get the day of the week in kibana scripted fields? Thanks!

You might be better of asking your question in the Kibana forum here: https://discuss.elastic.co/c/kibana

I've moved it :slight_smile:

It's my understanding that this is more of an elasticsearch feature that kibana happens to expose. I thought I read that timestamps adhere to the joda time interface but maybe elasticsearch only exposes a subset? If so, is there a reason why getDayOfWeek() was left out?

Kibana uses Lucene Expressions due to security concerns with what was previously used, Groovy (see https://github.com/elastic/kibana/issues/3180).
Lucene expressions do not support getDayOfWeek(), https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html#_lucene_expressions_scripts.

Sounds like more of a Lucene issue to dive into. Strange that getDayOfWeek() is omitted - it's pretty important. If anyone comes up with a workaround, I'd love to see it.

one year late, but here is the solution: How to print popular hour diagram in Kibana