Kibana加載樣本數據


kibana 6.2 加載樣本數據

kibana loading sample data

下載樣本數據

# 莎士比亞經典作品
wget https://download.elastic.co/demos/kibana/gettingstarted/shakespeare_6.0.json

# 一組虛擬生成的賬戶數據
wget https://download.elastic.co/demos/kibana/gettingstarted/accounts.zip

# 一組虛擬生成的日志數據
wget https://download.elastic.co/demos/kibana/gettingstarted/logs.jsonl.gz

解壓文件

unzip accounts.zip
gunzip logs.jsonl.gz

數據格式

Shakespeare數據集

{
    "line_id": INT,
    "play_name": "String",
    "speech_number": INT,
    "line_number": "String",
    "speaker": "String",
    "text_entry": "String",
}

account數據集

{
    "account_number": INT,
    "balance": INT,
    "firstname": "String",
    "lastname": "String",
    "age": INT,
    "gender": "M or F",
    "address": "String",
    "employer": "String",
    "email": "String",
    "city": "String",
    "state": "String"
}

logs數據集

{
    "memory": INT,
    "geo.coordinates": "geo_point"
    "@timestamp": "date"
}

Mapping Fields

加載這些數據之前,需要先創建它們的索引,並創建字段映射

在Kibana的Dev Tools > Console中,創建索引

PUT /shakespeare
{
    "mappings": {
        "doc": {
            "properties": {
                "speaker": {"type": "keyword"},
                "play_name": {"type": "keyword"},
                "line_id": {"type": "integer"},
                "speech_number": {"type": "integer"}
            }
        }
    }
}
  • speakerplay_name被指定為keyword類型的字段,它們不會被分析器分析
  • line_idspeech_number被指定為integer類型

logs數據集需要映射經緯度

PUT /logstash-2015.05.18
{
    "mappings": {
        "log": {
            "properties": {
                "geo": {
                    "properties": {
                        "coordinates": {
                            "type": "geo_point"
                        }
                    }
                }
            }
        }
    }
}
PUT /logstash-2015.05.19
{
    "mappings": {
        "log": {
            "properties": {
                "geo": {
                    "properties": {
                        "coordinates": {
                            "type": "geo_point"
                        }
                    }
                }
            }
        }
    }
}
PUT /logstash-2015.05.20
{
    "mappings": {
        "log": {
            "properties": {
                "geo": {
                    "properties": {
                        "coordinates": {
                            "type": "geo_point"
                        }
                    }
                }
            }
        }
    }
}

accounts數據集使用默認的映射即可

加載數據集

curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/bank/account/_bulk?pretty' --data-binary @accounts.json

curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/shakespeare/doc/_bulk?pretty' --data-binary @shakespeare_6.0.json

curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/_bulk?pretty' --data-binary @logs.jsonl

查看是否成功加載

GET /_cat/indices?v


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM