아무거나

키바나 매니지먼트(kibana management) 본문

Data Store/Elastic Stack

키바나 매니지먼트(kibana management)

전봉근 2019. 5. 14. 11:00
반응형

basketball_mapping.json
0.00MB
bulk_basketball.json
0.00MB

 

키바나 매니지먼트(kibana management)

1. curl -XDELETE localhost:9200/basketball  // 이전 basketball 인덱스를 삭제(새로 작업하기 위함)

 

2. curl -XPUT localhost:9200/basketball   // basketball 인덱스를 생성

 

3. curl -XPUT 'localhost:9200/basketball/record/_mapping' -d @basketball_mapping.json

# [basketball_mapping.json]

{
  "record" : {
	"properties" : {
      "team" : {
          "type" : "string",
          "fielddata" : true
      },
      "name" : {
          "type" : "string",
          "fielddata" : true
      },
      "points" : {
          "type" : "long"
      },
      "rebounds" : {
          "type" : "long"
      },
      "assists" : {
          "type" : "long"
      },
      "blocks" : {
          "type" : "long"
      },
      "submit_date" : {
          "type" : "date",
          "format" : "yyyy-MM-dd"
      }
    }
  }
}

 

4. sudo vi bulk_basketball.json

# [bulk_basketball.json]

{ "index" : { "_index" : "basketball", "_type" : "record", "_id" : "1" } }
{"team" : "Golden States Warriors","name" : "Stephen Curry", "points" : 30,"rebounds" : 3,"assists" : 4, "blocks" : 5, "submit_date" : "2016-10-11"}
{ "index" : { "_index" : "basketball", "_type" : "record", "_id" : "2" } }
{"team" : "Golden States Warriors","name" : "Stephen Curry","points" : 32,"rebound" : 5,"assist" : 8, "blocks" : 5, "submit_date" : "2016-10-13"}
{ "index" : { "_index" : "basketball", "_type" : "record", "_id" : "3" } }
{"team" : "Golden States Warriors","name" : "Stephen Curry","points" : 28,"rebound" : 2,"assist" : 3, "blocks" : 1, "submit_date" : "2016-10-17"}
{ "index" : { "_index" : "basketball", "_type" : "record", "_id" : "4" } }
{"team" : "Golden States Warriors","name" : "Stephen Curry","points" : 36,"rebound" : 1,"assist" : 2, "blocks" : 1, "submit_date" : "2016-11-20"}
{ "index" : { "_index" : "basketball", "_type" : "record", "_id" : "5" } }
{"team" : "Golden States Warriors","name" : "Stephen Curry","points" : 36,"rebound" : 1,"assist" : 2, "blocks" : 1, "submit_date" : "2016-11-25"}
{ "index" : { "_index" : "basketball", "_type" : "record", "_id" : "6" } }
{"team" : "Golden States Warriors","name" : "Stephen Curry","points" : 32,"rebound" : 1,"assist" : 4, "blocks" : 1, "submit_date" : "2016-11-28"}
{ "index" : { "_index" : "basketball", "_type" : "record", "_id" : "7" } }
{"team" : "Utah Jazz","name" : "Rudy Gobert", "points" : 3,"rebounds" : 11,"assists" : 4, "blocks" : 7, "submit_date" : "2016-10-12"}
{ "index" : { "_index" : "basketball", "_type" : "record", "_id" : "8" } }
{"team" : "Utah Jazz","name" : "Rudy Gobert","points" : 4,"rebound" : 13,"assist" : 8, "blocks" : 5, "submit_date" : "2016-10-14"}
{ "index" : { "_index" : "basketball", "_type" : "record", "_id" : "9" } }
{"team" : "Utah Jazz","name" : "Rudy Gobert","points" : 8,"rebound" : 10,"assist" : 3, "blocks" : 6, "submit_date" : "2016-10-18"}
{ "index" : { "_index" : "basketball", "_type" : "record", "_id" : "10" } }
{"team" : "Utah Jazz","name" : "Rudy Gobert","points" : 12,"rebound" : 9,"assist" : 2, "blocks" : 6, "submit_date" : "2016-11-10"}
{ "index" : { "_index" : "basketball", "_type" : "record", "_id" : "11" } }
{"team" : "Utah Jazz","name" : "Rudy Gobert","points" : 12,"rebound" : 14,"assist" : 2, "blocks" : 7, "submit_date" : "2016-11-22"}
{ "index" : { "_index" : "basketball", "_type" : "record", "_id" : "12" } }
{"team" : "Utah Jazz","name" : "Rudy Gobert","points" : 8,"rebound" : 10,"assist" : 4, "blocks" : 5, "submit_date" : "2016-11-27"}
{ "index" : { "_index" : "basketball", "_type" : "record", "_id" : "13" } }
{"team" : "Washington Wizards","name" : "John Wall","points" : 8,"rebound" : 1,"assist" : 13, "blocks" : 2, "submit_date" : "2016-10-18"}
{ "index" : { "_index" : "basketball", "_type" : "record", "_id" : "14" } }
{"team" : "Washington Wizards","name" : "John Wall","points" : 13,"rebound" : 2,"assist" : 12, "blocks" : 3, "submit_date" : "2016-11-10"}
{ "index" : { "_index" : "basketball", "_type" : "record", "_id" : "15" } }
{"team" : "Washington Wizards","name" : "John Wall","points" : 15,"rebound" : 3,"assist" : 12, "blocks" : 3, "submit_date" : "2016-11-22"}
{ "index" : { "_index" : "basketball", "_type" : "record", "_id" : "16" } }
{"team" : "Washington Wizards","name" : "John Wall","points" : 22,"rebound" : 4,"assist" : 14, "blocks" : 3, "submit_date" : "2016-11-27"}

 

5. 4번의 json데이터를 elasticsearch에 bulk 옵션을 주어 파일에 데이터를 넣자

   - curl -XPOST 'localhost:9200/_bulk' --data-binary @bulk_basketball.json

 

6. 위의 데이터를 넣는 것들을 kibana에서 확인하도록 하자

   - 키바나 웹 페이지에 접속

   - 좌측 메뉴중에 Management 를 클릭 -> index patterns 선택 -> logstash-* 이라고 되어있는 부분을 위에 인덱스를 설정한 basketball로 변경한다.

   - 그러면 basketball의 time filter field name이(시간관련 field -> 3번의 매핑참조) submit_date라는것을 알게 된다.

   - 그 다음 create 선택하면 확인할 수 있다.

반응형
Comments