Kibana 简明教程
Kibana - Working With Charts
让我们探索并了解在可视化中使用最广泛的图表。
Let us explore and understand the most commonly used charts in visualization.
-
Horizontal Bar Chart
-
Vertical Bar Chart
-
Pie Chart
以下是创建上述可视化的步骤。让我们从水平条形图开始。
The following are the steps to be followed to create above visualization. Let us start with Horizontal Bar.
Horizontal Bar Chart
打开 Kibana,然后单击左侧的 Visualize(可视化)选项卡,如下图所示 −
Open Kibana and click Visualize tab on left side as shown below −

单击 + 按钮以创建新的可视化 −
Click the + button to create a new visualization −

单击上面列出的 Horizontal Bar(水平条形图)。你必须选择要可视化的索引。
Click the Horizontal Bar listed above. You will have to make a selection of the index you want to visualize.

选择 countriesdata-28.12.2018 索引,如下图所示。选择索引后,将显示如下所示的屏幕 −
Select the countriesdata-28.12.2018 index as shown above. On selecting the index, it displays a screen as shown below −

该屏幕显示默认计数。现在,让我们绘制一个水平条形图,其中我们可以看到排名前 10 位国家的总人口。
It shows a default count. Now, let us plot a horizontal graph where we can see the data of top 10 country wise populations.
为此,我们需要选择 Y 和 X 轴上需要显示的内容。因此,选择 Bucket and Metric Aggregation(分组和度量聚合) −
For this purpose, we need to select what we want on the Y and X axis. Hence, select the Bucket and Metric Aggregation −

现在,如果你单击 Y-Axis(Y 轴),将显示如下所示的屏幕 −
Now, if you click on Y-Axis, it will display the screen as shown below −

现在,从这里显示的选项中选择聚合 −
Now, select the Aggregation that you want from the options shown here −

请注意,我们在此处选择最大值聚合,因为我们要根据可用最大人口来显示数据。
Note that here we will select the Max aggregation as we want to display data as per the max population available.
接下来,我们必须选择需要最大值的那个字段。在索引 countriesdata-28.12.2018 中,我们只有 2 个数字字段 - area(面积)和 population(人口)。
Next we have to select the field whose max value is required. In the index countriesdata-28.12.2018, we have only 2 numbers field – area and population.
由于我们要显示最大人口,因此选择 Population(人口)字段,如下图所示 −
Since we want the max population, we select the Population field as shown below −

通过此操作,我们在 Y 轴上完成操作。我们针对 Y 轴获取的输出如下所示:
By this, we are done with the Y-axis. The output that we get for Y-axis is as shown below −

现在让我们选择 X 轴,如下所示:
Now let us select the X-axis as shown below −

如果您选择 X 轴,那么将得到如下输出:
If you select X-Axis, you will get the following output −

选择按词条聚合。
Choose Aggregation as Terms.

从下拉菜单中选择字段。我们想要按照国家获取人口,所以选择国家字段。我们有以下排序选项:
Choose the field from the dropdown. We want country wise population so select country field. Order by we have following options −

我们将按最大人口排序,因为我们希望人口最多的国家优先显示。添加了所需数据后,单击指标数据顶部所示的应用更改按钮,如下所示:
We are going to choose the order by as Max Population as want the country with highest population to be displayed first and so on. Once the data we want is added click on the apply changes button on top of the Metrics data as shown below −

一旦你单击应用更改,我们将获得一个水平图形,其中我们可以看到中国是人口最多的国家,其次是印度、美国等。
Once you click apply changes, we have the horizontal graph wherein we can see that China is the country with highest population, followed by India, United States etc.

类似地,你可以通过选择所需的字段来绘制不同的图形。接下来,我们将此可视化效果保存为 max_population,以便以后用于创建仪表板。
Similarly, you can plot different graphs by choosing the field you want. Next, we will save this visualization as max_population to be used later for Dashboard creation.
在下一部分,我们将创建垂直条形图。
In the next section, we will create vertical bar chart.
Vertical Bar Chart
单击可视化选项卡,并使用垂直条形图和索引 countriesdata-28.12.2018 创建一个新的可视化效果。
Click the Visualize tab and create a new visualization using vertical bar and index as countriesdata-28.12.2018.
在此垂直条形图可视化效果中,我们将创建以国家地区为维度的条形图,即按照区域面积从大到小对国家进行展示。
In this vertical bar visualization, we will create bar graph with countries wise area, i.e. countries will be displayed with highest area.
因此,让我们选择 Y 和 X 轴,如下所示:
So let us select the Y and X axes as shown below −
X-axis

当我们在这里应用更改时,我们可以看到如下所示的输出:
When we apply the changes here, we can see the output as shown below −

从图形中,我们可以看到俄罗斯拥有最大的面积,其次是加拿大和美国。请注意,此数据是从国家数据索引中提取的,并且是虚拟数据,因此数字可能与实时数据不符。
From the graph, we can see that Russia is having the highest area, followed by Canada and United States. Please note this data is picked from the index countriesdata, and its dummy data, so figures might not be correct with live data.
让我们将此可视化效果保存为 countrywise_maxarea,以便以后与仪表板一起使用。
Let us save this visualization as countrywise_maxarea to be used with dashboard later.
接下来,让我们研究饼图。
Next, let us work on Pie chart.
Pie Chart
因此,首先创建一个可视化效果,然后选择索引为国家数据的饼图。我们要在饼图格式中显示国家数据中可用区域的数量。
So first create a visualization and select the pie chart with index as countriesdata. We are going to display the count of regions available in the countriesdata in pie chart format.
左侧具有提供数量的指标。在存储区中,有 2 个选项:拆分切片和拆分图表。现在,我们将使用拆分切片选项。
The left side has metrics which will give count. In Buckets, there are 2 options: Split slices and split chart. Now, we will use the option Split slices.

现在,如果你选择拆分切片,它将显示以下选项:
Now, if you select Split Slices, it will display the following options −

选择按词条聚合,它将显示更多选项,输入如下所示:
Select the Aggregation as Terms and it will display more options to be entered as follows −

字段下拉菜单将包含从所选索引中的所有字段。我们选择了区域字段,并将其排序方式选为计数。我们将按降序排序,大小设置为 10。因此,这里我们将获得国家索引的 10 个区域数量。
The Fields dropdown will have all the fields from the index chosen. We have selected Region field and Order By that we have selected as Count. We will order it Descending and the size will take as 10. So here we will be get the 10 regions count from the countries index.
现在,单击如下所示的高亮显示的播放按钮,你应该会在右侧看到更新后的饼图。
Now, click the play button as highlighted below and you should see the pie chart updated on the right side.

Pie chart display

所有区域均在右上角以颜色列出,并会在饼状图中显示相同颜色。将鼠标悬停在饼状图上,它将提供区域的数量及区域的名称,如下所示 −
All the regions are listed at the right top corner with colours and the same colour is shown in the pie chart. If you mouse over the pie chart, it will give the count of the region and also the name of the region as shown below −


由此,我们可以了解到 Sub-Saharan Afri 占 22.77% 的区域所上传的国家数据。
Thus, it tells us that 22.77% of region is occupied by Sub-Saharan Afri in the countries data we have uploaded.
从饼状图中,观察可知亚洲区域占 12.5%,数量为 28。
From the pie chart, observe that the Asia region covers 12.5% and the count is 28.
现在我们可以单击右上角的保存按钮保存可视化,如下所示 −
Now we can save the visualization by clicking the save button on top right corner as shown below −

现在,保存可视化以供以后在控制面板中使用。
Now, save the visualization so that it can be used later in dashboard.
