본문 바로가기
DevOps

Docker로 pinpoint를 띄우는법

by 이숴 2023. 7. 21.
반응형

프로젝트를 하면서 서버의 상태를 확인하기 위해 모니터링 툴을 추가했어야하는 상황이 있었습니다.

 

그래서 처음에는 grafana와 datadog를 생각했었지만, 

 

pinpoint가 무료이기도하고, 분산서버 임에도 추적할 수 있는 점 때문에 최종적으로는 pinpoint를 사용하게 되었습니다.

 

처음 시도했을때는 ncp에서 지원하는 pinpoint 전용 서버를 써서 연동을 시도해보았지만, ip가 막혀 있는 것인지 계속 어플리케이션의 agent가 탐지를 못해서 포기했었습니다.

 

다른 방법으로 시도하여 띄워야 했는데,

 

일반 서버를 개설해서 도커로 띄우는 방식을 선택했습니다.

저는 docker compose를 써서 pinpoint를 띄워보았습니다.

 

Pinpoint 서버

pinpoint 용 서버는 메모리를 16GB 이상으로 만드셔야 합니다. pinpoint가 띄워질때 사용하는 메모리가 13~15GB정도 사용되기 때문입니다.

 

서버를 개설하셨다면, 서버안에서 다음과 같이 코드를 작성해주세요.

$ git clone https://github.com/naver/pinpoint-docker.git
$ cd pinpoint-docker
$ docker-compose pull && docker-compose up -d

이렇게하면 docker-compose.yml 안에 설정되어있던 pinpoint가 빌드되어서 서버에 띄워지게 됩니다. 하지만 서버랑 연결이 아직 되지 않았는데요.

 

이제는 어플리케이션쪽에서 빌드시에 pinpoint가 띄워진 서버랑 연동을 시도 해야합니다.

저는 프로젝트 빌드를 DockerFile로 진행하고 있으니 참고하시길 바랍니다. 다른 방법으로는 VM Option에 설정 하는 부분이 있으니 찾아보시는 걸 추천드립니다.

# Start a new stage
FROM openjdk:17-jdk-alpine

# Add Pinpoint
ADD https://github.com/pinpoint-apm/pinpoint/releases/download/v2.5.2/pinpoint-agent-2.5.2.tar.gz /usr/local
RUN tar -zxvf /usr/local/pinpoint-agent-2.5.2.tar.gz -C /usr/local

# Update the Pinpoint configuration
RUN sed -i 's/profiler.transport.grpc.collector.ip=127.0.0.1/profiler.transport.grpc.collector.ip={본인 서버 IP}/g' /usr/local/pinpoint-agent-2.5.2/pinpoint-root.config
RUN sed -i 's/profiler.collector.ip=127.0.0.1/profiler.collector.ip={본인 서버 IP}/g' /usr/local/pinpoint-agent-2.5.2/pinpoint-root.config

# Copy the built JAR from the build stage
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar

# Expose the required port
EXPOSE 8080

# Run the application
ENTRYPOINT ["java","-jar", \
"-javaagent:/usr/local/pinpoint-agent-2.5.2/pinpoint-bootstrap-2.5.2.jar", \
"-Dpinpoint.applicationName={앱 이름}", \
"-Dpinpoint.config=/usr/local/pinpoint-agent-2.5.2/pinpoint-root.config", \
"-Dspring.profiles.active=prod", \
"/app.jar"]

저는 제 기준 최신버전인 2.5.2 버전으로 했습니다. 버전은 pinpoint 깃허브를 가셔서 찾아보셔도 좋을 것같습니다.

https://github.com/pinpoint-apm/pinpoint

 

GitHub - pinpoint-apm/pinpoint: APM, (Application Performance Management) tool for large-scale distributed systems.

APM, (Application Performance Management) tool for large-scale distributed systems. - GitHub - pinpoint-apm/pinpoint: APM, (Application Performance Management) tool for large-scale distributed sys...

github.com

 

dockerfile을 보시면 먼저 pinpoint깃허브에서 압축파일을 가져와서 압축해제한 후, 

 

pinpoint-root.config의 기본 localhost ip 설정들을 제 서버 ip로 수정하고

빌드시에 agent 내용을 포함해서 같이 실행시키도록 하였습니다.

 

이렇게하고 pinpoint 서버의 ip:8080으로 들어가보시면, pinpoint UI 화면을 확인하실 수 있으십니다.

 

반응형

댓글