Scripted field „hour“ in ELK Stack

You can add scripted fields in the Index Patterns in the Management Section of Kibana.

Click in the Management Section on Index Patterns in the Kibana Settings:

Choose a Index pattern (eg. logstash-*)

Click on Tab Scripted fields

Click on the button Add scripted fields

Proceed with these settings:

  • Name: hour
  • Language: painless
  • Type: number
  • Format: – Default –
  • Popularity: 0

In the Script field use this code:

LocalDateTime.ofInstant(Instant.ofEpochMilli(doc['@timestamp'].value.millis), ZoneId.of('Europe/Berlin')).getHour()

Use your timezone in the script!