ELK Stack이란
- Logstash를 이용하여 데이터를 수집하고 ElasticSearch로 데이터를 분류하여 Kibana로 표시해주는 것
1. ElasticSearch
- Apache Lucene을 바탕으로 개발된 분산 검색엔진으로 데이터를 쉽게 저장, 처리할 수 있으며, 실시간 검색과 플러그인을 이용한 확장을 지원하는 등의 장점이 있다.
또한 인덱스 갱신 주기도 빠른편이고 운영 중 스키마 변경도 가능하다.
- 설치 방법
설치링크
- 기본 개념
개념 링크
관계형 DB와 Elasticsearch 용어 비교
|ElasticSearch | RDB |
| :———- | :——— |
|Index | Database |
|Type | Table |
|Document | Row |
|Field | Column |
|Mapping | Schema |
|Everything is indexed | Index |
|Query DSL | SQL |
- 사용법
REST API 형싱으로 PUT을 이용하여 추가, 수정, DELETE로는 삭제, 검색은 GET으로 한다.
```Text
PUT /customer?pretty <- Index 생성
PUT /customer/_type/1?pretty -H ‘Content-type:application/json’ -d
{
“name”:”bboroccu”
} <- Type 생성 후 Document 추가 색인화는 1
POST /cutomer/_type?pretty -H ‘Content-type:application/json’ -d
{
“name”:”bboroccu”
} <- PUT과는 다르게 ID를 생성하지 않고 elasticsearch에서 ID 생성할 경우
GET /customer/_type/1?pretty <- 조회
PUT /customer/_type/1?pretty -H ‘Content-type:application/json’ -d
{
“name”:”ultrabborc”
} <- 수정
DELETE /cutomer?pretty <- Index 삭제
```
2. Logstash
- 하나 또는 여러개의 입력값을 간단하게 우리가 원하는 데이터로 변경해 주는 ETL(for Extract, Transform, Load)라고 생각하면 된다. 설정은 JSON형태로 input, filter, output만 선언해 주면 되고 input형태는 file, S3 bucket, RabbitMQ, redis등을 지원한다.
- 설치 방법
설치링크
- MAC에서 logstash 경로 : /usr/local/Cellar/logstash/{version}/bin
3. Kibana
- web-based data 분석 및 dashboard tool을 제공하며, ElastisSearch의 결과를 수 초내로 보여주는 역할을 담당한다.
로컬에서 ElasticSearch 테스트시 elasticsearch forbidden/12/index read-only / allow delete (api) 오류가 날경우
curl -XPUT -H “Content-Type: application/json” http://localhost:9200/_all/_settings -d ‘{“index.blocks.read_only_allow_delete”: null}’
내용 추가중…