Kibana Graph的初步印象
首先
最近我在学习图形数据库相关知识,正好在这个过程中了解到了Kibana Graph的信息,于是就试着去使用了一下。
-
- http://qiita.com/nakamura-tsuyoshi/items/d284ad1eb7ca848d5d79
-
- http://qiita.com/nakamura-tsuyoshi/items/4a0cbf20ce9ba4c934b9
- http://qiita.com/nakamura-tsuyoshi/items/5ae38b04373a224d9a34
环境准备
安装 Elasticsearch
我会像往常一样从官方网站轻松安装。
确认版本
[root@elastic_test ec2-user]# curl localhost:9200
{
"name" : "Ord",
"cluster_name" : "elasticsearch",
"version" : {
"number" : "2.3.2",
"build_hash" : "b9e4a6acad4008027e4038f6abed7f7dba346f94",
"build_timestamp" : "2016-04-21T16:03:47Z",
"build_snapshot" : false,
"lucene_version" : "5.5.0"
},
"tagline" : "You Know, for Search"
}
接着进行Kibana的安装。
只需从官方网站轻松安装即可
访问http://ip:5601/即可查看屏幕。
我試著將圖表放進去看看。
需要在Elasticsearch和Kibana两个方面都安装插件,参考以下公式。
安装Elasticsearch的插件。
将许可证安装入去。
[root@elastic_test ~]# /usr/share/elasticsearch/bin/plugin install license
-> Installing license...
Trying https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/license/2.3.2/license-2.3.2.zip ...
Downloading .......DONE
Verifying https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/license/2.3.2/license-2.3.2.zip checksums if available ...
Downloading .DONE
Installed license into /usr/share/elasticsearch/plugins/license
安装图形插件
[root@elastic_test ~]# /usr/share/elasticsearch/bin/plugin install graph
-> Installing graph...
Trying https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/graph/2.3.2/graph-2.3.2.zip ...
Downloading ....DONE
Verifying https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/graph/2.3.2/graph-2.3.2.zip checksums if available ...
Downloading .DONE
Installed graph into /usr/share/elasticsearch/plugins/graph
安装Kibana的插件。
把图表放进去
[root@elastic_test ~]# /opt/kibana/bin/kibana plugin --install elasticsearch/graph/latest
Installing graph
Attempting to transfer from https://download.elastic.co/elasticsearch/graph/graph-latest.tar.gz
Transferring 69265 bytes....................
Transfer complete
Extracting plugin archive
Extraction complete
Optimizing and caching browser bundles...
Plugin installation complete
重新启动Kibana
[root@elastic_test ~]# /etc/init.d/kibana restart
kibana stopped.
kibana started
请确认在浏览器中是否已安装。
创建样本数据
数据结构
- 店子が複数あるショップのユーザの購入データをインデックスさせる
在Elasticsearch中创建模板。
[root@elastic_test ~]# curl -XPUT localhost:9200/_template/moall -d '
> {
> "order": 0,
> "template": "moall-*",
> "settings": {
> "index": {
> "number_of_shards": "1",
> "number_of_replicas": "0"
> }
> },
> "mappings": {
> "moall": {
> "_source": {
> "enabled": true
> },
> "properties": {
> "order_time": {
> "format": "YYYY-MM-dd HH:mm:ss",
> "type": "date"
> },
> "price": {
> "index": "not_analyzed",
> "type": "integer"
> },
> "user_id": {
> "index": "not_analyzed",
> "type": "integer"
> },
> "user_name": {
> "index": "not_analyzed",
> "type": "string"
> },
> "user_gender": {
> "index": "not_analyzed",
> "type": "string"
> },
> "user_age": {
> "index": "not_analyzed",
> "type": "integer"
> },
> "item_id": {
> "index": "not_analyzed",
> "type": "integer"
> },
> "item_name": {
> "index": "not_analyzed",
> "type": "string"
> },
> "shop_id": {
> "index": "not_analyzed",
> "type": "integer"
> },
> "shop_name": {
> "index": "not_analyzed",
> "type": "string"
> },
> "category_id": {
> "index": "not_analyzed",
> "type": "integer"
> },
> "category_name": {
> "index": "not_analyzed",
> "type": "string"
> }
> }
> }
> },
> "aliases": {
>
> }
> }'
{"acknowledged":true}
将数据输入
[root@elastic_test ~]# curl -X POST http://localhost:9200/moall-201604/moall/1 -d '
> {
> "order_time" : "2016-04-02 22:22:22",
> "price": 9500,
> "user_id": 1,
> "user_name": "user_name1",
> "user_gender": "male",
> "user_age": 37,
> "item_id": 1,
> "item_name": "商品A",
> "shop_id": 1,
> "shop_name": "ショップA",
> "category_id": 1,
> "category_name": "カテゴリ1"
> }'
{"_index":"moall-201604","_type":"moall","_id":"1","_version":1,"_shards":{"total":1,"successful":1,"failed":0},"created":true}
[root@elastic_test ~]# curl -X POST http://localhost:9200/moall-201604/moall/2 -d '
> {
> "order_time" : "2016-04-03 11:21:11",
> "price": 1000,
> "user_id": 2,
> "user_name": "user_name2",
> "user_gender": "male",
> "user_age": 17,
> "item_id": 1,
> "item_name": "商品A",
> "shop_id": 1,
> "shop_name": "ショップA",
> "category_id": 1,
> "category_name": "カテゴリ1"
> }'
{"_index":"moall-201604","_type":"moall","_id":"2","_version":1,"_shards":{"total":1,"successful":1,"failed":0},"created":true}
[root@elastic_test ~]# curl -X POST http://localhost:9200/moall-201604/moall/3 -d '
> {
> "order_time" : "2016-04-04 09:45:20",
> "price": 1200,
> "user_id": 3,
> "user_name": "user_name3",
> "user_gender": "female",
> "user_age": 27,
> "item_id": 2,
> "item_name": "商品B",
> "shop_id": 1,
> "shop_name": "ショップA",
> "category_id": 1,
> "category_name": "カテゴリ1"
> }'
{"_index":"moall-201604","_type":"moall","_id":"3","_version":1,"_shards":{"total":1,"successful":1,"failed":0},"created":true}
[root@elastic_test ~]# curl -X POST http://localhost:9200/moall-201604/moall/4 -d '
> {
> "order_time" : "2016-04-05 10:18:22",
> "price": 15000,
> "user_id": 4,
> "user_name": "user_name4",
> "user_gender": "male",
> "user_age": 44,
> "item_id": 3,
> "item_name": "商品C",
> "shop_id": 2,
> "shop_name": "ショップB",
> "category_id": 1,
> "category_name": "カテゴリ1"
> }'
{"_index":"moall-201604","_type":"moall","_id":"4","_version":1,"_shards":{"total":1,"successful":1,"failed":0},"created":true}
[root@elastic_test ~]# curl -X POST http://localhost:9200/moall-201604/moall/5 -d '
> {
> "order_time" : "2016-03-22 10:18:22",
> "price": 2000,
> "user_id": 1,
> "user_name": "user_name1",
> "user_gender": "male",
> "user_age": 37,
> "item_id": 4,
> "item_name": "商品D",
> "shop_id": 3,
> "shop_name": "ショップC",
> "category_id": 2,
> "category_name": "カテゴリ2"
> }'
{"_index":"moall-201604","_type":"moall","_id":"5","_version":1,"_shards":{"total":1,"successful":1,"failed":0},"created":true}
[root@elastic_test ~]# curl -X POST http://localhost:9200/moall-201604/moall/6 -d '
> {
> "order_time" : "2016-02-11 10:18:22",
> "price": 4000,
> "user_id": 2,
> "user_name": "user_name2",
> "user_gender": "male",
> "user_age": 17,
> "item_id": 4,
> "item_name": "商品D",
> "shop_id": 3,
> "shop_name": "ショップC",
> "category_id": 2,
> "category_name": "カテゴリ2"
> }'
{"_index":"moall-201604","_type":"moall","_id":"6","_version":1,"_shards":{"total":1,"successful":1,"failed":0},"created":true}
[root@elastic_test ~]# curl -X POST http://localhost:9200/moall-201604/moall/7 -d '
> {
> "order_time" : "2016-03-25 10:18:22",
> "price": 5000,
> "user_id": 1,
> "user_name": "user_name1",
> "user_gender": "male",
> "user_age": 37,
> "item_id": 5,
> "item_name": "商品E",
> "shop_id": 3,
> "shop_name": "ショップC",
> "category_id": 2,
> "category_name": "カテゴリ2"
> }'
{"_index":"moall-201604","_type":"moall","_id":"7","_version":1,"_shards":{"total":1,"successful":1,"failed":0},"created":true}
使用 Kibana 的图表来确认
- 購入ユーザと商品を表示させた
-
- 購入ユーザと商品とショップを表示させた
- user_name1はショップCで2回購入しているためラインが太く表現されている
以下のように中国語で言い換えます:
目前正在进行中的请求。
有关一些卡住的重点或备忘录
由于样本数据太少,如果不更改设定值,图表将无法显示出来。
-
- significant設定を外した。多く使われてる重要語を抽出してくれる的な機能。詳しい説明は下記あたり。
https://www.elastic.co/guide/en/graph/current/graph-api-rest.html#api-rest-graph-explore
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html
Certaintyを1に設定した
无法同时指定多个不同的索引。
- 購入データに関してのグラフとuserどうしのつながりのグラフを一緒に観てみる的なことが無理?みたいです
无法以好的方式移动出现的图表。
-
- クリックしてドラッグしてこのアイテムはこのスペースに持ってきて、・・・的な操作はできなかった
- 拡大、縮小、移動はできたけど
在中国语言中,无法为物品和物品之间的连结赋予种类。
- 例えばグラフDBだとrelationsを作る際にfrendsを表すrelationと身内を表すrelationを分けて貼れたりするけど、それ系のものができなかった
导入非常容易
-
- すでに何かのデータをelasticsearchに入れて運用していれば、プラグインでとりあえずインストールすれば使える。
-
- 新たな視点でのデータの見える化ができて良さそう
社内ツール向きかな
仅仅重启Kibana是不够的,还需要重启elasticsearch。
如果不重新启动,会产生以下这样的错误。
[2016-05-05 09:26:21,130][DEBUG][action.admin.indices.mapping.put] [Ord] failed to put mappings on indices [[moall-201604]], type [_graph]
InvalidTypeNameException[Document mapping type name can't start with '_']
at org.elasticsearch.cluster.metadata.MetaDataMappingService$PutMappingExecutor.applyRequest(MetaDataMappingService.java:288)
at org.elasticsearch.cluster.metadata.MetaDataMappingService$PutMappingExecutor.execute(MetaDataMappingService.java:230)
at org.elasticsearch.cluster.service.InternalClusterService.runTasksForExecutor(InternalClusterService.java:468)
at org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:772)
at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:231)
at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:194)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
最后
-
- 何と言っても導入が楽なので既存のインデックスに試してみて、可視化させてみたらあたらしいデータ的な特徴が見つかるかもなぁと思った。
-
- 30日間は無料みたいだが、それ以降はライセンス契約が必要。どの程度費用かかるか少し探してみたけど見つからなかった
- まぁものが全然違うのでGraphDBと比較みたいな視点はあまり意味がないと思った