Data visualization Kibana

Based on an operation, we've got the data, then we will process the data, and therefore chose Kibana

      First to introduce,

        Kibana is an open source platform for analysis and visualization of Elasticsearch, used to search, view in Elasticsearch interactive store data in the index .

        Use Kibana, through a variety of charts for advanced data analysis and display .

   Kibana make huge amounts of data easier to understand. It is simple , browser-based user interface to quickly create real-time dashboard display Elasticsearch dynamic queries .

 

Enter the following:

      1. First, elasticsearch and kibana built on a server.

           Secondly, the establishment of an index kibana interface, and index elaticsearch established pairing.

        Step on the establishment of the index are as follows:

               1. Open the management of the management kibana

               2. Click the index patterns index module.

               3. Select the create index pattern module index.

            After entering the new index pages, indexing the index name and elasticsearch to establish correspondence , otherwise, the index kibana can not be created.

   Do not change into the next step which is the default option set, you can directly create.

 

 2.索引建立完成后,我们可以去discover选项,选择建立的索引,查看通过elaticsearch上传的数据

 

 

3.既然已经找到数据,那么我们就要对这些数据进行处理,我们选择可视化里面的创建折线图Line来展示。

 

然后选择想可视化的对应索引后,将出现如下界面。

 

 

选择X和Y的单位等,比如x轴选择时间作为单位,但是出现了以下问题:

匹配不到相应类型,也就是说,我在elaticsearch上传的时间不是kibana需要的date类型。那我们的时间是什么类型呢??

再回到当初的python上传数据的代码发现,第23行的这句话(在上一篇文里面):

y={'id':'1','time':str(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())),'value':str(val)}
 
发现time键对应的值是个字符串类型的啊!!!
OK,那我就改类型,把str改成date类型,可以运用python的datetime库,import datetime
str(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))---->datetime.date.today()
 
再仔细看看,发现,value对应的值也是str,当你在kibana操作的时候,字段里面的选项也是没有value选项的,现在知道了,
既然是str类型怎么能当成数字传上去呢,所以要把str类型转成number,即删除str()即可。
 
改完之后我们保存执行,在kibana中发现还是会报同样的错。为什么呢???
因为索引里面的字段类型是不能更改的,所以想变,就只能重新建立一个新的索引了,注意索引的名字一定不能相同!!!
 
再重复建立索引,建立可视化图的步骤,选择相应的X轴 Y轴后,我们的折线图就出来了。

 

Guess you like

Origin www.cnblogs.com/zx0423/p/11270426.html