[英]Elasticsearch buckets on results of aggregation
I am using ELK 7.x.我正在使用 ELK 7.x。 I would like a histogram or bar chart in Kibana on the results of an aggregation.
我想要 Kibana 中关于聚合结果的直方图或条形图。 As it's a bit abstract to explain, below is the equivalent SQL query.
由于解释起来有点抽象,下面是等效的 SQL 查询。
select count(*) as no_of_docs, doc_type
from documents
group by doc_type
15 pdf
21 doc
17 txt
1 ppt
A histogram or any chart as below:直方图或任何图表如下:
No of docs Count of doc type
(X-Axis) (Y-Axis)
1-10 1 [1 ppt occurrence in the 1-10 bucket]
11-20 2 [1 pdf, 1 txt occurrences in the 11-20 bucket]
21 and above 1 [1 doc occurrence in the 21 and above bucket]
It may not be straightforward, but I do think it should be possible.这可能并不简单,但我确实认为它应该是可能的。
I've come up with the below mapping and documents and accordingly created the a Vertical Bar visualizer.我想出了下面的映射和文档,并相应地创建了一个垂直条可视化工具。
PUT my_docs
{
"mappings": {
"properties": {
"doc_type":{
"type": "keyword"
}
}
}
}
POST my_docs/_doc/1
{
"doc_type": "pdf"
}
POST my_docs/_doc/2
{
"doc_type": "pdf"
}
POST my_docs/_doc/3
{
"doc_type": "pdf"
}
POST my_docs/_doc/4
{
"doc_type": "jpeg"
}
POST my_docs/_doc/5
{
"doc_type": "jpeg"
}
POST my_docs/_doc/6
{
"doc_type": "txt"
}
POST my_docs/_doc/7
{
"doc_type": "txt"
}
POST /_sql?format=txt
{
"query": "select count(*) as no_of_docs, doc_type from my_docs group by doc_type"
}
no_of_docs | doc_type
---------------+---------------
2 |jpeg
3 |pdf
2 |txt
Step 1:第1步:
First thing is you would require to create index pattern.第一件事是您需要创建索引模式。 You can check this link as how this could be done.
您可以查看此链接以了解如何完成此操作。
Basically visit Management > Kibana > Index Patterns and add the index ie my_docs
基本上访问Management > Kibana > Index Patterns并添加索引,即
my_docs
Step 2:第2步:
Visualize
button on the left side of KibanaVisualize
按钮create new visualization
create new visualization
Vertical Bar
visualizerVertical Bar
可视化工具my_docs
.my_docs
。 Note that if you haven't created index pattern, this index would not show up.Buckets
section click on Add and select X-axisBuckets
部分下,单击 Add 并选择 X-axisAggregation
field shows up.Aggregation
字段出现。Terms
and when you do that select doc_type
in the Field
section.Terms
, doc_type
在Field
部分选择doc_type
。Apply Changes
when you move your cursor on it) next to Panel Settings
on the top of this section where you configure the fields.Panel Settings
旁边的蓝色运行按钮(当您将光标移到它上面时,它应该显示Apply Changes
),您可以在其中配置字段。 Below is how the image appears for X-axis part:以下是 X 轴部分的图像显示方式:
Notice that your visualizer is ready.请注意,您的可视化工具已准备就绪。 Below is how it appears in my machine for the above sample data:
以下是它在我的机器中显示的上述示例数据的方式:
Let me know if this helps!让我知道这是否有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.