- Linux Server에서 OpenSearch로 로그 보내기2024년 12월 27일
- wngnl05
- 작성자
- 2024.12.27.:03
OpenSerch 생성하기 참고
2024.04.17 - [Aws] - EKS Fluent-Bit to OpenSearch
OpenSearch 설정
Security 선택하기
Create new role
Ec2에 연결된 역활 이름
역활 넣어주기
역활 넣어주기
Mapped users를 누르고
EC2 역활의 ARN 작성하고 생성
Python app을 Ec2에서 nohup으로 실행
curl https://raw.githubusercontent.com/fluent/fluent-bit/master/install.sh | sh sudo systemctl enable --now fluent-bit sudo ln -s /opt/fluent-bit/bin/fluent-bit /bin/
Fluentbit 설정 파일
sudo vi /etc/fluent-bit/fluent-bit.conf
밑에 있는 [INPUT], [OUTPUT] 삭제하고 아래 코드 넣기
더보기[INPUT] Name tail Path <로그 파일 경로> Read_From_Head true Parser test [OUTPUT] Name es Match * Host <OpenSearch 앤드포인트 https:// 빼고> Port 443 TLS On AWS_Auth On AWS_Region ap-northeast-2 Index app-log Replace_Dots On Suppress_Type_Name On
Fluentbit Parser 설정하기
sudo vi /etc/fluent-bit/parsers.conf
가장 위에 넣어주기
[PARSER] Name test Format regex Regex ^(?<clientip>[^*]*) - \[(?<time>[^\]]*)\] "(?<method>[^ ]*) (?<path>[^ ]*) (?<protocol>[^ ]*)" (?<responsecode>[^ ]*) "(?<useragent>[^ ]*)"
Parser.conf 는 수정하면 다시 재시작 해주어야 함
sudo systemctl restart fluent-bit
테스트 해보고 백그라운드에서 실행
fluent-bit -c /etc/fluent-bit/fluent-bit.conf
Run Fluentbit in BackGround
fluent-bit -c /etc/fluent-bit/fluent-bit.conf &
green open app-log dwxHtcnyQcGsMwhGB0FMYw 5 1 2 0 34kb 17kb
OPENSEARCH_ENDPOINT=$(aws opensearch describe-domain --domain-name wsi-opensearch | jq -r '.DomainStatus.Endpoint') curl -s -u admin:Password01! "https://$OPENSEARCH_ENDPOINT/_cat/indices?index=app-log"
"clientip", "method", "path", "protocol", "responsecode", "time", "useragent"
OPENSEARCH_ENDPOINT=$(aws opensearch describe-domain --domain-name wsi-opensearch | jq -r '.DomainStatus.Endpoint') curl -s -u admin:Password01! https://$OPENSEARCH_ENDPOINT/app-log | jq '.["app-log"].mappings.properties | keys[]'
'Aws' 카테고리의 다른 글
ECR PULL 차단하기 (0) 2024.12.27 Fluentbit Sidecar (0) 2024.12.27 Dockerfile 로 Python 앱 배포하기 (0) 2024.12.27 EKS CloudWatch Insight (0) 2024.12.27 Node.js로 Lambda@Edge 이미지 리사이징 하기 (0) 2024.12.27 다음글이전글이전 글이 없습니다.댓글
스킨 업데이트 안내
현재 이용하고 계신 스킨의 버전보다 더 높은 최신 버전이 감지 되었습니다. 최신버전 스킨 파일을 다운로드 받을 수 있는 페이지로 이동하시겠습니까?
("아니오" 를 선택할 시 30일 동안 최신 버전이 감지되어도 모달 창이 표시되지 않습니다.)