티스토리 뷰
2022.11.08 - [ELK 스택] - Filebeat - Logstash - Elasticsearch 예제
Filebeat - Logstash - Elasticsearch 예제
Filebeat 설치 및 실행 filebeat.yml 에서 파일 입력 설정 파일을 다시 읽어들이기 위한 data 플래그 삭제 Filebeat => Logstash 파이프라인 filebeat.yml 에서 output.logstash 설정 Logstash 에서 beats 입력 설정 Logstash o
jhyunnn.tistory.com
아래 글은 위에 먼저 읽으셔야 이해 될겁니다!
GET _cat/indices/apachelog*
GET filebeat-7.11.2*/_search
GET apachelog*/_count
GET /_cat/node
GET apachelog*/_count
GET apachelog-2020.08.08/_search
# _search 하게되면 다이나믹 매핑이 되어있어서 제대로 값을 사용하기 어려운 상태입니다.
# 매핑을 바꿀려면은 매핑을 먼저 선언하고 인덱스에 들어갈 document를 색인해야합니다.
이전 내용을 카피를 해서 복사한 내용으로 여기서부터 수정 진행할게요
GET apachelog-2020.08.08/_search
# 삭제한거 아래에 그냥 적어둘게요
clientip, ecs, input, log, tags(beats)
# 데이터 넣기
PUT mylog
{
{ ...
# geoip는 사용할 가능성이 높기에 냅둘게요
"geoip": {
"properties": {
"city_name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
# 집계만 할 가능성이 높기에 keyword 타입으로 지정
"continent_code": {
"type": "keyword"
},
"continent_code2": {
"type": "keyword"
},
"continent_code3": {
"type": "keyword"
},
"continent_code4": {
"type": "keyword"
},
"dma_code": {
"type": "long"
},
"ip": {
"type": "ip"
},
"latitude": {
"type": "half_float"
},
# location이 type이 float으로 되어있을텐데 이러면 사용이 어려워서
# 변경해주겠습니다.
"location": {
"type": "geo_point"
},
...
"postal_code": {
"type": "keyword"
},
"region_code": {
"type": "keyword"
},
"region_name": {
"type": "keyword"
},
"timezone": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"httpversion": {
"type": "keyword"
},
"ident": {
"type": "keyword"
},
# message 는 keyword를 쓸일이 없어요
# 그래서 text만 냅둘게요
"message": {
"type": "text"
},
"referrer": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"request": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
},
"response": {
"type": "keyword"
},
"useragent": {
"properties": {
"build": {
"type": "keyword"
},
"device": {
"type": "keyword"
},
"major": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"minor": {
"type": "keyword"
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"os": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"os_major": {
"type": "keyword",
},
"os_minor": {
"type": "keyword",
},
"os_name": {
"type": "text",
"fields":{
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"patch": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"verb": {
"type": "keyword"
}
}
}
# 여기서 이제 재색인 하는걸 해볼게요
# reindex 라는 걸 사용하고
POST _reindex
{
"source": {
"index": "apachelog-2020.08.08"
},
"dest": {
"index": "mylog"
}
}
# 데이터, 매핑 확인
GET mylog/_search
GET mylog_mapping
참고
'ELK 스택' 카테고리의 다른 글
Elasticsearch - 인덱스 재색인: 인덱스 템플릿과 스크립트 사용 (0) | 2022.11.08 |
---|---|
Filebeat - Logstash - Elasticsearch 예제 (0) | 2022.11.08 |
Elasticsearch - 인덱스 매핑과 데이터 타입 날짜, 객체, 위치정보 (3) (0) | 2022.11.07 |
Elasticsearch - 인덱스 매핑과 데이터 타입 날짜, 객체, 위치정보 (2) (0) | 2022.11.07 |
Elasticsearch - 인덱스 매핑과 데이터 타입 날짜, 객체, 위치정보 (1) (0) | 2022.11.07 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Java
- 절대 경로 설정하기
- bool
- list
- 인덱스
- React18
- Mappings
- index 처리를 잘하자
- ElasticSearach 백업
- Query
- react
- Mapping
- GIT
- mysql은 nl이 기본 세팅
- 재색인
- InteiilJ
- config
- ArrayList
- kibana
- Elasticsearch
- pm2-logrotate
- 문자
- literal sql
- Linux
- 명령어
- logstash
- 키바나
- EL
- NextJS 14
- string
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
글 보관함