[英]convert field number to date on kibana, elastic search
I've a field number on Elasticsearch via Kibana. 我通过Kibana在Elasticsearch上有一个字段编号。
This is an example field: 这是一个示例字段:
"insert.datePeticio:1,546,185,770,733"
I need to convert this field to date, for visualize purpose. 我需要将此字段转换为日期,以实现可视化目的。
How can I parse it to date mode? 如何将其解析为日期模式?
As far as I understand, you have an integer field on Elasticsearch that stores date/time in milliseconds since the epoch. 据我了解,您在Elasticsearch上有一个整数字段,用于存储自该纪元以来的毫秒数的日期/时间。 You would like to convert it to an appropriate date type to visualise on Kibana properly. 您想将其转换为适当的日期类型,以正确显示在Kibana上。 In this case, I would recommend two solutions: 在这种情况下,我将推荐两种解决方案:
1) If you are able to define a mapping, use the the following for insert.datePeticio
field: 1)如果能够定义映射,请对insert.datePeticio
字段使用以下内容:
"mappings": {
"_doc": {
"properties": {
"insert.datePeticio": {
"format": "epoch_millis",
"type": "date"
}
}
}
}
This allows Kibana to define and represent insert.datePeticio
field as date even though the actual value is store in miliseconds as integer on Elasticsearch. 这使Kibana可以将insert.datePeticio
字段定义和表示为日期,即使实际值在Elasticsearch上以毫秒为单位存储为整数。
2) If not, so cannot make any changes on the original mapping, create a scripted field on Kibana as follows: 2)如果没有,则无法在原始映射上进行任何更改,请在Kibana上创建脚本字段,如下所示:
If you go to Kibana > Discover , you can see two fields together in different representations and types: insert.datePeticio: 1,546,185,770,733
and insert.datePeticio_UTC:December 30th 2018, 16:02:50.733
. 如果转到Kibana>发现 ,则可以以不同的表示形式和类型一起看到两个字段: insert.datePeticio: 1,546,185,770,733
和insert.datePeticio_UTC:December 30th 2018, 16:02:50.733
。 Since being a date type, the scripted field insert.datePeticio_UTC
can be easily used to create visualisations based on date aggregations. 由于是日期类型,因此脚本字段insert.datePeticio_UTC
可以轻松地用于基于日期聚合创建可视化效果。
Note: Scripted fields compute data on the fly from the data in your Elasticsearch indices. 注意:脚本字段会根据Elasticsearch索引中的数据即时计算数据。 Keep in mind that computing data on the fly with scripted fields can be very resource intensive and can have a direct impact on Kibana's performance. 请记住,使用脚本字段即时计算数据可能会占用大量资源,并且可能直接影响Kibana的性能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.