Elasticsearch은 모니터링 시스템으로 APM을 지원한다.
Spring 기반 웹서버에서 편리하게 구성할 수 있게 Elastic APM Agent를 제공.
스프링 기반의 웹서버를 Elasticsearch, Kibana를 이용해서 APM 연결하는 내용이다.
ELK 구성
1 | |
es01, es02, es03각 클러스터링 해서 설정했고, 키바나 설정과, 로그스테이시 설정으로 구성, 해당 구성은 Install Elasticsearch with Docker의 기반으로 로그스테이시 설정을 추가했으나 로그스테이시 사용하지 않는다면 해당 부분을 주석해서 사용해도 된다.
1 | |
위 명령어로 도커를 실행
APM 설정
APM Server 설정

- APM으로 이동

Setup Instructions버튼을 클릭

1 | |
apm-server.yml 설정 파일을 수정한다
아래 내용은 중간정도 부분에 존재
1 | |
우문투의 경우 apm-server.yml 위치
1 | |
실행중인지 확인 코드
1 | |
Agent 설정

- Agent 설정도 동일하게 해당 가이드를 참고하여 진행한다
- Maven Central으로 이동해서 해당 언어에 맞는 Agent를 다운로드
Check agent status버튼을 눌러서 위에서 설정한 APM 서버가 제대로 동작 중인지 확인할 수 있다.- 오른쪽 최하단
Launch APM버튼을 클릭해서 종료한다. 해당 설정으로 다른 무언가를 생성하지 않고 필요한 APM Server, APM Agent를 설정하는 것이 목적이다
Agent 실행
1 | |
모니터링 대상 서버 구동시 해당 Agent를 같이 실행하면 된다

1 | |
윈도우
1 | |
service_name: APM 대상의 서버 이름server_url: 위에서 설정한 APM 서버 주소application_packages: 애플리케이션 패키지 주소secret_token: 설정은 사용하지 않아 제거
키바나 APM

- 위에 설정한 APM 서버 확인
Transactions

- 해당 애플리케이션 트랜잭션 정보를 출력.

- 해당 트랜잭션 내용을 살펴볼 수 있으며, HTTP 요청/응답에 대한 자세한 내용도 표시한다.

- 해당 쿼리 문의 상세한 내용도 보여준다
Errors

- 해당 서버의 Error를 보여준다.
- 발생한 Error를 클릭하면 해당 오류의 더 많은 정보를 보여준다.

- 오류가 발생한 트랜잭션을 클릭하면 트래잭션 탭으로 이동되며, 해당 이슈의 원인을 파악 할 수 있다.
JVMs

현재 시스템 리소스에 대한 내용
memory 에러 발생하는 경우
-
Linux
The
vm.max_map_countsetting should be set permanently in/etc/sysctl.conf:1
2grep vm.max_map_count /etc/sysctl.conf vm.max_map_count=262144To apply the setting on a live system, run:
1
1
sysctl -w vm.max_map_count=262144 -
macOS with Docker for Mac
The
vm.max_map_countsetting must be set within the xhyve virtual machine:- From the command line, run:
1
screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty1
2. Press enter and use`sysctl` to configure `vm.max_map_count`:1
1
sysctl -w vm.max_map_count=2621441
3. To exit the `screen` session, type `Ctrl a d`. -
Windows and macOS with Docker Desktop
The
vm.max_map_countsetting must be set via docker-machine:1
2docker-machine ssh sudo sysctl -w vm.max_map_count=262144 -
Windows with Docker Desktop WSL 2 backend
The
vm.max_map_countsetting must be set in the docker-desktop container:1
2wsl -d docker-desktop sysctl -w vm.max_map_count=262144https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-cli-run-prod-mode