Elastic Search

KIBANA.샘플데이터 로드

jake_kim 2019. 5. 9. 14:11
반응형

[참조.한글] https://www.elastic.co/guide/kr/kibana/current/tutorial-load-dataset.html

[참조.영문]https://www.elastic.co/guide/en/kibana/current/tutorial-load-dataset.html#_set_up_mappings 

한글과영문은 동일.

한글 매뉴얼은 가끔 오류가 나니 영문 참조하는 걸 권유 (Ex> shakespeare mapping )

 

1)

curl -O https://download.elastic.co/demos/kibana/gettingstarted/7.x/shakespeare.json
curl -O https://download.elastic.co/demos/kibana/gettingstarted/7.x/accounts.zip
curl -O https://download.elastic.co/demos/kibana/gettingstarted/7.x/logs.jsonl.gz

 

 

2)

unzip accounts.zip

unzip logs.jsonl.gz

 

3) 

curl -X PUT "localhost:9200/shakespeare" -H 'Content-Type: application/json' -d'
{
  "mappings": {
    "properties": {
    "speaker": {"type": "keyword"},
    "play_name": {"type": "keyword"},
    "line_id": {"type": "integer"},
    "speech_number": {"type": "integer"}
    }
  }
}
'

 

curl -X PUT "localhost:9200/logstash-2015.05.18" -H 'Content-Type: application/json' -d'
{
  "mappings": {
    "properties": {
      "geo": {
        "properties": {
          "coordinates": {
            "type": "geo_point"
          }
        }
      }
    }
  }
}
'

 

curl -X PUT "localhost:9200/logstash-2015.05.19" -H 'Content-Type: application/json' -d'
{
  "mappings": {
    "properties": {
      "geo": {
        "properties": {
          "coordinates": {
            "type": "geo_point"
          }
        }
      }
    }
  }
}
'

 

curl -X PUT "localhost:9200/logstash-2015.05.20" -H 'Content-Type: application/json' -d'
{
  "mappings": {
    "properties": {
      "geo": {
        "properties": {
          "coordinates": {
            "type": "geo_point"
          }
        }
      }
    }
  }
}
'

 

4) 

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

 

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

 

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

 

 

5) Shakespeare Index Pattern 생성

순서 1) Kibana 5601 port 접속 > 왼쪽 메뉴 Management > Kibana 서브 메뉴> 아래 Index Pattern 클릭

순서 2) Create index pattern 클릭

순서 3) Step 1 of 2: Define index pattern 에서 shakes* 입력후 다음

순서 4) Step 2 of 2: Configure settings 에서 Create index pattern 클릭

 

6) bank Index Pattern 생성

순서 1) Kibana 5601 port 접속 > 왼쪽 메뉴 Management > Kibana 서브 메뉴> 아래 Index Pattern 클릭

순서 2) Create index pattern 클릭

순서 3) Step 1 of 2: Define index pattern 에서 ba* 입력후 다음

순서 4) Step 2 of 2: Configure settings 에서 Create index pattern 클릭

 

7) Logstash Index Pattern 생성

순서 1) Kibana 5601 port 접속 > 왼쪽 메뉴 Management > Kibana 서브 메뉴> 아래 Index Pattern 클릭

순서 2) Create index pattern 클릭

순서 3) Step 1 of 2: Define index pattern 에서 logstash* 입력후 다음

순서 4) @timestamp 선택

순서 5) Step 2 of 2: Configure settings 에서 Create index pattern 클릭

 

8) Kibana 에서 데이터 확인하기.

순서 1) Kibana > 왼쪽 메뉴 Discover 선택

순서 2) 좌측 Filter 아래에서 ba* 선택

순서 3) Filter 에 "account_number<100 AND balance>47500" 입력후 업데이트 클릭하면 결과가 나타난다.

          Filter Bar 우측 "Lucene" 을 클릭하면 On/ Off 나타나는데, Toggle 하면 KQL 로 바꿔야 한다.

* Available Field 에서 add 하면, 원하는 컬럼만 볼 수 있다.

 

9) Kibana 에서 bank 데이터 Visualize 하기.

참고) Visualize 선택시, 우측에 나타나는 목록은 Visaulize 저장된 목록이다.

순서 1) Kibana > 왼쪽 메뉴 Visualize 선택 > 우측 상단 + 클릭 > pie 선택

순서 2) Index Pattern 는 ba* 선택.

순서 3) 왼쪽 중간에 있는 Bucket 메뉴에서 Split Slices 선택.

순서 4) Range 는 Aggregation 선택.
순서 5) Field 는 balance.
순서 6) Range 는 0~999, 1000~2999, 3000~6999, 7000~14999, 15000~30999, 31000~50000 을 입력 후, ▶ (Apply changes) 클릭

순서 7) Save 메뉴 클릭해서 Pie 로 저장.

 

 

10) Kibana 에서 Shakespear 데이터 Visualize 하기.

순서 1) Kibana > 왼쪽 메뉴 Visualize 선택 > 우측 상단 + 클릭 > Vertical bar 선택

순서 2) Index Pattern 는 shake* 선택.

순서 3) 왼쪽 중간에 있는 Metrics 에서, Y-Axis 클릭.

순서 4) Aggregation 을 Unique Count 로 변경, Field 는 Speaker 로 선택. Custom Lable 은 "Speaking Parts"

순서 5) 왼쪽 아래에 있는 Buckets 에서 X-Axis 클릭.
순서 6) Aggregation 을 Terms 으로 설정 및 Field 를 play_name 로 설정.
순서 7) Order by 는 alphabetically 로 설정, Order 는 Ascending으로 설정.
순서 8) custom label 은 "Play Name" 으로 설정.

순서 9) ▶ (Apply changes) 클릭
순서 10) Save 메뉴 클릭해서 Bar 로 저장.

 

11) Kibana 에서 logstach 데이터 Visualize 하기.

순서 1) Kibana > 왼쪽 메뉴 Visualize 선택 > 우측 상단 + 클릭 > Coordinate map 선택

순서 2) Index Pattern 는 logstash* 선택.

순서 3) 상단 Filter 바 우측의 "타임 Picker 바"에서 Absolute / 20150518 ~ 20150520 선택

순서 4) 왼쪽 아래에 있는 Buckets 에서 Geo Coordinates 클릭.

순서 5) Aggregation 을 Geohash  로 설정 및 Field 를 geo.coordinates 선택.
순서 6) 
순서 7) 
순서 8) 

순서 9) ▶ (Apply changes) 클릭
순서 10) Save 메뉴 클릭해서 Bar 로 저장.

 

12) Kibana 에서 

반응형