본문으로 바로가기

Elastic APM 구성해보기

category ELK 2022. 8. 24. 17:43
반응형

 

APM 이란?

애플리케이션 성능 모니터링 시스템 (Application Performance Monitoring or Management) 

 

APM Agent

애플리케이션에 설치해서, 코드를 계측하고 런타임에 성능 데이터와 오류를 수집하여 APM Server로 전송

Elastic APM 통합 (APM Server)

APM Agent가 준 성능 데이터를 수신해 Elasticsearch 문서로 변환하고 해당 인덱스에 저장

Elasticsearch

텍스트 검색 및 분석 엔진으로써 대용량 데이터를 저장, 검색 및 분석함.

Kibana APM UI

Elasticsearch와 함께 작동하고 설계된 무료 개방형 분석 및 시각화 플랫폼.

 

구성해보기

 

Elastic APM 통합 (APM Server), Elasticsearch Cluster, Kibana 실행

version: "3.7"
services:
  apm-server:
    image: elastic/apm-server:7.8.1
    container_name: apm-server
    hostname: apm-server
    restart: always
    ports:
      - 8200:8200
    links:
      - es1:elasticsearch
    depends_on:
      - es1
    volumes:
      - ./apm/apm-server.yml:/usr/share/apm-server/apm-server.yml
      - ./apm/data:/usr/share/apm-server/data
  kibana:
    image: docker.elastic.co/kibana/kibana:7.8.1
    container_name: kibana
    hostname: kibana
    links:
      - "es1:elasticsearch"
    ports:
      - 5601:5601
  es1:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.8.1
    container_name: es1
    hostname: es1
    environment:
      - cluster.name=es-cluster
      - node.name=es1
      - cluster.initial_master_nodes=es1
      - discovery.seed_hosts=es2
      - node.master=true
      - node.data=true
    ports:
      - 9200:9200
      - 9300:9300
    volumes:
      - ./es1/data:/usr/share/elasticsearch/data
  es2:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.8.1
    container_name: es2
    hostname: es2
    environment:
      - cluster.name=es-cluster
      - node.name=es2
      - cluster.initial_master_nodes=es1
      - discovery.seed_hosts=es1
      - node.master=false
      - node.data=true
    volumes:
      - ./es2/data:/usr/share/elasticsearch/data

 

 

apm-server.yml

apm-server.yml 작성

 

APM version 8.0 | APM User Guide [8.3] | Elastic

View commits APM version 8.0.1edit View commits Bug fixesedit Fix mixing of labels across OpenTelemetry log records 7358 Fix panic when processing OpenTelemetry histogram metrics without bounds 7316 Fix waiting for events to be flushed when shutting down A

www.elastic.co

apm-server:
  rum.enabled: true
  kibana.enabled: true
  kibana.host: kibana:5601
  host: "0.0.0.0:8200"

setup:
  kibana.host: kibana:5601
  template.settings.index.number_of_replicas: 0

output.elasticsearch:
  enabled: true
  protocol: "http"
  hosts: [ "elasticsearch:9200" ]
  ssl.enabled: false
  kibana:
    enabled: true

 

APM Agent

APM Agent Download

 

APM Agents | Elastic

 

www.elastic.co

 

실행 방법

 

1. jar 파일 실행시

-javaagent:/apm-agent.jar
-Delastic.apm.service_name=todo-apm-agent-service
-Delastic.apm.application_packages=com.example
-Delastic.apm.server_url=http://localhost:8200
-jar app.jar

2. 인텔리제이 > Run/Debug Configurations VM options 작성

-javaagent:/apm-agent.jar
-Delastic.apm.service_name=todo-apm-agent-service
-Delastic.apm.application_packages=com.example
-Delastic.apm.server_url=http://localhost:8200

 

Kibana APM 확인

 

 

 

참조

반응형