kibana 6.2 加载样本数据
kibana loading sample data
下载样本数据
1# 莎士比亚经典作品 2wget https://download.elastic.co/demos/kibana/gettingstarted/shakespeare_6.0.json 3 4# 一组虚拟生成的账户数据 5wget https://download.elastic.co/demos/kibana/gettingstarted/accounts.zip 6 7# 一组虚拟生成的日志数据 8wget https://download.elastic.co/demos/kibana/gettingstarted/logs.jsonl.gz
解压文件
1unzip accounts.zip 2gunzip logs.jsonl.gz
数据格式
Shakespeare数据集
1{ 2 "line_id": INT, 3 "play_name": "String", 4 "speech_number": INT, 5 "line_number": "String", 6 "speaker": "String", 7 "text_entry": "String", 8}
account数据集
1{ 2 "account_number": INT, 3 "balance": INT, 4 "firstname": "String", 5 "lastname": "String", 6 "age": INT, 7 "gender": "M or F", 8 "address": "String", 9 "employer": "String", 10 "email": "String", 11 "city": "String", 12 "state": "String" 13}
logs数据集
1{ 2 "memory": INT, 3 "geo.coordinates": "geo_point" 4 "@timestamp": "date" 5}
Mapping Fields
加载这些数据之前,需要先创建它们的索引,并创建字段映射
在Kibana的Dev Tools > Console中,创建索引
1PUT /shakespeare 2{ 3 "mappings": { 4 "doc": { 5 "properties": { 6 "speaker": {"type": "keyword"}, 7 "play_name": {"type": "keyword"}, 8 "line_id": {"type": "integer"}, 9 "speech_number": {"type": "integer"} 10 } 11 } 12 } 13}
speaker和play_name被指定为keyword类型的字段,它们不会被分析器分析line_id和speech_number被指定为integer类型
logs数据集需要映射经纬度
1PUT /logstash-2015.05.18 2{ 3 "mappings": { 4 "log": { 5 "properties": { 6 "geo": { 7 "properties": { 8 "coordinates": { 9 "type": "geo_point" 10 } 11 } 12 } 13 } 14 } 15 } 16} 17 18 19PUT /logstash-2015.05.19 20{ 21 "mappings": { 22 "log": { 23 "properties": { 24 "geo": { 25 "properties": { 26 "coordinates": { 27 "type": "geo_point" 28 } 29 } 30 } 31 } 32 } 33 } 34} 35 36 37PUT /logstash-2015.05.20 38{ 39 "mappings": { 40 "log": { 41 "properties": { 42 "geo": { 43 "properties": { 44 "coordinates": { 45 "type": "geo_point" 46 } 47 } 48 } 49 } 50 } 51 } 52}
accounts数据集使用默认的映射即可
加载数据集
1curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/bank/account/_bulk?pretty' --data-binary @accounts.json 2 3curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/shakespeare/doc/_bulk?pretty' --data-binary @shakespeare_6.0.json 4 5curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/_bulk?pretty' --data-binary @logs.jsonl
查看是否成功加载
GET /_cat/indices?v