elasticsearch Grafana条形图:可视化每个月每个产品类型的条目总数
我试图使用Grafana中的条形图来可视化以下数据。我的数据源是ElasticSearch,它获取如下日志消息: 我知道我想按产品类型对这些条目进行分组,并获得每个产品类型每月所有条目的总和。结果应该如下所示: 我已经设法获得了每种产品类型的所有条目的总和:elasticsearch Grafana条形图:可视化每个月每个产品类型的条目总数,elasticsearch,nosql,lucene,bar-chart,grafana,elasticsearch,Nosql,Lucene,Bar Chart,Grafana,我试图使用Grafana中的条形图来可视化以下数据。我的数据源是ElasticSearch,它获取如下日志消息: 我知道我想按产品类型对这些条目进行分组,并获得每个产品类型每月所有条目的总和。结果应该如下所示: 我已经设法获得了每种产品类型的所有条目的总和: 但我不知道如何获得每个月每种产品类型的金额。关于如何实现这一点,您有什么想法吗?因此,您需要在这里根据数据上的日期直方图字段进行分组,然后在产品类型上进行聚合或排序 因此,如上图所示,您需要做的是首先通过“日期直方图””与要存储的字段
但我不知道如何获得每个月每种产品类型的金额。关于如何实现这一点,您有什么想法吗?因此,您需要在这里根据数据上的日期直方图字段进行分组,然后在产品类型上进行聚合或排序 因此,如上图所示,您需要做的是首先通过“日期直方图””与要存储的字段(在您的情况下,字段名似乎是“时间戳””进行分组。您可以根据需要指定时间间隔,如每小时、每天、每月,也可以将其保留为“自动” 然后,您接下来需要像上面提到的那样,对产品类型进行分析 一旦你这么做了,我想你就可以走了 要交叉检查幕后发生的事情,您可以单击面板右上角的“查询检查器”,并将查询作为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"
}
您可以忽略周围的信息,因为这毕竟是虚拟数据
您也可以参考以下链接:
对于其他可能有类似查询但与Kibana相关的人来说,它甚至更简单。在“可视化”选项卡中,选择索引 步骤1:首先选择“日期直方图”字段,然后选择要使用的索引字段 步骤2:然后选择“术语”并选择要使用的索引字段 步骤3:可视化准备就绪