I am trying to output the value of @timestamp in a runtime field (configured in Kibana 7.13.3). My goal is then to get only the month as display value with a modified format 'MMM'. Unfortunately, I have been unsuccessful so far with all possible combinations that can be found on Google. I have not even managed to output the "normal" value of @timestamp or any other date field in a new runtime field.
emit(doc['@timestamp'].value);
^---- HERE
In Discover, I then get this error message:
cannot convert MethodHandle(Dates)JodaCompatibleZonedDateTime to (Object)long
I also tried a gazillion of other things... with no success.
The same works great with a keyword field if I am using this:
thanks a lot. This is a great resource of examples.
Could you help me further to return the value of @timestamp as a Date type in the runtime field? Using .toString(), which requires the runtime field to be a Keyword field, brings the problem that I cannot configure any custom date formatting, like MMM,
If I try to use emit(doc['@timestamp'].value.toString()) and runtime field type Date, the Discover app shows an error:
cannot convert MethodHandle(Object)String to (Object)long
emit(doc['@timestamp'].value.toString()) is a string
Can you show me exactly what you want before and after and what data types you want before and after and how you plan to use the result and what type you want the result... I am lost / confused at this point.
I have data from about the last 10 years and would like an evaluation of which month has the most entries. As a date field I have the @timestamp field available. I need an evaluation of the data per month. Month should be for example "7" or "July". That would not matter. My plan was to create a runtime field, which gets the value of @timestamp and is displayed in the format MMM. So I still have the @timestamp field and additionally the month in a separate field.
thanks for the clarification of the difference between mapping and index pattern. I am aware of this now. I also understand now how to return the month name as a string (Keyword runtime field), but I am still unsure how to return the value of @timestamp as a date (Date runtime field). Maybe I am just confused and the answer is too simple Sorry if that is the case...
@timestamp is already always available as a "indexed / concrete field" as a date type... why do you need it as a runtime field? @timestamp will always be available.
What do you mean the the value of @timestamp as a date (Date runtime field)
Can you show me what you mean? Are you just trying to format the date in a certain format?
Are you trying to build visualizations or DSL queries?
I want to show and use the Month and the Year in separate additional fields. My idea is to keep the fields as Date fields and just apply a custom formatting as needed.
let us just assume that I want to duplicate the @timestamp field into a runtime field. Let us call this runtime field my_date. How do I return the date value of the @timstamp field in the my_date field? The my_date field is a Date field type.
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.