因此,您需要在这里按日期直方图字段对数据进行分组,然后对产品类型进行聚合或分桶。
如上图所示,您需要首先按“日期直方图”与字段(看起来字段名称为“timestamp ”,在你的情况下)你想要在其上进行存储。您可以根据需要指定间隔,例如每小时、每天、每月,或者您也可以将其保留为“自动”。
然后,您接下来需要像上面提到的那样对产品类型进行分类。
一旦你这样做了,我想你会很高兴的。
要准确地交叉检查幕后发生的事情,您可以点击面板右上角的“Query Inspector”并将查询也以 JSON 格式查看。
在我展示的示例中,生成了以下内容:
{
"type": "table",
"title": "Panel Title",
"gridPos": {
"x": 0,
"y": 0,
"w": 12,
"h": 8
},
"id": 23763571993,
"targets": [
{
"refId": "A",
"query": "",
"alias": "",
"metrics": [
{
"type": "count",
"id": "1"
}
],
"bucketAggs": [
{
"id": "3",
"type": "date_histogram",
"settings": {
"interval": "auto",
"min_doc_count": "0",
"trimEdges": "0"
}
},
{
"id": "4",
"type": "terms",
"settings": {
"min_doc_count": "0",
"size": "10",
"order": "desc",
"orderBy": "_term"
},
"field": "coordinates.longitude"
}
],
"timeField": "@timestamp"
}
],
"options": {
"showHeader": true
},
"datasource": "ES Logs",
"fieldConfig": {
"defaults": {
"custom": {
"align": null,
"filterable": false
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"value": null,
"color": "green"
},
{
"value": 80,
"color": "red"
}
]
},
"mappings": [],
"color": {
"mode": "thresholds"
}
},
"overrides": []
},
"pluginVersion": "7.5.4"
}
你可以忽略周围的信息,因为这毕竟是虚拟数据。
您也可以参考以下链接:Date Histogram Community Question
对于可能有类似查询但与 Kibana 相关的其他人,它甚至更简单。在可视化选项卡中,选择您的索引。
第1步:首先选择“日期直方图”字段,然后选择要使用的索引字段。
第 2 步:然后选择“术语”并选择您要使用的索引字段。
第 3 步:可视化准备就绪。