티스토리 뷰

[업데이트 2016.12.01 01:15]

 

2) Kibana

Kibana의 경우도 설치된 path의 bin 디렉토리로 이동 후, kibana.bat를 실행하면 됩니다. 그리고 localhost 5601포트로 접속합니다. 참고로 Elasticsearch를 통해 Visualization해주기 때문에, Elasticsearch 서비스가 실행 되어 있어야 합니다.

 

http://localhost:5601/

 

다음과 같이 실행됨을 확인 후, 웹브라우저에서 위의 주소로 접속합니다.

 

 

다음와 같이 Kibana의 첫 화면을 볼 수 있습니다.

 

 

처음에 접속해보면 Elasticsearch index 식별을 위해 적어도 하나의 index pattern을 지정하라고 나옵니다. 해당 index에 time-based field가 없을 경우 Index contains time-based events를 uncheck 합니다.

 

* 참고: https://www.elastic.co/guide/en/kibana/current/connect-to-elasticsearch.html

* 참고: https://www.elastic.co/guide/en/kibana/current/tutorial-load-dataset.html

 

아래와 같이 @timestamp field가 있어야 Index contains time-based events를 사용할 수 있습니다.(Tutorial 링크 참고)

 

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



테스트를 해보기 위해서 위의 Tutorial에서 제공하는 json dataset을 curl을 통해 Elasticsearch에 import 합니다. 참고로 curl은 데이터 전송을 위한 command line 툴입니다. 보통 REST API 등 테스트를 위해 자주 사용한다고 합니다.

 

* 참고: https://www.lesstif.com/pages/viewpage.action?pageId=14745703#curl설치및사용법-HTTPGET/POST,RESTAPI연계등-개요

* 참고: https://winampplugins.co.uk/curl/

 

위의 Tutorial 내용을 참고하여 shakespeare란 데이터에 대한 mapping 정보를 import합니다. 저는 Kibana > Dev Tools > Console을 통해 import하였습니다. 아래의 내용을 복사하면 자동으로 import하도록 변경됩니다.

 

 

curl -XPUT http://localhost:9200/shakespeare -d '
{
 "mappings" : {
  "_default_" : {
   "properties" : {
    "speaker" : {"type": "string", "index" : "not_analyzed" },
    "play_name" : {"type": "string", "index" : "not_analyzed" },
    "line_id" : { "type" : "integer" },
    "speech_number" : { "type" : "integer" }
   }
  }
 }
}
';


 

 

 

이제 bulk API를 통해 json 데이터를 import합니다.

참고로 Windows 기준으로 HTTP 주소를 쓸때, 겹따옴표를 써야 합니다.("http://xxx:xxx")

 

 

curl -XPOST "http://localhost:9200/bank/account/_bulk?pretty" --data-binary @accounts.json
curl -XPOST "http://localhost:9200/shakespeare/_bulk?pretty" --data-binary @shakespeare.json
curl -XPOST "http://localhost:9200/_bulk?pretty" --data-binary @logs.jsonl


 

Import후 Kibana Web Console 또는 curl을 통해 index pattern에 대해 검색해보면(_cat API 사용) 정상적으로 추가 되었음을 확인 할 수 있습니다.

 

 

이제 Discover 매뉴로 가보면 다음과 같이 각 index pattern별로 데이터를 search할 수 있습니다.

 

 

검색창에 특정 필드의 조건을 주면 해당 조건에 맞게 다시 검색이 진행됩니다.

아래의 경우 age가 39세 이상인 데이터를 찾은 경우입니다. 조건식에 대해서는 아래의 링크 참조하시기 바랍니다.

 

* 참고: https://www.elastic.co/guide/en/kibana/current/tutorial-discovering.html

 

 

이제 Visualize 매뉴로 가서 시각화를 시켜봅니다. 예를 들면 아래와 같이 Pie차트를 사용하여 나이대별 잔고 현황을 볼 수 있습니다.

 

 

* 참고: https://www.elastic.co/guide/en/kibana/current/tutorial-visualizing.html

 

이제 Visualize했던 차트 및 Markdown 등을 Dashboard에서 한번에 보여주기 위해 Dashboard매뉴로 이동합니다. Dashboard 매뉴에서 Add를 눌러 기존에 만들었던 차트 등을 추가합니다.

 

 

다음과 같이 Dashboard에 차트 들이 추가 된 모습니다.

 

 

지금까지 Elasticsearch와 Kibana에 대해 간단히 사용법을 정리해보았습니다. 다양한 기능, API에 대한 정의들이 있는데, 모두 Elastic 홈페이지의 가이드를 통해 확인이 가능합니다.

 

다음은 Logstash를 설치해보고, 해당 서비스를 통해 수집된 로그 데이터를 Elasticsearch가 사용할 수 있도록 JSON으로 주기적으로 넘겨주는 부분에 대해 스터디해보려고 합니다.

 

<GitHub>

https://github.com/asyncbridge/analytics/tree/master/ELK

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함