'elastic'에 해당되는 글 130건

  1. 2016.11.21 [Kibana] Date Histogram Advanced DSL
  2. 2016.11.02 [Elasticsearch] Elasticsearch 5.0 GA 살펴보기 - 2
  3. 2016.11.02 [Elasticsearch] Elasticsearch 5.0 GA 살펴보기 - 1
  4. 2016.11.01 [Elasticsearch] Multi fields 질의
  5. 2016.08.16 [Logstash] Exception 에러로그 detection.
  6. 2016.05.18 [Logstash] input-http, filter-mutate,grok 샘플 config
  7. 2016.03.31 [Kafka] 재미로 본 Elastic Stack과 Kafka 매칭
  8. 2015.10.30 [Review] Modeling data for fast aggregations - on Elastic's Blog
  9. 2015.10.27 [Filebeat] 가볍게 사용해 볼까요?
  10. 2015.09.09 [Elastic] Elastic 제품들...

[Kibana] Date Histogram Advanced DSL

Elastic/Kibana 2016. 11. 21. 10:34

Kibana 를 사용하면서 많이 사용하는 것중 하나가 바로 Date Histogram Aggregation 입니다.

기본 결과에 대한 정렬은 count 에 대한 desc 으로 결과가 전달 되는데요.

날짜에 대한 desc 정렬을 하고 싶은 경우 아래와 같은 스크립트를 추가 하시면 됩니다.


제가 많이 사용하는 스크립트라 매번 타이핑 하기 귀찮아서 올려 봅니다.


{

"field":"time",

"interval":"1w",

  "order": {

    "_key": "desc"

  }

}


- field 값에 time 을 넣은 이유는 @timestamp 를 사용하기 않기 때문 입니다. :)

- order 에 사용 가능한 field 는 

Date Histogram 에서는 _key, _count

Terms 에서는 _term, _count

입니다.


:

[Elasticsearch] Elasticsearch 5.0 GA 살펴보기 - 2

Elastic/Elasticsearch 2016. 11. 2. 17:49

site plugin head 설치를 해보려 합니다.

설치 방법이 달라졌습니다.


[사전준비]

Elasticsearch 5.0 GA 살펴보기 - 1 에서 클러스터 구성

그냥 bin/elasticsearch, bin/elasticsearch 두 번 하시면 됩니다.


[설치 명령어]

https://www.elastic.co/guide/en/elasticsearch/plugins/current/installation.html#_core_elasticsearch_plugins


$ bin/elasticsearch-plugin install [plugin-name]


[Head Plugins]

https://github.com/mobz/elasticsearch-head#running-with-built-in-server


설치 방법은 위 문서에 잘 나와 있습니다.

아래는 제가 그냥 실행한 명령어를 나열 하였습니다.


$ git clone git://github.com/mobz/elasticsearch-head.git

$ cd elasticsearch-head/

$ npm install

$ sudo npm install -g grunt-cli

$ grunt server


[Head 접속]

$ open http://localhost:9100

- cross origin  정책으로 인해서 초기 접속이 되지 않습니다.

- elasticsearch.yml 에 아래 내용 추가해 주시고 재실행 하시면 됩니다.


[Cross Origin 정책수정]

$ vi config/elasticsearch.yml


http.cors.enabled: true

http.cors.allow-origin: "*"




노드명이 많이 아쉽내요 ㅠ.ㅠ

:

[Elasticsearch] Elasticsearch 5.0 GA 살펴보기 - 1

Elastic/Elasticsearch 2016. 11. 2. 17:11
내년에 업그레이드를 해야 하기 때문에 한번 살펴 보고자 합니다.

오늘은 가볍게 다운 받고 압축 풀고 기본 구조가 어떻게 변경이 되었나 한번 살펴 보려 합니다.


[다운로드]

https://www.elastic.co/downloads/elasticsearch


$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.0.0.tar.gz


[압축해제]

$ tar -xvzf elasticsearch-5.0.0.tar.gz

$ ln -s elasticsearch-5.0.0 elasticsearch


[바로실행]

$ bin/elasticsearch


[2016-11-02T16:52:22,051][INFO ][o.e.n.Node               ] [] initializing ...

[2016-11-02T16:52:22,246][INFO ][o.e.e.NodeEnvironment    ] [DiStpli] using [1] data paths, mounts [[/ (/dev/disk1)]], net usable_space [734.4gb], net total_space [930.3gb], spins? [unknown], types [hfs]

[2016-11-02T16:52:22,247][INFO ][o.e.e.NodeEnvironment    ] [DiStpli] heap size [1.9gb], compressed ordinary object pointers [true]

[2016-11-02T16:52:22,248][INFO ][o.e.n.Node               ] [DiStpli] node name [DiStpli] derived from node ID; set [node.name] to override

[2016-11-02T16:52:22,268][INFO ][o.e.n.Node               ] [DiStpli] version[5.0.0], pid[14095], build[253032b/2016-10-26T04:37:51.531Z], OS[Mac OS X/10.12.1/x86_64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_72/25.72-b15]

[2016-11-02T16:52:23,487][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [aggs-matrix-stats]

[2016-11-02T16:52:23,487][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [ingest-common]

[2016-11-02T16:52:23,488][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [lang-expression]

[2016-11-02T16:52:23,488][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [lang-groovy]

[2016-11-02T16:52:23,488][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [lang-mustache]

[2016-11-02T16:52:23,488][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [lang-painless]

[2016-11-02T16:52:23,488][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [percolator]

[2016-11-02T16:52:23,488][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [reindex]

[2016-11-02T16:52:23,488][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [transport-netty3]

[2016-11-02T16:52:23,488][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [transport-netty4]

[2016-11-02T16:52:23,489][INFO ][o.e.p.PluginsService     ] [DiStpli] no plugins loaded

[2016-11-02T16:52:27,399][INFO ][o.e.n.Node               ] [DiStpli] initialized

[2016-11-02T16:52:27,399][INFO ][o.e.n.Node               ] [DiStpli] starting ...

[2016-11-02T16:52:27,809][INFO ][o.e.t.TransportService   ] [DiStpli] publish_address {127.0.0.1:9300}, bound_addresses {[fe80::1]:9300}, {[::1]:9300}, {127.0.0.1:9300}

[2016-11-02T16:52:30,900][INFO ][o.e.c.s.ClusterService   ] [DiStpli] new_master {DiStpli}{DiStpli8S4-rE5QKCPP_Lw}{bwHQPV_UTl6NSPCfx8IE3w}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)

[2016-11-02T16:52:30,974][INFO ][o.e.h.HttpServer         ] [DiStpli] publish_address {127.0.0.1:9200}, bound_addresses {[fe80::1]:9200}, {[::1]:9200}, {127.0.0.1:9200}

[2016-11-02T16:52:30,974][INFO ][o.e.n.Node               ] [DiStpli] started

[2016-11-02T16:52:30,975][INFO ][o.e.g.GatewayService     ] [DiStpli] recovered [0] indices into cluster_state


[접속]

http://localhost:9200


{
  "name" : "DiStpli",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "eA4iUJ4BSoOxmoDbLjFgoQ",
  "version" : {
    "number" : "5.0.0",
    "build_hash" : "253032b",
    "build_date" : "2016-10-26T04:37:51.531Z",
    "build_snapshot" : false,
    "lucene_version" : "6.2.0"
  },
  "tagline" : "You Know, for Search"
}



[디렉토리구조]

$ ls -al

total 56

drwxr-xr-x  12  staff    408 11  2 16:52 .

drwxr-xr-x  34  staff   1156 11  2 16:45 ..

-rw-r--r--   1  staff  11358 10 26 13:35 LICENSE.txt

-rw-r--r--   1  staff    150 10 26 13:35 NOTICE.txt

-rw-r--r--   1  staff   9108 10 26 13:35 README.textile

drwxr-xr-x  15  staff    510 10 26 13:40 bin

drwxr-xr-x   6  staff    204 11  2 16:52 config

drwxr-xr-x   3  staff    102 11  2 16:52 data

drwxr-xr-x  36  staff   1224 10 26 13:40 lib

drwxr-xr-x   6  staff    204 11  2 16:52 logs

drwxr-xr-x  12  staff    408 10 26 13:40 modules

drwxr-xr-x   2  staff     68 11  2 16:52 plugins


- 실행 후 모습 입니다.


[디렉토리 bin]

- 실행 파일들이 위치해 있습니다.


[디렉토리 config]

- elasticsearch.yml 은 그대로 존재 합니다.

- logging.yml 은 log4j2.properties 로 변경 되었습니다.

- jvm.options 가 추가 되었습니다.

기존에 실행 시 설정에 필요했던 jvm 옵션을 스크립트에 추가 하기 위해 커스텀하게 사용했는데요. 이 옵션이 생겨서 좀 더 유연해 졌내요.

- scripts 디렉토리가 생겼습니다.

잘 아시겠지만 각종 script 관련 코드를 이곳에 저장하고 읽어 들일 수 있도록 된 것 같습니다.


[디렉토리 data]

- 예전 그대로 같지만 조금 달라졌습니다.

즉, 예전에는 data/클러스터명/nodes/0 뭐 이런 식이였는데요.

지금은 data/nodes/0 으로 생성이 되내요.

클러스터명이 사라졌내요. (여전히 default cluster_name 은 elasticsearch 입니다.)


[디렉토리 lib]

- 바뀐건 종속 라이브러리가 바뀌었내요.


[디렉토리 modules]

- elastic 에서 제공하는 추가 modules 들이 들어 있습니다.


[디렉토리 plugins]

- 바뀐건 아마도 plugin 만드는 방법이 바뀌었을 것 같습니다.


[초간단 클러스터 구성 테스트]

- 기본적으로 elasticsearch 는 bin/elasticsearch 를 여러번 실행 하면 클러스터로 묶어 줍니다.

단, 인스턴스를 분리 하셔야 합니다.


$ bin/elasticsearch

[2016-11-02T17:21:04,689][INFO ][o.e.n.Node               ] [] initializing ...

[2016-11-02T17:21:04,770][INFO ][o.e.e.NodeEnvironment    ] [npjHq7P] using [1] data paths, mounts [[/ (/dev/disk1)]], net usable_space [734.4gb], net total_space [930.3gb], spins? [unknown], types [hfs]

[2016-11-02T17:21:04,771][INFO ][o.e.e.NodeEnvironment    ] [npjHq7P] heap size [1.9gb], compressed ordinary object pointers [true]

[2016-11-02T17:21:04,772][INFO ][o.e.n.Node               ] [npjHq7P] node name [npjHq7P] derived from node ID; set [node.name] to override

[2016-11-02T17:21:04,773][INFO ][o.e.n.Node               ] [npjHq7P] version[5.0.0], pid[14680], build[253032b/2016-10-26T04:37:51.531Z], OS[Mac OS X/10.12.1/x86_64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_72/25.72-b15]

[2016-11-02T17:21:05,375][INFO ][o.e.p.PluginsService     ] [npjHq7P] loaded module [aggs-matrix-stats]

[2016-11-02T17:21:05,375][INFO ][o.e.p.PluginsService     ] [npjHq7P] loaded module [ingest-common]

[2016-11-02T17:21:05,376][INFO ][o.e.p.PluginsService     ] [npjHq7P] loaded module [lang-expression]

[2016-11-02T17:21:05,376][INFO ][o.e.p.PluginsService     ] [npjHq7P] loaded module [lang-groovy]

[2016-11-02T17:21:05,376][INFO ][o.e.p.PluginsService     ] [npjHq7P] loaded module [lang-mustache]

[2016-11-02T17:21:05,376][INFO ][o.e.p.PluginsService     ] [npjHq7P] loaded module [lang-painless]

[2016-11-02T17:21:05,376][INFO ][o.e.p.PluginsService     ] [npjHq7P] loaded module [percolator]

[2016-11-02T17:21:05,376][INFO ][o.e.p.PluginsService     ] [npjHq7P] loaded module [reindex]

[2016-11-02T17:21:05,376][INFO ][o.e.p.PluginsService     ] [npjHq7P] loaded module [transport-netty3]

[2016-11-02T17:21:05,376][INFO ][o.e.p.PluginsService     ] [npjHq7P] loaded module [transport-netty4]

[2016-11-02T17:21:05,377][INFO ][o.e.p.PluginsService     ] [npjHq7P] no plugins loaded

[2016-11-02T17:21:06,764][INFO ][o.e.n.Node               ] [npjHq7P] initialized

[2016-11-02T17:21:06,765][INFO ][o.e.n.Node               ] [npjHq7P] starting ...

[2016-11-02T17:21:06,895][INFO ][o.e.t.TransportService   ] [npjHq7P] publish_address {127.0.0.1:9301}, bound_addresses {[fe80::1]:9301}, {[::1]:9301}, {127.0.0.1:9301}

[2016-11-02T17:21:09,996][INFO ][o.e.c.s.ClusterService   ] [npjHq7P] detected_master {DiStpli}{DiStpli8S4-rE5QKCPP_Lw}{oJ9y-SxJTYex3ZNBmRIpoQ}{127.0.0.1}{127.0.0.1:9300}, added {{DiStpli}{DiStpli8S4-rE5QKCPP_Lw}{oJ9y-SxJTYex3ZNBmRIpoQ}{127.0.0.1}{127.0.0.1:9300},}, reason: zen-disco-receive(from master [master {DiStpli}{DiStpli8S4-rE5QKCPP_Lw}{oJ9y-SxJTYex3ZNBmRIpoQ}{127.0.0.1}{127.0.0.1:9300} committed version [7]])

[2016-11-02T17:21:10,030][INFO ][o.e.h.HttpServer         ] [npjHq7P] publish_address {127.0.0.1:9201}, bound_addresses {[fe80::1]:9201}, {[::1]:9201}, {127.0.0.1:9201}

[2016-11-02T17:21:10,031][INFO ][o.e.n.Node               ] [npjHq7P] started



$ bin/elasticsearch

[2016-11-02T17:19:34,869][INFO ][o.e.n.Node               ] [] initializing ...

[2016-11-02T17:19:35,074][INFO ][o.e.e.NodeEnvironment    ] [DiStpli] using [1] data paths, mounts [[/ (/dev/disk1)]], net usable_space [734.4gb], net total_space [930.3gb], spins? [unknown], types [hfs]

[2016-11-02T17:19:35,074][INFO ][o.e.e.NodeEnvironment    ] [DiStpli] heap size [1.9gb], compressed ordinary object pointers [true]

[2016-11-02T17:19:35,076][INFO ][o.e.n.Node               ] [DiStpli] node name [DiStpli] derived from node ID; set [node.name] to override

[2016-11-02T17:19:35,079][INFO ][o.e.n.Node               ] [DiStpli] version[5.0.0], pid[14588], build[253032b/2016-10-26T04:37:51.531Z], OS[Mac OS X/10.12.1/x86_64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_72/25.72-b15]

[2016-11-02T17:19:37,110][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [aggs-matrix-stats]

[2016-11-02T17:19:37,111][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [ingest-common]

[2016-11-02T17:19:37,111][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [lang-expression]

[2016-11-02T17:19:37,111][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [lang-groovy]

[2016-11-02T17:19:37,111][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [lang-mustache]

[2016-11-02T17:19:37,111][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [lang-painless]

[2016-11-02T17:19:37,111][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [percolator]

[2016-11-02T17:19:37,111][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [reindex]

[2016-11-02T17:19:37,111][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [transport-netty3]

[2016-11-02T17:19:37,111][INFO ][o.e.p.PluginsService     ] [DiStpli] loaded module [transport-netty4]

[2016-11-02T17:19:37,111][INFO ][o.e.p.PluginsService     ] [DiStpli] no plugins loaded

[2016-11-02T17:19:40,144][INFO ][o.e.n.Node               ] [DiStpli] initialized

[2016-11-02T17:19:40,145][INFO ][o.e.n.Node               ] [DiStpli] starting ...

[2016-11-02T17:19:40,356][INFO ][o.e.t.TransportService   ] [DiStpli] publish_address {127.0.0.1:9300}, bound_addresses {[fe80::1]:9300}, {[::1]:9300}, {127.0.0.1:9300}



[2016-11-02T17:19:43,625][INFO ][o.e.c.s.ClusterService   ] [DiStpli] new_master {DiStpli}{DiStpli8S4-rE5QKCPP_Lw}{oJ9y-SxJTYex3ZNBmRIpoQ}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)

[2016-11-02T17:19:43,742][INFO ][o.e.g.GatewayService     ] [DiStpli] recovered [0] indices into cluster_state

[2016-11-02T17:19:43,750][INFO ][o.e.h.HttpServer         ] [DiStpli] publish_address {127.0.0.1:9200}, bound_addresses {[fe80::1]:9200}, {[::1]:9200}, {127.0.0.1:9200}

[2016-11-02T17:19:43,750][INFO ][o.e.n.Node               ] [DiStpli] started

[2016-11-02T17:21:09,966][INFO ][o.e.c.s.ClusterService   ] [DiStpli] added {{npjHq7P}{npjHq7PlTqqiB2bhXkIxqQ}{IhQPGv_rTsyd7a1DbXFMwA}{127.0.0.1}{127.0.0.1:9301},}, reason: zen-disco-node-join[{npjHq7P}{npjHq7PlTqqiB2bhXkIxqQ}{IhQPGv_rTsyd7a1DbXFMwA}{127.0.0.1}{127.0.0.1:9301}]

[2016-11-02T17:21:10,007][WARN ][o.e.d.z.ElectMasterService] [DiStpli] value for setting "discovery.zen.minimum_master_nodes" is too low. This can result in data loss! Please set it to at least a quorum of master-eligible nodes (current value: [-1], total number of master-eligible nodes used for publishing in this round: [2])

- 친절하게 quorum 구성 하라고 메시지도 보여 주내요.

:

[Elasticsearch] Multi fields 질의

Elastic/Elasticsearch 2016. 11. 1. 13:33

요즘 추천 데이터 만드느라 도통 mapping 정보 설계나 dsl 작성을 안했더니 까먹기 일수내요.

그래서 그냥 기억하는 차원에서 가볍게 작성해 봅니다.


[참고문서]

https://www.elastic.co/guide/en/elasticsearch/reference/2.4/multi-fields.html


[설명]

- 예전에는 multi-field 라고 했고 지금은 fields 라고 합니다.

- fields 의 용도는 단일 field 에 여러가지 속성을 부여하고 싶을 때 사용을 합니다.


예를 들면)

- index:analyzed 로 선언을 했는데 정렬을 해야 할 경우.

- index:not_analyzed 로 선언을 했는데 같은 value로 fulltext 검색을 해야 할 경우.


보통은 index:analyzed 로 선언 하고 fields 로 index:not_analyzed 로 구성 하는게 많습니다.


[mappings 정보]

...중략...

"keyword": { "type":"string", "index":"analyzed", "analyzer":"edge_ngram_analyzer", "index_options":"docs", "norms": { "enabled":false },

  "fields": {

    "exact": {

      "type":"string", "index":"not_analyzed", "store":"no"

    }

  }

},

...중략...

- 위 맵핑 정보는 제가 자동완성에서 사용하는 정보를 일부 발췌한 내용입니다.


[query dsl]

{

  "query": {

    "term": {

      "keyword.exact": "향수"

    }

  }

}

- 질의는 위에서와 같이 .(dot) 을 이용해서 field 명을 사용하시면 됩니다.

:

[Logstash] Exception 에러로그 detection.

Elastic/Logstash 2016. 8. 16. 12:35

바빠서 초간단 버전 업데이트 합니다.


1. patterns 생성)

잘 아시겠지만 grok filter 에서의 pattern 은 deprecated 되었습니다. 그래서 patterns_dir 을 만들어서 설정을 하셔야 합니다.

저는 그냥 기존에 생성된 LOGLEVEL 패턴에 (Ee)xception 만 추가 했습니다.


patterns/patterns

LOGLEVEL ([Ee]xception|EXCEPTION|[Aa]lert|ALERT|[Tt]race|TRACE|[Dd]ebug|DEBUG|[Nn]otice|NOTICE|[Ii]nfo|INFO|[Ww]arn?(?:ing)?|WARN?(?:ING)?|[Ee]rr?(?:or)?|ERR?(?:OR)?|[Cc]rit?(?:ical)?|CRIT?(?:ICAL)?|[Ff]atal|FATAL|[Ss]evere|SEVERE|EMERG(?:ENCY)?|[Ee]merg(?:ency)?)


[참고]

https://github.com/logstash-plugins/logstash-patterns-core/blob/master/patterns/grok-patterns


2. config 생성)

input {

  file {

    path => "/server/elastic/elasticsearch-2.3.5/logs/*.log"

  }

}


filter {

  grok {

    patterns_dir => ["./patterns"]

    match => {

      "message" => "%{LOGLEVEL:error_log}"

    }

  }


  if "_grokparsefailure" in [tags] {

    drop { }

  }

}


output {

  if [error_log] in ["Exception","exception"] {

    stdout {

      codec => "rubydebug"

    }

  }

}


이 설정의 용도는 elasticsearch 에서 발생하는 exception 을 감지 하기 위한 것입니다.

초간단 버전이니 튜닝은 각자 잘 하시면 됩니다.



※ 실제 이것만 가지고 서비스에 적용하시면 문제 발생 할 수 있습니다.

filebeats 와 연동해서 사용하시길 권장 드립니다.

:

[Logstash] input-http, filter-mutate,grok 샘플 config

Elastic/Logstash 2016. 5. 18. 17:48

그냥 올려봅니다.


[logstash config]

input {

  http {

    codec => json {

    }

  }

}


filter {

  mutate {

    add_filed => { "request_uri" => "%{headers[request_uri]}" }

    replace => { "message" => "input http 사용 시 headers 내부 변수 접근(nested variables)" }

  }


  grok {

    match => { "request_uri" => "%{URIPARAM:request}" }

  }

}


output {

  stdout { codec => rubydebug }

}


뭐 정말 별거 아닌고 모니터링 시스템 설계 하다가 prototype 구현을 해봐야 겠다 싶어서 대충 돌려보다 grok 에러가 발생해서 기록해 본겁니다.


[logstash http input 사용 시 출력 결과]

{

       "message" => "",

      "@version" => "1",

    "@timestamp" => "2016-05-18T07:19:36.140Z",

          "host" => "127.0.0.1",

       "headers" => {

         "request_method" => "GET",

           "request_path" => "/",

            "request_uri" => "/?message=test",

  1 input {

           "http_version" => "HTTP/1.1",

              "http_host" => "127.0.0.1:8080",

        "http_user_agent" => "curl/7.43.0",

            "http_accept" => "*/*"

    },

          "tags" => [

        [0] "_grokparsefailure"

    ]

}


:

[Kafka] 재미로 본 Elastic Stack과 Kafka 매칭

ITWeb/개발일반 2016. 3. 31. 18:16

그냥 재미로 한번 매칭해 봤습니다.

크게 의미는 없으니 재미로 봐주세요.


Kafka)


Elastic Stack)



 Elastic Stack

 Kafka

 logstash, beats

 producer

 elasticsearch cluster

 cluster (broker + zk)

 logstash

 consumer

 index

 topic 

 shard

 partition

 document id

 offset 

 index.number_of_replicas

 --replication-factors

 index.number_of_shards

 --partitions


저는 이해하기 쉬운데 저만 그런가요??


:

[Review] Modeling data for fast aggregations - on Elastic's Blog

Elastic/Elasticsearch 2015. 10. 30. 11:43

elastic blog에 올라온 글에 대한 개인 리뷰 입니다.

그냥 정리 차원에서 작성해 보겠습니다.


[원문]

https://www.elastic.co/blog/modeling-data-for-fast-aggregations


글 제목이나 링크만 봐도 어떤 내용인지 감이 오실 겁니다.

"aggregation 성능을 올리기 위한 모델링"

딱 봐도 끌리는 제목이죠.


이 글에서 제시해 주는 건 단순 명료 합니다.

query와 aggregation 조건에 대한 attribute 를 각 문서에 미리 정의를 해 두는 것으로 aggregation operation 수를 줄여 주는 것입니다.

문서에서는 6번의 aggregation operations를 attribute 설정을 통해 2번의 aggregation operations 수행으로 줄어든 것을 확인 시켜 주고 있습니다.


당연히 색인시점에 query, aggregation 조건을 분리해서 문서에 대한 attribute 설정을 하고 색인을 해야 합니다.

즉, 여기서 단점이 바로 보이시죠.

문서에도 나와 있습니다.

조건이 변경 되면 reindexing 을 해야 한다는 것입니다.


잘 아시겠지만 모든 요건을 만족하는 그런 아키텍쳐도, 모델링도 저는 보지 못한 것 같습니다.

항상 그렇지만 연구하고 요건을 충족 시킬수 있는 구성과 모델이 뭔지 실험하고 적용해 보지 않고서는 답을 찾을 수 없지 않을까 생각 합니다.


정리하면,

pre-compute 를 통한 문서의 attribute 정보 추가로 aggregation 수를 줄여 수행 성능을 빠르게 할 수 있다는 것입니다.


:

[Filebeat] 가볍게 사용해 볼까요?

Elastic/Beats 2015. 10. 27. 15:13
filebeat 가 릴리즈 되었습니다.
▶ elastic blog : https://www.elastic.co/blog/weekly-beats-first-filebeat-release

GA 버전은 아니고 beta4 이지만 그래도 의미 있는 릴리즈이기 때문에 소식을 전하지 않았나 싶습니다.

여기서는 가볍게 FEL (Filebeat + Elasticsearch + Logstash) 구성으로 /var/log 아래 파일로그에 대한 수집과 색인까지 살펴 보도록 하겠습니다.


Kibana를 이용한 dashboard 구성은 제가 직접 만들면 되는데 귀찮아서 그냥 이건 skip 하도록 하겠습니다.

기본적으로 elastic에서 제공하고 있는 dashboard sample 데이터가 있으니 참고 하시면 좋을 것 같습니다.

(2015.10.27일 기준으로 filebeat 는 등록되어 있지 않습니다.)


▶ elastic reference : https://www.elastic.co/guide/en/beats/libbeat/current/getting-started.html#load-kibana-dashboards


curl -L -O http://download.elastic.co/beats/dashboards/beats-dashboards-1.0.0-beta4.tar.gz

tar xzvf beats-dashboards-1.0.0-beta4.tar.gz

cd beats-dashboards-1.0.0-beta4/

./load.sh


[FEL Architecture]

기본적인 아키텍쳐링은 elastic 문서에 잘 나와 있습니다.



[Filebeat 란?]

filebeat는 기본적으로 logstash forwarder를 기반으로 만들어 졌습니다.

개별 노드에 agent 형태로 설치가 되어 동작 하게 되며, log directories or specific log files, tails the files 에 대해서 elasticsearch로 색인하게 됩니다.


참고 문서)

* "logstash-forwarder" : https://github.com/elastic/logstash-forwarder

* "libbeat platform" : https://www.elastic.co/guide/en/beats/libbeat/current/index.html


[Filebeat 설치]

※ 개발 장비로 macbook 을 사용중이기 때문에 mac 기준으로 작성 합니다.


Step 1) 다운로드를 받고 압축을 해제 합니다.

다운로드 링크 : https://www.elastic.co/downloads/beats/filebeat

$ tar -xvzf filebeat-1.0.0-beta4-darwin.tgz

$ cd filebeat-1.0.0-beta4-darwin

$ vi filebeat.yml


Step 2) filebeat.yml 설정
 filebeat configure : https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-configuration-details.html
filebeat도 elasticsearch와 마찬가지로 잘 모르면 기본 설정으로 사용 하시면 됩니다.
기본적으로 설정 하셔야 하는 값들은 "paths", "log", "elasticsearch", "logstash" 설정입니다.

...중략...
      paths:
        - /var/log/*.log

      type: log
...중략...
output:

  ### Elasticsearch as output
  elasticsearch:

    # Set to true to enable elasticsearch output
    enabled: false

...중략...

  logstash:

    # Uncomment out this option if you want to output to Logstash. The default is false.

    enabled: true


    # The Logstash hosts

    hosts: ["localhost:5044"]

...중략...


※ 여기서 elasticsearch.enabled: false 로 하는 것은 F -> L -> E 구조로 사용하기 위해서 입니다.


 filebeat logstash output configure : https://www.elastic.co/guide/en/beats/libbeat/master/configuration.html#logstash-output


Step 3) dynamic template 설정

이 설정은 logstash를 사용해 보신 분이라면 어떤 용도인지 잘 아실거라고 생각 합니다.

짧게 설명 드리면 dynamic mapping에 의한 특정 index 패턴에 사전 mapping 구성을 통해 생성되는 field의 특성을 pre-define 하는 설정을 하는 것입니다.


$ curl -XPUT 'http://localhost:9200/_template/filebeat?pretty' -d@filebeat.template.json

※ filebeat.template.json 파일은 압축 해제 하신 경로에 포함되어 있습니다.


Step 4) filebeat 실행

※ elasticsearch와 logstash를 먼저 실행 시켜 둔 후 아래 명령어로 실행 합니다.


$ sudo ./filebeat -e -c filebeat.yml -d "publish"


[Logstash 구성]

  1. filebeat 데이터를 받아 줄 logstash를 구성 합니다.
  2. logstash 1.5.4 이상
  3. beats plugin 설치
    $ bin/plugin install logstash-input-beats

[Filebeat용 logstash config 생성]

아래 설정은 libbeat reference 문서에 자세히 나와 있습니다.

 libbeat reference : https://www.elastic.co/guide/en/beats/libbeat/current/getting-started.html

input {

  beats {

    port => 5044

  }

}


output {

  elasticsearch {

    host => "localhost"

    port => "9200"

    protocol => "http"

    index => "%{[@metadata][index]}"

    document_type => "%{[@metadata][type]}"

  }

}


아래 그림은 제 맥북에서 실행 시킨 명령어 스크린샷 입니다.



logstash) bin/logstash -f conf/filebeat.config

filebeat) sudo ./filebeat -e -c filebeat.yml -d "publish"

kibana) bin/kibana

elasticsearch) bin/elasticsearch


간단하게 요약을 하면 이렇습니다.)


1. 수집 할 대상 서버에 filebeat 를 설치하고 실행 합니다.

2. logstash input beat 를 실행하고 output 으로 elasticsearch로 색인 되도록 합니다.

3. elasticsearch에 적재된 로그를 기반으로 kibana에서 dashboard를 구성 합니다.


:

[Elastic] Elastic 제품들...

Elastic 2015. 9. 9. 10:30

Elasticsearch, Logstash, Kibana 를 주로 사용하고 있다 보니 다른 제품들은 크게 관심있게 보지를 않았습니다.

제가 관심 있게 보는건 저 한테 필요 하거나 오픈소스 이거나 인데요.

당연히 위에 제품들은 모두 제가 사용하고 있는 것들이고 오픈소스 입니다.


Elastic 에서 제공하고 있는 제품들은 아래 링크를 통해서 확인 하시면 되는데요.


제품 소개 링크) https://www.elastic.co/products


최근까지 제가 잘 못 알고 있던 제품이 있었는데 이것도 한번 사용해 보기 위해 elastic 제품들을 각각 한 줄로 정리해 보기로 했습니다.


Elasticsearch - 오픈소스 무료

루씬 기반의 분산 검색 엔진 입니다.


Logstash - 오픈소스 무료

다양한 input/filter/ouput/codec 들을 제공하는 collector 입니다.


Kibana - 오픈소스 무료

elasticsearch를 DB로 사용하는 visualization/dashboard 도구 입니다.


Packet Beat - 오픈소스 무료

OS 또는 Process 등에서 발생 하는 network 모니터링 도구 입니다.


Top Beat - 오픈소스 무료

기본적인 시스템(CPU, MEM, IO, DISK) 모니터링 도구 입니다.


Elasticsearch Hadoop Plugin - 오픈소스 무료

Hadoop component 들과 elasticsearch를 쉽게 연동 할 수 있도록 도와 주는 라이브러리 입니다.


Found - SaaS 형 서비스 유료

Cloud 환경에서 ELK 를 쉽게 구축하고 사용할 수 있도록 해주는 서비스 입니다.


Shield - 유료

ELK를 이용하여 기업에서 사용하기에는 부족했던 인증, 권한 등의 기능을 제공해 주는 제품 입니다.


Watcher - 유료

ELK를 이용하면서 아쉬웠던 alert 이나 notification 에 대한 기능을 제공해 주는 제품 입니다.


Marvel - 유료 (개발자 버전은 무료)

Elasticsearch에 대한 관리 및 모니터링을 제공하는 제품 입니다.


저는 기본적으로 ELK 기반으로 필요한건 다 만들어서 사용을 하고 있는 편입니다.

beats 도 역시 만들어서 사용하고 있었는데요. 

이건 한번 시도를 해봐야 겠내요. :)

: