기존 레디스와 함께 OpenTelemetry Collector를 컨테이너로 배포하여 도커 Compose를 사용해 레디스 인스턴스를 모니터링합니다.
시작하기 전에
수집기를 설정하기 전에 다음이 필요합니다:
- 도커 및 도커 컴포즈 (v2 이상) 설치
- 너의 뉴렐릭
- 실행 중이고 액세스 가능한 레디스 ― 버전 6.0 이상 권장(4.0 이상은 축소된 메트릭 세트로 작동함)
- 뉴렐릭의 OTLP 엔드포인트에 대한 아웃바운드 HTTPS(포트 443)
설치 옵션에서 수집기 배포판을 선택합니다: NRDOT 수집기, OpenTelemetry Collector Contrib 또는 Prometheus 수신자. 각 경로의 도커 컴포즈 파일은 프로메테우스 수신기 경로를 위한 redis_exporter 를 포함하여 필요한 이미지를 가져옵니다.
설치 옵션
수집기 설정 생성
이 설정은 수집기에게 레디스 메트릭을 수집하고 뉴렐릭으로 보내는 방법을 알려줍니다. 세 가지 주요 작업을 처리합니다:
redis수신기를 통해 레디스에서 메트릭을 수집 합니다.데이터 가공 ― 카디널리티를 줄이고, 카운터를 델타로 변환하며, 엔티티 합성을 위해 태그를 지정합니다.
처리된 메트릭을 OTLP를 통해 뉴렐릭으로 내보내기
프로젝트 디렉터리에
otel-collector-config.yaml을(를) 만듭니다:extensions:health_check:endpoint: "0.0.0.0:13133"receivers:redis:endpoint: "redis:6379" # Update with your Redis service name:portcollection_interval: 10smetrics:redis.maxmemory:enabled: trueredis.role:enabled: falseredis.cmd.calls:enabled: trueredis.cmd.usec:enabled: trueredis.clients.max_input_buffer:enabled: falseredis.clients.max_output_buffer:enabled: falseredis.replication.backlog_first_byte_offset:enabled: falseresource_attributes:server.address:enabled: trueserver.port:enabled: trueprocessors:memory_limiter:check_interval: 5slimit_mib: 512spike_limit_mib: 128resource_detection:detectors: [env, system]timeout: 5soverride: falsesystem:resource_attributes:host.name:enabled: truehost.id:enabled: true# Uncomment the section below to use a custom human-readable name for your# Redis entity instead of the default server.address:server.port identifier.# resource/redis:# attributes:# - key: redis.instance.id# value: "my-redis-instance"# action: upsertattributes/entity_tags:actions:- key: instrumentation.providervalue: opentelemetryaction: upsertcumulativetodelta:include:match_type: regexpmetrics:- redis\.commands\.processed- redis\.connections\.received- redis\.connections\.rejected- redis\.keys\.evicted- redis\.keys\.expired- redis\.keyspace\.hits- redis\.keyspace\.misses- redis\.net\.input- redis\.net\.output- redis\.cpu\.time- redis\.cmd\.calls- redis\.cmd\.usec- redis\.uptimefilter/cardinality:metrics:datapoint:- 'metric.name == "redis.cpu.time" and attributes["state"] != "sys" and attributes["state"] != "user"'- 'metric.name == "redis.cmd.calls" and attributes["cmd"] != "get" and attributes["cmd"] != "set" and attributes["cmd"] != "del" and attributes["cmd"] != "hget" and attributes["cmd"] != "hset" and attributes["cmd"] != "hgetall" and attributes["cmd"] != "lpush" and attributes["cmd"] != "rpop" and attributes["cmd"] != "zadd" and attributes["cmd"] != "expire"'- 'metric.name == "redis.cmd.usec" and attributes["cmd"] != "get" and attributes["cmd"] != "set" and attributes["cmd"] != "del" and attributes["cmd"] != "hget" and attributes["cmd"] != "hset" and attributes["cmd"] != "hgetall" and attributes["cmd"] != "lpush" and attributes["cmd"] != "rpop" and attributes["cmd"] != "zadd" and attributes["cmd"] != "expire"'transform/metadata_nullify:metric_statements:- context: metricstatements:- set(description, "")- set(unit, "")batch:send_batch_size: 2048send_batch_max_size: 4096timeout: 10sexporters:otlp_http:endpoint: ${env:OTEL_EXPORTER_OTLP_ENDPOINT}headers:api-key: ${env:NEW_RELIC_LICENSE_KEY}compression: gzipservice:extensions: [health_check]pipelines:metrics/redis:receivers: [redis]# If using resource/redis for custom name, add it to the processors list:# processors: [memory_limiter, resource_detection, resource/redis, attributes/entity_tags, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch]processors: [memory_limiter, resource_detection, attributes/entity_tags, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch]exporters: [otlp_http]이 설정의 역할
파이프라인의 각 구성 요소에는 특정 작업이 있습니다:
요소 설명 health_check수집기가 실행 중인지 확인할 수 있도록 0.0.0.0:13133에 상태 엔드포인트를 노출합니다.redis수신기10초마다 레디스 엔드포인트에 연결하고 레디스 INFO명령에서 메트릭을 읽습니다.server.address및server.port가 엔티티의 ID가 됩니다.memory_limiter컨테이너를 보호하기 위해 수집기 메모리 사용량을 제한합니다(512 MiB 소프트 제한, 128 MiB 스파이크). resource_detection호스트를 감지하고 host.name및host.id을(를) 추가하여 레디스 메트릭을 기본 호스트 엔티티에 연결합니다.attributes/entity_tags쿼리 범위를 OpenTelemetry 경로로 지정할 수 있도록 모든 메트릭에 instrumentation.provider: opentelemetry을(를) 찍습니다.cumulativetodelta뉴렐릭이 비율을 올바르게 차트로 표시할 수 있도록 레디스의 누적 카운터 ― 명령, 키스페이스 적중, 축출 등 ― 를 델타 값으로 변환합니다. filter/cardinality수집 비용을 제어하기 위해 높은 카디널리티 데이터 포인트( user및sys이외의 CPU 상태, 일반적이지 않은 명령에 대한 명령별 메트릭)를 삭제합니다.transform/metadata_nullify페이로드 크기를 줄이기 위해 메트릭 설명 및 단위를 지웁니다. batch네트워크 오버헤드를 줄이기 위해 내보내기 전에 데이터 포인트를 그룹화(배치당 2,048개, 최대 4,096개)하고 최소 10초마다 플러시합니다. otlp_http라이선스 키로 인증되고 gzip 압축을 사용하여 OTLP를 통해 처리된 메트릭을 뉴렐릭으로 내보냅니다. 팁
사용자 친화적인 엔티티 이름을 원하시나요? 기본적으로 레디스 엔티티의 이름은
server.address:server.port조합을 사용하여 지정됩니다. 대신 사람이 읽을 수 있는 사용자 지정 이름을 사용하려면, 위의 구성에서resource/redis섹션의 주석 처리를 제거하고,redis.instance.id값에 원하는 이름을 설정한 다음, 프로세서 파이프라인에resource/redis을(를) 추가하세요.
선택 사항: 인증 설정
기본적으로 수집기는 자격 증명 없이 레디스에 연결합니다. 레디스 인스턴스에 인증이 필요한 경우, 일치하는 자격 증명을 redis 수신기에 추가하세요. 설정에 맞는 옵션을 선택하세요:
선택 사항: 레디스 로그 수집
메트릭 외에도 수집기는 레디스의 로그 파일을 뉴렐릭으로 전달할 수 있으므로 로그 이벤트 ― 재시작, 지속성 이벤트 또는 오류 ― 를 동일한 엔티티의 메트릭 급증과 연관시킬 수 있습니다.
중요
기본적으로 도커의 레디스는 파일이 아닌 stdout 에 로그를 기록합니다. filelog 수신기로 로그를 수집하려면 레디스가 로그 파일에 기록하도록 설정하고 레디스와 수집기 컨테이너 간에 도커 볼륨을 통해 공유해야 합니다.
docker-compose.yml의 레디스 서비스에 다음을 추가합니다:
redis: image: redis:7 command: > sh -c "touch /data/redis.log && chmod 644 /data/redis.log && redis-server --logfile /data/redis.log" volumes: - redis-logs:/data그리고 수집기 서비스에 공유 볼륨을 추가합니다:
otel-collector: volumes: - redis-logs:/var/log/redis:ro그런 다음 docker-compose.yml의 하단에 추가합니다:
volumes: redis-logs:otel-collector-config.yaml에 filelog 수신기를 추가합니다:
receivers: # ... existing redis receiver ... file_log/redis: include: - /var/log/redis/redis.log start_at: end operators: - type: regex_parser regex: '^\d+:[XCSM] \d+ \w+ \d+ \d+:\d+:\d+\.\d+ (?P<level>.) ' on_error: send resource: db.system: redis파일의 로그 줄에는 자체적인 레디스 연결 컨텍스트가 없습니다 ― 뉴렐릭이 로그를 레디스 엔티티와 연결하도록 명시적으로 ID 속성을 추가해야 합니다. 레디스 엔티티의 ID와 일치하는 하드코딩된 값을 사용하여 resource/redis_logs 프로세서를 추가합니다:
processors: # ... existing processors ... resource/redis_logs: attributes: - key: server.address value: "redis" # Must match your redis receiver endpoint host action: upsert - key: server.port value: 6379 # Must match your redis receiver endpoint port action: upsert - key: instrumentation.provider value: opentelemetry action: upsert팁
사용자 지정 인스턴스 ID를 사용하시나요? 사용자 지정 엔티티 명명에 resource/redis 프로세서를 활성화한 경우, 위의 server.address 및 server.port 를 redis.instance.id(으)로 바꿉니다:
resource/redis_logs: attributes: - key: redis.instance.id value: "my-redis-instance" # Must match the value in resource/redis action: upsert - key: instrumentation.provider value: opentelemetry action: upsert서비스 섹션에 별도의 로그 파이프라인을 추가합니다:
service: pipelines: metrics/redis: receivers: [redis] processors: [memory_limiter, resource_detection, attributes/entity_tags, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch] exporters: [otlp_http] logs/redis: receivers: [file_log/redis] processors: [memory_limiter, resource/redis_logs, batch] exporters: [otlp_http]중요
수집기 컨테이너는 레디스 로그 파일에 대한 읽기 권한이 있어야 합니다. 로그 디렉터리를 컨테이너에 마운트할 때, 수집기 프로세스가 파일을 읽을 수 있는지 확인하세요. 호스트에서 다음을 실행합니다:
$sudo chmod 755 /var/log/redis$sudo chmod 644 /var/log/redis/redis.log선택 사항: 호스트 메트릭 수집
레디스 성능은 종종 호스트 리소스 압박 ― CPU 포화, 메모리 고갈 또는 디스크 I/O 경합을 추적합니다. 뉴렐릭에서 두 가지를 연관시킬 수 있도록 레디스와 함께 시스템 메트릭을 수집하는 hostmetrics 수신기를 추가합니다. 수집기가 컨테이너의 파일 시스템이 아닌 호스트 파일 시스템을 읽도록 도커 컨테이너 내부에서 실행할 때 root_path: /hostfs 설정이 필요합니다:
receivers: # ... existing receivers ... host_metrics: collection_interval: 10s root_path: /hostfs scrapers: cpu: metrics: system.cpu.utilization: {enabled: true} system.cpu.time: {enabled: true} load: metrics: system.cpu.load_average.1m: {enabled: true} system.cpu.load_average.5m: {enabled: true} system.cpu.load_average.15m: {enabled: true} memory: metrics: system.memory.usage: {enabled: true} system.memory.utilization: {enabled: true} disk: metrics: system.disk.io: {enabled: true} system.disk.operations: {enabled: true} filesystem: metrics: system.filesystem.usage: {enabled: true} system.filesystem.utilization: {enabled: true} network: metrics: system.network.io: {enabled: true} system.network.packets: {enabled: true}호스트 메트릭을 위한 별도의 metrics/host 파이프라인을 추가합니다(레디스 파이프라인에 host_metrics 을(를) 추가하지 마십시오):
service: pipelines: metrics/redis: receivers: [redis] processors: [memory_limiter, resource_detection, attributes/entity_tags, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch] exporters: [otlp_http] metrics/host: receivers: [host_metrics] processors: [memory_limiter, resource_detection, attributes/entity_tags, batch] exporters: [otlp_http]선택 사항: 커스텀 메타데이터 추가
사용자 지정 리소스 속성은 모든 레디스 메트릭에 컨텍스트 ― 환경, 팀 또는 티어 ― 를 태그로 지정하여 뉴렐릭에서 데이터를 필터링하고 그룹화할 수 있도록 합니다. 원하는 태그가 있는 resource/custom 프로세서를 추가합니다:
processors: # ... existing processors ... resource/custom: attributes: - key: environment value: "production" action: upsert - key: team value: "platform" action: upsert파이프라인에 프로세서를 포함하세요:
service: pipelines: metrics/redis: receivers: [redis] processors: [memory_limiter, resource_detection, resource/custom, attributes/entity_tags, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch] exporters: [otlp_http]선택 사항: 레디스 Cluster 모니터링 활성화
레디스 Cluster 모니터링은 현재 Prometheus 수신기 방식(redis_exporter 사용)이 필요합니다. NRDOT Collector의 기본 레디스 수신기는 클러스터 메트릭에 필요한 CLUSTER INFO 명령을 아직 지원하지 않습니다. 클러스터 모니터링 설정을 위해 Prometheus 수신기 탭을 사용하세요.
도커 Compose 파일 생성
기존 레디스와 함께 수집기를 실행하려면 docker-compose.yml 을(를) 만듭니다. 동일한 디렉터리에 있는 .env 파일은 도커 Compose에 의해 자동으로 로드됩니다:
services: otel-collector: image: newrelic/nrdot-collector:latest env_file: .env volumes: - ./otel-collector-config.yaml:/etc/otel/config.yaml:ro - /etc/machine-id:/etc/machine-id:ro # Uncomment if collecting Redis logs (requires shared volume — see logs step above): # - redis-logs:/var/log/redis:ro # Uncomment if collecting host metrics: # - /:/hostfs:ro # Uncomment if using TLS: # - ./certs:/etc/ssl/redis:ro environment: - NEW_RELIC_LICENSE_KEY=${NEW_RELIC_LICENSE_KEY} - OTEL_EXPORTER_OTLP_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT} # Uncomment if collecting host metrics: # - HOST_PROC=/hostfs/proc # - HOST_SYS=/hostfs/sys # - HOST_ETC=/hostfs/etc # Uncomment if using Redis authentication: # - REDIS_PASSWORD=${REDIS_PASSWORD} # - REDIS_USERNAME=${REDIS_USERNAME} command: ["--config=/etc/otel/config.yaml"] ports: - "13133:13133" healthcheck: test: ["CMD", "curl", "-f", "http://localhost:13133"] interval: 10s timeout: 5s retries: 3
# Uncomment if collecting Redis logs:# volumes:# redis-logs:팁
이전 단계에서 선택적 기능(로그, 호스트 메트릭, TLS 또는 인증)을 활성화한 경우 위의 도커 Compose 파일에서 해당 줄의 주석 처리를 제거합니다.
환경 파일 생성
도커 Compose는 docker-compose.yml과(와) 동일한 디렉터리에 있는 .env 파일에서 배포 관련 값을 읽어오므로 compose 파일에 라이선스 키가 노출되지 않습니다. .env 파일을 생성합니다:
$NEW_RELIC_LICENSE_KEY=YOUR_LICENSE_KEY$OTEL_EXPORTER_OTLP_ENDPOINT=YOUR_OTLP_ENDPOINT$# Set the New Relic OTLP endpoint for your region.$# See https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp플레이스홀더를 자체 값으로 바꿉니다:
| 변하기 쉬운 | 필수의 | 설명 |
|---|---|---|
NEW_RELIC_LICENSE_KEY | 네 | 귀하의 뉴렐릭 수집 라이선스 키. |
OTEL_EXPORTER_OTLP_ENDPOINT | 네 | 해당 리전의 뉴렐릭 OTLP 엔드포인트. 자세한 내용은 뉴렐릭 OTLP 엔드포인트를 참조하세요. |
시작 및 확인
백그라운드에서 수집기 시작:
$docker compose up -ddocker compose ps (으)로 컨테이너가 실행 중인지 확인합니다 ― 수집기는 running 상태를 표시해야 합니다. 종료된 경우 docker compose logs otel-collector 을(를) 사용하여 로그를 확인하세요 ― 가장 일반적인 원인은 YAML 들여쓰기 오류 및 연결할 수 없는 레디스 엔드포인트입니다.
그런 다음 메트릭이 뉴렐릭에 도달하는지 확인합니다. 시작 후 약 1분 정도 기다린 다음 쿼리 빌더에서 다음 쿼리를 실행합니다:
SELECT count(*) FROM Metric WHERE metricName LIKE 'redis.%' AND instrumentation.provider = 'opentelemetry' SINCE 5 minutes ago0이 아닌 개수는 레디스 메트릭이 전송되고 있음을 확인합니다. 0을(를) 반환하는 경우, 레디스 문제 해결(OpenTelemetry)을 참조하세요.
수집기 설정 생성
이 설정은 수집기에게 레디스 메트릭을 수집하고 뉴렐릭으로 보내는 방법을 알려줍니다. 세 가지 주요 작업을 처리합니다:
redis수신기를 통해 레디스에서 메트릭을 수집 합니다.데이터 가공 ― 카디널리티를 줄이고, 카운터를 델타로 변환하며, 엔티티 합성을 위해 태그를 지정합니다.
처리된 메트릭을 OTLP를 통해 뉴렐릭으로 내보내기
프로젝트 디렉터리에
otel-collector-config.yaml을(를) 만듭니다:extensions:health_check:endpoint: "0.0.0.0:13133"receivers:redis:endpoint: "redis:6379" # Update with your Redis service name:portcollection_interval: 10smetrics:redis.maxmemory:enabled: trueredis.role:enabled: falseredis.cmd.calls:enabled: trueredis.cmd.usec:enabled: trueredis.clients.max_input_buffer:enabled: falseredis.clients.max_output_buffer:enabled: falseredis.replication.backlog_first_byte_offset:enabled: falseresource_attributes:server.address:enabled: trueserver.port:enabled: trueprocessors:memory_limiter:check_interval: 5slimit_mib: 512spike_limit_mib: 128resource_detection:detectors: [env, system]timeout: 5soverride: falsesystem:resource_attributes:host.name:enabled: truehost.id:enabled: true# Uncomment the section below to use a custom human-readable name for your# Redis entity instead of the default server.address:server.port identifier.# resource/redis:# attributes:# - key: redis.instance.id# value: "my-redis-instance"# action: upsertattributes/entity_tags:actions:- key: instrumentation.providervalue: opentelemetryaction: upsertcumulativetodelta:include:match_type: regexpmetrics:- redis\.commands\.processed- redis\.connections\.received- redis\.connections\.rejected- redis\.keys\.evicted- redis\.keys\.expired- redis\.keyspace\.hits- redis\.keyspace\.misses- redis\.net\.input- redis\.net\.output- redis\.cpu\.time- redis\.cmd\.calls- redis\.cmd\.usec- redis\.uptimefilter/cardinality:metrics:datapoint:- 'metric.name == "redis.cpu.time" and attributes["state"] != "sys" and attributes["state"] != "user"'- 'metric.name == "redis.cmd.calls" and attributes["cmd"] != "get" and attributes["cmd"] != "set" and attributes["cmd"] != "del" and attributes["cmd"] != "hget" and attributes["cmd"] != "hset" and attributes["cmd"] != "hgetall" and attributes["cmd"] != "lpush" and attributes["cmd"] != "rpop" and attributes["cmd"] != "zadd" and attributes["cmd"] != "expire"'- 'metric.name == "redis.cmd.usec" and attributes["cmd"] != "get" and attributes["cmd"] != "set" and attributes["cmd"] != "del" and attributes["cmd"] != "hget" and attributes["cmd"] != "hset" and attributes["cmd"] != "hgetall" and attributes["cmd"] != "lpush" and attributes["cmd"] != "rpop" and attributes["cmd"] != "zadd" and attributes["cmd"] != "expire"'transform/metadata_nullify:metric_statements:- context: metricstatements:- set(description, "")- set(unit, "")batch:send_batch_size: 2048send_batch_max_size: 4096timeout: 10sexporters:otlp_http:endpoint: ${env:OTEL_EXPORTER_OTLP_ENDPOINT}headers:api-key: ${env:NEW_RELIC_LICENSE_KEY}compression: gzipservice:extensions: [health_check]pipelines:metrics/redis:receivers: [redis]# If using resource/redis for custom name, add it to the processors list:# processors: [memory_limiter, resource_detection, resource/redis, attributes/entity_tags, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch]processors: [memory_limiter, resource_detection, attributes/entity_tags, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch]exporters: [otlp_http]이 설정의 역할
파이프라인의 각 구성 요소에는 특정 작업이 있습니다:
요소 설명 health_check수집기가 실행 중인지 확인할 수 있도록 0.0.0.0:13133에 상태 엔드포인트를 노출합니다.redis수신기10초마다 레디스 엔드포인트에 연결하고 레디스 INFO명령에서 메트릭을 읽습니다.server.address및server.port가 엔티티의 ID가 됩니다.memory_limiter컨테이너를 보호하기 위해 수집기 메모리 사용량을 제한합니다(512 MiB 소프트 제한, 128 MiB 스파이크). resource_detection호스트를 감지하고 host.name및host.id을(를) 추가하여 레디스 메트릭을 기본 호스트 엔티티에 연결합니다.attributes/entity_tags쿼리 범위를 OpenTelemetry 경로로 지정할 수 있도록 모든 메트릭에 instrumentation.provider: opentelemetry을(를) 찍습니다.cumulativetodelta뉴렐릭이 비율을 올바르게 차트로 표시할 수 있도록 레디스의 누적 카운터 ― 명령, 키스페이스 적중, 축출 등 ― 를 델타 값으로 변환합니다. filter/cardinality수집 비용을 제어하기 위해 높은 카디널리티 데이터 포인트( user및sys이외의 CPU 상태, 일반적이지 않은 명령에 대한 명령별 메트릭)를 삭제합니다.transform/metadata_nullify페이로드 크기를 줄이기 위해 메트릭 설명 및 단위를 지웁니다. batch네트워크 오버헤드를 줄이기 위해 내보내기 전에 데이터 포인트를 그룹화(배치당 2,048개, 최대 4,096개)하고 최소 10초마다 플러시합니다. otlp_http라이선스 키로 인증되고 gzip 압축을 사용하여 OTLP를 통해 처리된 메트릭을 뉴렐릭으로 내보냅니다. 팁
사용자 친화적인 엔티티 이름을 원하시나요? 기본적으로 레디스 엔티티의 이름은
server.address:server.port조합을 사용하여 지정됩니다. 대신 사람이 읽을 수 있는 사용자 지정 이름을 사용하려면, 위의 구성에서resource/redis섹션의 주석 처리를 제거하고,redis.instance.id값에 원하는 이름을 설정한 다음, 프로세서 파이프라인에resource/redis을(를) 추가하세요.
선택 사항: 인증 설정
기본적으로 수집기는 자격 증명 없이 레디스에 연결합니다. 레디스 인스턴스에 인증이 필요한 경우, 일치하는 자격 증명을 redis 수신기에 추가하세요. 설정에 맞는 옵션을 선택하세요:
선택 사항: 레디스 로그 수집
메트릭 외에도 수집기는 레디스의 로그 파일을 뉴렐릭으로 전달할 수 있으므로 로그 이벤트 ― 재시작, 지속성 이벤트 또는 오류 ― 를 동일한 엔티티의 메트릭 급증과 연관시킬 수 있습니다.
중요
기본적으로 도커의 레디스는 파일이 아닌 stdout 에 로그를 기록합니다. filelog 수신기로 로그를 수집하려면 레디스가 로그 파일에 기록하도록 설정하고 레디스와 수집기 컨테이너 간에 도커 볼륨을 통해 공유해야 합니다.
docker-compose.yml의 레디스 서비스에 다음을 추가합니다:
redis: image: redis:7 command: > sh -c "touch /data/redis.log && chmod 644 /data/redis.log && redis-server --logfile /data/redis.log" volumes: - redis-logs:/data그리고 수집기 서비스에 공유 볼륨을 추가합니다:
otel-collector: volumes: - redis-logs:/var/log/redis:ro그런 다음 docker-compose.yml의 하단에 추가합니다:
volumes: redis-logs:otel-collector-config.yaml에 filelog 수신기를 추가합니다:
receivers: # ... existing redis receiver ... file_log/redis: include: - /var/log/redis/redis.log start_at: end operators: - type: regex_parser regex: '^\d+:[XCSM] \d+ \w+ \d+ \d+:\d+:\d+\.\d+ (?P<level>.) ' on_error: send resource: db.system: redis파일의 로그 줄에는 자체적인 레디스 연결 컨텍스트가 없습니다 ― 뉴렐릭이 로그를 레디스 엔티티와 연결하도록 명시적으로 ID 속성을 추가해야 합니다. 레디스 엔티티의 ID와 일치하는 하드코딩된 값을 사용하여 resource/redis_logs 프로세서를 추가합니다:
processors: # ... existing processors ... resource/redis_logs: attributes: - key: server.address value: "redis" # Must match your redis receiver endpoint host action: upsert - key: server.port value: 6379 # Must match your redis receiver endpoint port action: upsert - key: instrumentation.provider value: opentelemetry action: upsert팁
사용자 지정 인스턴스 ID를 사용하시나요? 사용자 지정 엔티티 명명에 resource/redis 프로세서를 활성화한 경우, 위의 server.address 및 server.port 를 redis.instance.id(으)로 바꿉니다:
resource/redis_logs: attributes: - key: redis.instance.id value: "my-redis-instance" # Must match the value in resource/redis action: upsert - key: instrumentation.provider value: opentelemetry action: upsert서비스 섹션에 별도의 로그 파이프라인을 추가합니다:
service: pipelines: metrics/redis: receivers: [redis] processors: [memory_limiter, resource_detection, attributes/entity_tags, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch] exporters: [otlp_http] logs/redis: receivers: [file_log/redis] processors: [memory_limiter, resource/redis_logs, batch] exporters: [otlp_http]중요
수집기 컨테이너는 레디스 로그 파일에 대한 읽기 권한이 있어야 합니다. 로그 디렉터리를 컨테이너에 마운트할 때, 수집기 프로세스가 파일을 읽을 수 있는지 확인하세요. 호스트에서 다음을 실행합니다:
$sudo chmod 755 /var/log/redis$sudo chmod 644 /var/log/redis/redis.log선택 사항: 호스트 메트릭 수집
레디스 성능은 종종 호스트 리소스 압박 ― CPU 포화, 메모리 고갈 또는 디스크 I/O 경합을 추적합니다. 뉴렐릭에서 두 가지를 연관시킬 수 있도록 레디스와 함께 시스템 메트릭을 수집하는 hostmetrics 수신기를 추가합니다. 수집기가 컨테이너의 파일 시스템이 아닌 호스트 파일 시스템을 읽도록 도커 컨테이너 내부에서 실행할 때 root_path: /hostfs 설정이 필요합니다:
receivers: # ... existing receivers ... host_metrics: collection_interval: 10s root_path: /hostfs scrapers: cpu: metrics: system.cpu.utilization: {enabled: true} system.cpu.time: {enabled: true} load: metrics: system.cpu.load_average.1m: {enabled: true} system.cpu.load_average.5m: {enabled: true} system.cpu.load_average.15m: {enabled: true} memory: metrics: system.memory.usage: {enabled: true} system.memory.utilization: {enabled: true} disk: metrics: system.disk.io: {enabled: true} system.disk.operations: {enabled: true} filesystem: metrics: system.filesystem.usage: {enabled: true} system.filesystem.utilization: {enabled: true} network: metrics: system.network.io: {enabled: true} system.network.packets: {enabled: true}호스트 메트릭을 위한 별도의 metrics/host 파이프라인을 추가합니다(레디스 파이프라인에 host_metrics 을(를) 추가하지 마십시오):
service: pipelines: metrics/redis: receivers: [redis] processors: [memory_limiter, resource_detection, attributes/entity_tags, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch] exporters: [otlp_http] metrics/host: receivers: [host_metrics] processors: [memory_limiter, resource_detection, attributes/entity_tags, batch] exporters: [otlp_http]선택 사항: 커스텀 메타데이터 추가
사용자 지정 리소스 속성은 모든 레디스 메트릭에 컨텍스트 ― 환경, 팀 또는 티어 ― 를 태그로 지정하여 뉴렐릭에서 데이터를 필터링하고 그룹화할 수 있도록 합니다. 원하는 태그가 있는 resource/custom 프로세서를 추가합니다:
processors: # ... existing processors ... resource/custom: attributes: - key: environment value: "production" action: upsert - key: team value: "platform" action: upsert파이프라인에 프로세서를 포함하세요:
service: pipelines: metrics/redis: receivers: [redis] processors: [memory_limiter, resource_detection, resource/custom, attributes/entity_tags, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch] exporters: [otlp_http]선택 사항: 레디스 Cluster 모니터링 활성화
레디스 Cluster 모니터링은 현재 Prometheus 수신기 접근 방식(redis_exporter 사용)이 필요합니다. OTel Collector Contrib의 기본 레디스 수신기는 클러스터 메트릭에 필요한 CLUSTER INFO 명령을 아직 지원하지 않습니다. 클러스터 모니터링 설정을 위해 Prometheus 수신기 탭을 사용합니다.
도커 Compose 파일 생성
기존 레디스와 함께 수집기를 실행하려면 docker-compose.yml 을(를) 만듭니다. 동일한 디렉터리에 있는 .env 파일은 도커 Compose에 의해 자동으로 로드됩니다:
services: otel-collector: image: otel/opentelemetry-collector-contrib:latest env_file: .env volumes: - ./otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml:ro - /etc/machine-id:/etc/machine-id:ro # Uncomment if collecting Redis logs (requires shared volume — see logs step above): # - redis-logs:/var/log/redis:ro # Uncomment if collecting host metrics: # - /:/hostfs:ro # Uncomment if using TLS: # - ./certs:/etc/ssl/redis:ro environment: - NEW_RELIC_LICENSE_KEY=${NEW_RELIC_LICENSE_KEY} - OTEL_EXPORTER_OTLP_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT} # Uncomment if collecting host metrics: # - HOST_PROC=/hostfs/proc # - HOST_SYS=/hostfs/sys # - HOST_ETC=/hostfs/etc # Uncomment if using Redis authentication: # - REDIS_PASSWORD=${REDIS_PASSWORD} # - REDIS_USERNAME=${REDIS_USERNAME} command: ["--config=/etc/otelcol-contrib/config.yaml"] ports: - "13133:13133" healthcheck: test: ["CMD", "curl", "-f", "http://localhost:13133"] interval: 10s timeout: 5s retries: 3
# Uncomment if collecting Redis logs:# volumes:# redis-logs:팁
이전 단계에서 선택적 기능(로그, 호스트 메트릭, TLS 또는 인증)을 활성화한 경우 위의 도커 Compose 파일에서 해당 줄의 주석 처리를 제거합니다.
환경 파일 생성
도커 Compose는 docker-compose.yml과(와) 동일한 디렉터리에 있는 .env 파일에서 배포 관련 값을 읽어오므로 compose 파일에 라이선스 키가 노출되지 않습니다. .env 파일을 생성합니다:
$NEW_RELIC_LICENSE_KEY=YOUR_LICENSE_KEY$OTEL_EXPORTER_OTLP_ENDPOINT=YOUR_OTLP_ENDPOINT$# Set the New Relic OTLP endpoint for your region.$# See https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp플레이스홀더를 자체 값으로 바꿉니다:
| 변하기 쉬운 | 필수의 | 설명 |
|---|---|---|
NEW_RELIC_LICENSE_KEY | 네 | 귀하의 뉴렐릭 수집 라이선스 키. |
OTEL_EXPORTER_OTLP_ENDPOINT | 네 | 해당 리전의 뉴렐릭 OTLP 엔드포인트. 자세한 내용은 뉴렐릭 OTLP 엔드포인트를 참조하세요. |
시작 및 확인
백그라운드에서 수집기 시작:
$docker compose up -ddocker compose ps (으)로 컨테이너가 실행 중인지 확인합니다 ― 수집기는 running 상태를 표시해야 합니다. 종료된 경우 docker compose logs otel-collector 을(를) 사용하여 로그를 확인하세요 ― 가장 일반적인 원인은 YAML 들여쓰기 오류 및 연결할 수 없는 레디스 엔드포인트입니다.
그런 다음 메트릭이 뉴렐릭에 도달하는지 확인합니다. 시작 후 약 1분 정도 기다린 다음 쿼리 빌더에서 다음 쿼리를 실행합니다:
SELECT count(*) FROM Metric WHERE metricName LIKE 'redis.%' AND instrumentation.provider = 'opentelemetry' SINCE 5 minutes ago0이 아닌 개수는 레디스 메트릭이 전송되고 있음을 확인합니다. 0을(를) 반환하는 경우, 레디스 문제 해결(OpenTelemetry)을 참조하세요.
수집기 설정 생성
이 설정은 redis_exporter 에서 메트릭을 스크랩하여 뉴렐릭으로 보냅니다. 다음과 같은 주요 작업을 처리합니다:
prometheus수신기를 통해redis_exporterPrometheus 엔드포인트를 스크랩 합니다.Prometheus 메트릭을 뉴렐릭의 레디스 메트릭 이름으로 이름 바꾸기
데이터 가공 ― 카디널리티를 줄이고, 카운터를 델타로 변환하며, 엔티티 합성을 위해 태그를 지정합니다.
처리된 메트릭을 OTLP를 통해 뉴렐릭으로 내보내기
프로젝트 디렉터리에
otel-collector-config.yaml을(를) 만듭니다:extensions:health_check:endpoint: "0.0.0.0:13133"receivers:prometheus:config:scrape_configs:- job_name: 'redis'scrape_interval: 10sstatic_configs:- targets: ['redis-exporter:9121'] # Update with your Redis exporter host:portmetric_relabel_configs:- source_labels: [__name__]regex: '(go_|process_|promhttp_|redis_exporter_).*'action: dropprocessors:memory_limiter:check_interval: 5slimit_mib: 512spike_limit_mib: 128resource_detection:detectors: [env, system]timeout: 5soverride: falsesystem:resource_attributes:host.name:enabled: truehost.id:enabled: true# Required: Set a unique identifier for your Redis entity.# The Prometheus receiver does not provide server.address/server.port,# so redis.instance.id is required for entity creation in New Relic.resource/redis_identity:attributes:- key: redis.instance.idvalue: "my-redis-instance:6379" # Update with a unique name for this Redis instanceaction: upsertattributes/entity_tags:actions:- key: instrumentation.providervalue: opentelemetryaction: upsertmetricstransform:transforms:- include: redis_uptime_in_secondsaction: updatenew_name: redis.uptime- include: redis_connected_clientsaction: updatenew_name: redis.clients.connected- include: redis_blocked_clientsaction: updatenew_name: redis.clients.blocked- include: redis_memory_used_bytesaction: updatenew_name: redis.memory.used- include: redis_memory_max_bytesaction: updatenew_name: redis.maxmemory- include: redis_mem_fragmentation_ratioaction: updatenew_name: redis.memory.fragmentation_ratio- include: redis_memory_used_rss_bytesaction: updatenew_name: redis.memory.rss- include: redis_memory_used_peak_bytesaction: updatenew_name: redis.memory.peak- include: redis_memory_used_lua_bytesaction: updatenew_name: redis.memory.lua- include: redis_connections_received_totalaction: updatenew_name: redis.connections.received- include: redis_rejected_connections_totalaction: updatenew_name: redis.connections.rejected- include: redis_commands_processed_totalaction: updatenew_name: redis.commands.processed- include: redis_keyspace_hits_totalaction: updatenew_name: redis.keyspace.hits- include: redis_keyspace_misses_totalaction: updatenew_name: redis.keyspace.misses- include: redis_evicted_keys_totalaction: updatenew_name: redis.keys.evicted- include: redis_expired_keys_totalaction: updatenew_name: redis.keys.expired- include: redis_net_input_bytes_totalaction: updatenew_name: redis.net.input- include: redis_net_output_bytes_totalaction: updatenew_name: redis.net.output- include: redis_connected_slavesaction: updatenew_name: redis.slaves.connected- include: redis_db_keysaction: updatenew_name: redis.db.keys- include: redis_db_keys_expiringaction: updatenew_name: redis.db.expires- include: redis_rdb_changes_since_last_saveaction: updatenew_name: redis.rdb.changes_since_last_save- include: redis_db_avg_ttl_secondsaction: updatenew_name: redis.db.avg_ttl- include: redis_latest_fork_secondsaction: updatenew_name: redis.latest_fork- include: redis_master_repl_offsetaction: updatenew_name: redis.replication.offset- include: redis_repl_backlog_first_byte_offsetaction: updatenew_name: redis.replication.backlog_first_byte_offset- include: redis_commands_totalaction: updatenew_name: redis.cmd.calls- include: redis_commands_duration_seconds_totalaction: updatenew_name: redis.cmd.usec- include: redis_cpu_sys_seconds_totalaction: updatenew_name: redis.cpu.timeoperations:- action: add_labelnew_label: statenew_value: sys- include: redis_cpu_user_seconds_totalaction: updatenew_name: redis.cpu.timeoperations:- action: add_labelnew_label: statenew_value: usercumulativetodelta:include:match_type: regexpmetrics:- redis\.commands\.processed- redis\.connections\.received- redis\.connections\.rejected- redis\.keys\.evicted- redis\.keys\.expired- redis\.keyspace\.hits- redis\.keyspace\.misses- redis\.net\.input- redis\.net\.output- redis\.cpu\.time- redis\.cmd\.calls- redis\.cmd\.usec- redis\.uptimefilter/cardinality:metrics:datapoint:- 'metric.name == "redis.cpu.time" and attributes["state"] != "sys" and attributes["state"] != "user"'- 'metric.name == "redis.cmd.calls" and attributes["cmd"] != "get" and attributes["cmd"] != "set" and attributes["cmd"] != "del" and attributes["cmd"] != "hget" and attributes["cmd"] != "hset" and attributes["cmd"] != "hgetall" and attributes["cmd"] != "lpush" and attributes["cmd"] != "rpop" and attributes["cmd"] != "zadd" and attributes["cmd"] != "expire"'- 'metric.name == "redis.cmd.usec" and attributes["cmd"] != "get" and attributes["cmd"] != "set" and attributes["cmd"] != "del" and attributes["cmd"] != "hget" and attributes["cmd"] != "hset" and attributes["cmd"] != "hgetall" and attributes["cmd"] != "lpush" and attributes["cmd"] != "rpop" and attributes["cmd"] != "zadd" and attributes["cmd"] != "expire"'transform/metadata_nullify:metric_statements:- context: metricstatements:- set(description, "")- set(unit, "")batch:send_batch_size: 2048send_batch_max_size: 4096timeout: 10sexporters:otlp_http:endpoint: ${env:OTEL_EXPORTER_OTLP_ENDPOINT}headers:api-key: ${env:NEW_RELIC_LICENSE_KEY}compression: gzipservice:extensions: [health_check]pipelines:metrics/redis:receivers: [prometheus]processors: [memory_limiter, resource_detection, resource/redis_identity, attributes/entity_tags, metricstransform, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch]exporters: [otlp_http]이 설정의 역할
파이프라인의 각 구성 요소에는 특정 작업이 있습니다:
요소 설명 health_check수집기가 실행 중인지 확인할 수 있도록 0.0.0.0:13133에 상태 엔드포인트를 노출합니다.prometheus수신기10초마다 redis_exporter엔드포인트(기본값redis-exporter:9121)를 스크랩하고 익스포터 자체의go_*,process_*,promhttp_*및redis_exporter_*메트릭을 삭제합니다.memory_limiter컨테이너를 보호하기 위해 수집기 메모리 사용량을 제한합니다(512 MiB 소프트 제한, 128 MiB 스파이크). resource_detection호스트를 감지하고 host.name및host.id을(를) 추가하여 레디스 메트릭을 기본 호스트 엔티티에 연결합니다.resource/redis_identity뉴렐릭에서 레디스 엔티티를 식별하는 redis.instance.id을(를) 설정합니다. Prometheus 수신기는server.address또는server.port을(를) 제공하지 않으므로 여기에 필요합니다.attributes/entity_tags쿼리 범위를 OpenTelemetry 경로로 지정할 수 있도록 모든 메트릭에 instrumentation.provider: opentelemetry을(를) 찍습니다.metricstransform익스포터의 Prometheus 메트릭(예: redis_uptime_in_seconds)의 이름을 뉴렐릭의 레디스 이름(redis.uptime)으로 바꾸고 CPU 메트릭에state레이블을 추가합니다.cumulativetodelta뉴렐릭이 비율을 올바르게 차트로 표시할 수 있도록 누적 카운터 ― 명령, 키스페이스 적중, 축출 등 ― 를 델타 값으로 변환합니다. filter/cardinality수집 비용을 제어하기 위해 높은 카디널리티 데이터 포인트( user및sys이외의 CPU 상태, 일반적이지 않은 명령에 대한 명령별 메트릭)를 삭제합니다.transform/metadata_nullify페이로드 크기를 줄이기 위해 메트릭 설명 및 단위를 지웁니다. batch네트워크 오버헤드를 줄이기 위해 내보내기 전에 데이터 포인트를 그룹화(배치당 2,048개, 최대 4,096개)하고 최소 10초마다 플러시합니다. otlp_http라이선스 키로 인증되고 gzip 압축을 사용하여 OTLP를 통해 처리된 메트릭을 뉴렐릭으로 내보냅니다. 중요
Prometheus 수신기 접근 방식에는
redis.instance.id이(가) 있는resource/redis_identity프로세서가 필수 입니다. 네이티브 레디스 수신기와 달리 Prometheus 수신기는server.address또는server.port을(를) 제공하지 않습니다 ― 따라서redis.instance.id은(는) 뉴렐릭에서 레디스 엔티티를 식별할 수 있는 유일한 방법입니다. 각 인스턴스에 대해 고유하고 기술적인 이름으로 설정합니다(예:prod-redis-cache:6379).
선택 사항: 레디스 Cluster 모니터링 활성화
레디스가 Cluster 모드로 실행 중인 경우 모든 노드에서 클러스터 상태 메트릭을 자동으로 수집하려면 --is-cluster 플래그와 함께 redis_exporter 을(를) 시작합니다:
$redis_exporter --redis.addr=redis://localhost:7000 --is-cluster위의 Prometheus 수신기 설정은 이미 클러스터 메트릭의 이름을 변경합니다(예: redis_cluster_state → redis.cluster.state). 뉴렐릭에 별도의 클러스터 엔티티를 생성하려면 redis.instance.id이(가) 포함되지 않은 별도의 파이프라인 에 redis.cluster.name 리소스 속성을 추가합니다:
resource/cluster: attributes: - key: redis.cluster.name value: "my-redis-cluster" # Update with your cluster name action: upsert서비스 섹션에 클러스터 파이프라인을 추가합니다:
metrics/cluster: receivers: [prometheus] processors: [memory_limiter, resource_detection, resource/cluster, attributes/entity_tags, metricstransform, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch] exporters: [otlp_http]중요
클러스터 엔티티는 redis.cluster.name 이(가) 존재하고 redis.instance.id 이(가) 없어야 합니다. 동일한 메트릭에 두 가지가 모두 설정된 경우 인스턴스 엔티티만 생성됩니다. 인스턴스 및 클러스터 메트릭에 별도의 파이프라인을 사용하세요.
선택 사항: 레디스 로그 수집
메트릭 외에도 수집기는 레디스의 로그 파일을 뉴렐릭으로 전달할 수 있으므로 로그 이벤트 ― 재시작, 지속성 이벤트 또는 오류 ― 를 동일한 엔티티의 메트릭 급증과 연관시킬 수 있습니다.
중요
기본적으로 도커의 레디스는 파일이 아닌 stdout 에 로그를 기록합니다. filelog 수신기로 로그를 수집하려면 레디스가 로그 파일에 기록하도록 설정하고 레디스와 수집기 컨테이너 간에 도커 볼륨을 통해 공유해야 합니다.
docker-compose.yml의 레디스 서비스에 다음을 추가합니다:
redis: image: redis:7 command: > sh -c "touch /data/redis.log && chmod 644 /data/redis.log && redis-server --logfile /data/redis.log" volumes: - redis-logs:/data그리고 수집기 서비스에 공유 볼륨을 추가합니다:
otel-collector: volumes: - redis-logs:/var/log/redis:ro그런 다음 docker-compose.yml의 하단에 추가합니다:
volumes: redis-logs:otel-collector-config.yaml에 filelog 수신기를 추가합니다:
receivers: # ... existing prometheus receiver ... file_log/redis: include: - /var/log/redis/redis.log start_at: end operators: - type: regex_parser regex: '^\d+:[XCSM] \d+ \w+ \d+ \d+:\d+:\d+\.\d+ (?P<level>.) ' on_error: send resource: db.system: redis파일의 로그 줄에는 자체적인 레디스 연결 컨텍스트가 없습니다 ― 뉴렐릭이 로그를 레디스 엔티티와 연결하도록 명시적으로 ID 속성을 추가해야 합니다. 레디스 엔티티의 ID와 일치하는 하드코딩된 값을 사용하여 resource/redis_logs 프로세서를 추가합니다:
processors: # ... existing processors ... resource/redis_logs: attributes: - key: redis.instance.id value: "my-redis-instance:6379" # Must match the value in resource/redis_identity action: upsert - key: instrumentation.provider value: opentelemetry action: upsert서비스 섹션에 별도의 로그 파이프라인을 추가합니다:
service: pipelines: metrics/redis: receivers: [prometheus] processors: [memory_limiter, resource_detection, resource/redis_identity, attributes/entity_tags, metricstransform, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch] exporters: [otlp_http] logs/redis: receivers: [file_log/redis] processors: [memory_limiter, resource/redis_logs, batch] exporters: [otlp_http]선택 사항: 호스트 메트릭 수집
레디스 성능은 종종 호스트 리소스 압박 ― CPU 포화, 메모리 고갈 또는 디스크 I/O 경합을 추적합니다. 뉴렐릭에서 두 가지를 연관시킬 수 있도록 레디스와 함께 시스템 메트릭을 수집하는 hostmetrics 수신기를 추가합니다. 수집기가 컨테이너의 파일 시스템이 아닌 호스트 파일 시스템을 읽도록 도커 컨테이너 내부에서 실행할 때 root_path: /hostfs 설정이 필요합니다:
receivers: # ... existing receivers ... host_metrics: collection_interval: 10s root_path: /hostfs scrapers: cpu: metrics: system.cpu.utilization: {enabled: true} system.cpu.time: {enabled: true} load: metrics: system.cpu.load_average.1m: {enabled: true} system.cpu.load_average.5m: {enabled: true} system.cpu.load_average.15m: {enabled: true} memory: metrics: system.memory.usage: {enabled: true} system.memory.utilization: {enabled: true} disk: metrics: system.disk.io: {enabled: true} system.disk.operations: {enabled: true} filesystem: metrics: system.filesystem.usage: {enabled: true} system.filesystem.utilization: {enabled: true} network: metrics: system.network.io: {enabled: true} system.network.packets: {enabled: true}호스트 메트릭을 위한 별도의 metrics/host 파이프라인을 추가합니다(레디스 파이프라인에 host_metrics 을(를) 추가하지 마십시오):
service: pipelines: metrics/redis: receivers: [prometheus] processors: [memory_limiter, resource_detection, resource/redis_identity, attributes/entity_tags, metricstransform, cumulativetodelta, filter/cardinality, transform/metadata_nullify, batch] exporters: [otlp_http] metrics/host: receivers: [host_metrics] processors: [memory_limiter, resource_detection, attributes/entity_tags, batch] exporters: [otlp_http]도커 Compose 파일 생성
기존 레디스와 함께 redis_exporter 및 수집기를 실행하려면 docker-compose.yml 을(를) 생성합니다. 동일한 디렉터리에 있는 .env 파일은 도커 Compose에 의해 자동으로 로드됩니다:
services: redis-exporter: image: oliver006/redis_exporter:latest environment: - REDIS_ADDR=redis://redis:6379 # Update with your Redis service name:port # Uncomment if using Redis authentication: # - REDIS_PASSWORD=${REDIS_PASSWORD} # - REDIS_USER=${REDIS_USERNAME} ports: - "9121:9121" healthcheck: test: ["CMD-SHELL", "redis_exporter --version || exit 1"] interval: 10s timeout: 5s retries: 3
otel-collector: image: otel/opentelemetry-collector-contrib:latest env_file: .env volumes: - ./otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml:ro - /etc/machine-id:/etc/machine-id:ro environment: - NEW_RELIC_LICENSE_KEY=${NEW_RELIC_LICENSE_KEY} - OTEL_EXPORTER_OTLP_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT} command: ["--config=/etc/otelcol-contrib/config.yaml"] ports: - "13133:13133" depends_on: redis-exporter: condition: service_healthy healthcheck: test: ["CMD", "curl", "-f", "http://localhost:13133"] interval: 10s timeout: 5s retries: 3팁
대신 NRDOT 수집기를 사용하려면 otel-collector 이미지를 newrelic/nrdot-collector:latest (으)로 교체하고 설정 마운트 경로를 /etc/otel/config.yaml(으)로 업데이트합니다.
환경 파일 생성
도커 Compose는 docker-compose.yml과(와) 동일한 디렉터리에 있는 .env 파일에서 배포 관련 값을 읽어오므로 compose 파일에 라이선스 키가 노출되지 않습니다. .env 파일을 생성합니다:
$NEW_RELIC_LICENSE_KEY=YOUR_LICENSE_KEY$OTEL_EXPORTER_OTLP_ENDPOINT=YOUR_OTLP_ENDPOINT$# Set the New Relic OTLP endpoint for your region.$# See https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp플레이스홀더를 자체 값으로 바꿉니다:
| 변하기 쉬운 | 필수의 | 설명 |
|---|---|---|
NEW_RELIC_LICENSE_KEY | 네 | 귀하의 뉴렐릭 수집 라이선스 키. |
OTEL_EXPORTER_OTLP_ENDPOINT | 네 | 해당 리전의 뉴렐릭 OTLP 엔드포인트. 자세한 내용은 뉴렐릭 OTLP 엔드포인트를 참조하세요. |
시작 및 확인
백그라운드에서 수집기 및 redis_exporter 을(를) 시작합니다:
$docker compose up -ddocker compose ps 을(를) 사용하여 컨테이너가 실행 중인지 확인하세요 ― 수집기와 redis-exporter 모두 running 상태를 표시해야 합니다. 수집기가 종료된 경우 docker compose logs otel-collector 을(를) 사용하여 로그를 확인하세요 ― 가장 일반적인 원인은 YAML 들여쓰기 오류, 연결할 수 없는 redis_exporter 또는 익스포터가 실행되지 않는 것입니다.
그런 다음 메트릭이 뉴렐릭에 도달하는지 확인합니다. 시작 후 약 1분 정도 기다린 다음 쿼리 빌더에서 다음 쿼리를 실행합니다:
SELECT count(*) FROM Metric WHERE metricName LIKE 'redis.%' AND instrumentation.provider = 'opentelemetry' SINCE 5 minutes ago0이 아닌 개수는 레디스 메트릭이 전송되고 있음을 확인합니다. 0을(를) 반환하는 경우, 레디스 문제 해결(OpenTelemetry)을 참조하세요.
팁
APM과 레디스 상관관계 분석: 서비스 맵에서 APM 애플리케이션과 레디스 인스턴스를 연결하려면 선택한 엔티티 식별자 패턴 ― redis.instance.id 또는 server.address 및 server.port ― 과 함께 db.system="redis" 을(를) APM 메트릭의 리소스 속성으로 포함합니다. 이 값은 수집기에서 설정한 값과 일치해야 합니다. 이를 통해 뉴렐릭 내에서 서비스 간 가시성을 확보하고 더 빠른 문제 진단, 해결이 가능해집니다.
다음 단계
- 자체 호스팅 설치: VM/베어 메탈에서 레디스 모니터링
- Kubernetes 설치: DaemonSet을 사용하여 Kubernetes에 배포
- 데이터 보기: 대시보드 탐색 및 알림 설정
- 메트릭 참조: 사용 가능한 메트릭의 전체 목록
- 문제 진단, 해결: 일반적인 문제 및 해결 방법