OpenTelemetry를 사용하여 자체 호스팅 HAProxy 로드 밸런서를 모니터하여 성능 메트릭 및 텔레메트리 데이터를 뉴렐릭으로 전송하십시오.
세 가지 수집기 옵션 중에서 선택할 수 있습니다:
- NRDOT: OpenTelemetry의 뉴렐릭 배포판(권장 — 안내 설치를 통해 자동화됨)
- OTel Collector Contrib: haproxyreceiver가 포함된 표준 OpenTelemetry Collector
- Prometheus Receiver: 이미 HAProxy의 내장 Prometheus 엔드포인트(HAProxy 2.0+)를 사용 중인 환경의 경우
팁
현재 nri-haproxy을(를) 사용 중이고 OpenTelemetry로 전환하려면 구형 통합을 비활성화하고 아래의 설정 단계를 따르십시오. OTel 기반 접근 방식은 더 풍부한 메타데이터(프런트엔드/백앤드/서버당 haproxy.proxy_name, haproxy.service_name)를 포함한 차원 메트릭을 제공합니다.
시작하기 전에
다음 사항을 확인하십시오:
유효한 뉴렐릭 클러스터
stats 엔드포인트가 활성화된 HAProxy 버전 2.0 이상(stats를 지원하는 모든 버전, Prometheus 경로는 2.0 이상 필요)
Linux 호스트에 다음 수집기 중 하나가 설치되어 있어야 합니다.
Linux 호스트에서 네트워크 액세스 대상:
- HAProxy 통계 엔드포인트(일반적으로
http://localhost:8404/stats) - 뉴렐릭의 OTLP 엔드포인트
- HAProxy 통계 엔드포인트(일반적으로
HAProxy 모니터링 설정
원하는 수집기를 선택하고 다음 단계를 따르세요.
NRDOT 수집기는 haproxyreceiver 및 뉴렐릭 전용 구성 요소를 포함하는 사전 구성된 배포판입니다.
NRDOT 수집기를 설치하고 구성하려면 다음 단계를 따르십시오:
팁
검증 단계에서 오류가 발생하면 누락된 구성 요소를 설치한 후 계속 진행하십시오. NRDOT 수집기 설치에 도움이 필요하신가요? nrdot-수집기-releases의 설치 섹션을 확인하세요.
설치 중 사용 export collector_distro="nrdot-collector"
아직 HAProxy stats 엔드포인트를 활성화하지 않았다면 haproxy.cfg에 다음을 추가하십시오:
frontend stats bind *:8404 stats enable stats uri /stats stats refresh 10s설정을 적용하려면 HAProxy를 다시 로드하십시오:
$sudo systemctl reload haproxystats 엔드포인트에 액세스할 수 있는지 확인하십시오:
$curl -s http://localhost:8404/statsHAProxy 통계가 포함된 HTML 출력을 확인하실 수 있습니다.
HAProxy 통계 엔드포인트에서 메트릭을 수집하고 뉴렐릭으로 전송하도록 NRDOT 수집기를 설정하십시오.
중요
모니터링 방식을 선택하세요:
HAProxy 전용 모니터링(이 가이드): HAProxy 로드 밸런서 성능 및 메트릭만 모니터합니다.
전체 서버 모니터링: HAProxy와 전체 서버(CPU 사용량, 메모리, 디스크 공간, 시스템 로그)를 모니터합니다.
HAProxy뿐만 아니라 전체 서버를 모니터하려면 NRDOT 수집기의 기본 설정을 대신 사용하고 여기에 HAProxy 수신기 설정을 추가하십시오.
설정 파일 /etc/nrdot-collector/haproxy-config.yaml 만듭니다.
receivers: haproxy: endpoint: http://localhost:8404/stats collection_interval: 15s
processors: resourcedetection: detectors: [system] system: resource_attributes: host.name: enabled: true host.id: enabled: true
batch:
exporters: otlphttp: endpoint: ${env:OTEL_EXPORTER_OTLP_ENDPOINT} headers: api-key: ${env:NEW_RELIC_LICENSE_KEY}
service: pipelines: metrics: receivers: [haproxy] processors: [resourcedetection, batch] exporters: [otlphttp]이 설정은 15초 간격으로 17개의 모든 기본 메트릭을 수집합니다. haproxyreceiver는 각 메트릭에 haproxy.proxy_name, haproxy.service_name 및 haproxy.addr 속성을 자동으로 추가합니다.
더 깊은 가시성을 위해 추가 메트릭(총 27개: 기본 17개+선택 10개)을 활성화하려면 선택 메트릭을 추가하십시오:
receivers: haproxy: endpoint: http://localhost:8404/stats collection_interval: 15s metrics: haproxy.connections.average_time: enabled: true haproxy.requests.average_time: enabled: true haproxy.responses.average_time: enabled: true haproxy.active: enabled: true haproxy.backup: enabled: true haproxy.downtime: enabled: true haproxy.failed_checks: enabled: true haproxy.weight: enabled: true haproxy.sessions.total: enabled: true haproxy.connections.total: enabled: true팁
아래의 최적화된 설정은 포괄적 모드와 비교하여 데이터 수집을 약 85% 줄입니다. 모든 대시보드와 골든 메트릭은 계속 정상적으로 작동합니다.
데이터 수집량을 줄이려면 60초 간격을 사용하고 최적화 프로세서를 추가하십시오:
receivers: haproxy: endpoint: http://localhost:8404/stats collection_interval: 60s
processors: resourcedetection: detectors: [system] system: resource_attributes: host.name: enabled: true host.id: enabled: true
transform/metadata_nullify: metric_statements: - context: metric statements: - set(description, "") where description != "" - set(unit, "") where unit != ""
resource/remove_attributes: attributes: - key: os.description action: delete - key: telemetry.sdk.version action: delete - key: telemetry.sdk.language action: delete - key: telemetry.sdk.name action: delete - key: host.arch action: delete
batch: send_batch_size: 2048 timeout: 30s
exporters: otlphttp: endpoint: ${env:OTEL_EXPORTER_OTLP_ENDPOINT} headers: api-key: ${env:NEW_RELIC_LICENSE_KEY}
service: pipelines: metrics: receivers: [haproxy] processors: [resourcedetection, transform/metadata_nullify, resource/remove_attributes, batch] exporters: [otlphttp]구성 매개변수
매개변수 | 설명 |
|---|---|
| HAProxy 통계 엔드포인트 URL(예:
)로 교체하십시오. |
| 메트릭 수집 간격입니다. 전체 세부 정보는
, 더 적은 수집 볼륨은
|
HAProxy 설정 파일을 사용하고 OTLP 엔드포인트를 설정하도록 NRDOT 수집기 설정을 업데이트하십시오.
OTLP 엔드포인트에 대한 정보는 뉴렐릭 OTLP 엔드포인트를 참조하십시오.
중요
라이선스 키는 설치 중에 /etc/nrdot-collector/nrdot-collector.conf 에 이미 구성되어 있습니다. 설정 파일 경로와 OTLP 엔드포인트만 업데이트하면 됩니다.
수집기 설정 파일을 업데이트합니다.
$export collector_distro="nrdot-collector"$export otlp_endpoint="<YOUR_NEWRELIC_OTLP_ENDPOINT>" # Replace with your region's endpoint$
$# Update the config file path to point to haproxy-config.yaml$sudo sed -i 's|OTELCOL_OPTIONS="--config=/etc/nrdot-collector/config.yaml"|OTELCOL_OPTIONS="--config=/etc/nrdot-collector/haproxy-config.yaml"|' /etc/${collector_distro}/${collector_distro}.conf$
$# Add the OTLP endpoint$echo "OTEL_EXPORTER_OTLP_ENDPOINT=${otlp_endpoint}" | sudo tee -a /etc/${collector_distro}/${collector_distro}.conf > /dev/nullNRDOT 수집기 서비스를 시작(또는 다시 시작)하십시오:
$sudo systemctl daemon-reload$sudo systemctl restart nrdot-collector서비스 상태를 확인하세요:
$sudo systemctl status nrdot-collector설정 오류가 있는지 로그를 검토하십시오:
$sudo journalctl -u nrdot-collector -n 50 --no-pager데이터가 유입되도록 2~3분 정도 기다린 후, 뉴렐릭에서 확인하십시오:
FROM Metric SELECT uniques(metricName)WHERE metricName LIKE 'haproxy.%'SINCE 10 minutes ago17개(기본값) 또는 27개(모든 메트릭 활성화)의 고유한 HAProxy 메트릭 이름이 표시되어야 합니다. 차원 속성을 확인하십시오:
FROM Metric SELECT latest(haproxy.sessions.count)FACET haproxy.proxy_name, haproxy.service_nameSINCE 5 minutes agoOpenTelemetry Collector Contrib 배포판을 haproxyreceiver와 함께 사용하여 HAProxy 서버를 모니터할 수 있습니다. haproxyreceiver는 HAProxy의 CSV 통계 엔드포인트를 스크랩하고 프런트엔드별, 백앤드별, 서버별 세분성으로 차원 메트릭을 생성합니다.
아직 HAProxy stats 엔드포인트를 활성화하지 않았다면 haproxy.cfg에 다음을 추가하십시오:
frontend stats bind *:8404 stats enable stats uri /stats stats refresh 10s설정을 적용하려면 HAProxy를 다시 로드하십시오:
$sudo systemctl reload haproxystats 엔드포인트에 액세스할 수 있는지 확인하십시오:
$curl -s http://localhost:8404/stats아직 OpenTelemetry Collector Contrib을 설치하지 않은 경우 OpenTelemetry Collector 릴리스에서 최신 릴리스를 다운로드하여 설치합니다:
Debian/Ubuntu의 경우:
$wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/latest/download/otelcol-contrib_<VERSION>_linux_amd64.deb$sudo dpkg -i otelcol-contrib_<VERSION>_linux_amd64.debRHEL/Amazon Linux의 경우:
$wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/latest/download/otelcol-contrib_<VERSION>_linux_amd64.rpm$sudo rpm -U otelcol-contrib_<VERSION>_linux_amd64.rpm중요
편집하기 전에: 기존 설정을 백업하세요. sudo cp /etc/otelcol-contrib/config.yaml /etc/otelcol-contrib/config.yaml.backup
수집기 설정 파일(/etc/otelcol-contrib/config.yaml)의 내용을 다음으로 교체하십시오:
receivers: haproxy: endpoint: http://localhost:8404/stats collection_interval: 15s
processors: resourcedetection: detectors: [system] system: resource_attributes: host.name: enabled: true host.id: enabled: true
batch:
exporters: otlphttp: endpoint: ${env:OTEL_EXPORTER_OTLP_ENDPOINT} headers: api-key: ${env:NEW_RELIC_LICENSE_KEY}
service: pipelines: metrics: receivers: [haproxy] processors: [resourcedetection, batch] exporters: [otlphttp]이 최소 설정은 17개의 기본 메트릭을 모두 수집합니다. haproxyreceiver는 각 메트릭에 haproxy.proxy_name, haproxy.service_name 및 haproxy.addr 속성을 자동으로 추가합니다.
더 깊은 가시성을 위해 추가 메트릭(총 27개: 기본 17개+선택 10개)을 활성화하려면 metrics 섹션을 추가하십시오:
receivers: haproxy: endpoint: http://localhost:8404/stats collection_interval: 15s metrics: haproxy.connections.average_time: enabled: true haproxy.requests.average_time: enabled: true haproxy.responses.average_time: enabled: true haproxy.active: enabled: true haproxy.backup: enabled: true haproxy.downtime: enabled: true haproxy.failed_checks: enabled: true haproxy.weight: enabled: true haproxy.sessions.total: enabled: true haproxy.connections.total: enabled: true구성 매개변수
매개변수 | 설명 |
|---|---|
| HAProxy 통계 엔드포인트 URL(예:
) |
| 메트릭 수집 간격입니다. 권장 사항: 전체 세부 정보의 경우
, 수집 볼륨을 줄이려면
|
필요한 환경 변수를 설정하세요:
$# Set your New Relic license key$export NEW_RELIC_LICENSE_KEY="<YOUR_LICENSE_KEY>"$
$# Set the OTLP endpoint. For more information, refer to New Relic OTLP endpoint: https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp$export OTEL_EXPORTER_OTLP_ENDPOINT="<YOUR_NEWRELIC_OTLP_ENDPOINT>"systemd 서비스의 경우, 서비스 환경 파일에 다음을 추가하십시오:
$echo "NEW_RELIC_LICENSE_KEY=<YOUR_LICENSE_KEY>" | sudo tee -a /etc/otelcol-contrib/otelcol-contrib.conf$echo "OTEL_EXPORTER_OTLP_ENDPOINT=<YOUR_NEWRELIC_OTLP_ENDPOINT>" | sudo tee -a /etc/otelcol-contrib/otelcol-contrib.conf<YOUR_LICENSE_KEY> 로 바꾸세요.
수집기 서비스를 시작(또는 다시 시작)하십시오:
$sudo systemctl daemon-reload$sudo systemctl restart otelcol-contrib서비스 상태를 확인하세요:
$sudo systemctl status otelcol-contrib설정 오류가 있는지 로그를 검토하십시오:
$sudo journalctl -u otelcol-contrib -n 50 --no-pager데이터가 유입되도록 2~3분 정도 기다린 후, 뉴렐릭에서 확인하십시오:
FROM Metric SELECT uniques(metricName)WHERE metricName LIKE 'haproxy.%'SINCE 10 minutes agoHAProxy 메트릭이 나타나는 것을 볼 수 있습니다. 차원 속성을 확인하십시오:
FROM Metric SELECT latest(haproxy.sessions.count)WHERE metricName = 'haproxy.sessions.count'FACET haproxy.proxy_name, haproxy.service_nameSINCE 5 minutes ago환경에 HAProxy의 내장 Prometheus 엔드포인트가 이미 활성화되어 있거나 Prometheus 기반 모니터링 스택에서 마이그레이션하는 경우 이 접근 방식을 사용하십시오.
팁
권장 사항: HAProxy Prometheus 엔드포인트가 아직 활성화되어 있지 않은 경우, 대신 NRDOT collector [NRDOT 수집기] 또는 OpenTelemetry Collector Contrib 탭을 사용하십시오. 이들은 Prometheus 익스포터 모듈 없이 HAProxy 통계 엔드포인트에 직접 연결됩니다.
haproxy.cfg의 통계 프런트엔드에 Prometheus 익스포터를 추가하십시오:
frontend stats bind *:8404 http-request use-service prometheus-exporter if { path /metrics } stats enable stats uri /stats stats refresh 10s핵심 줄은 http-request use-service prometheus-exporter if { path /metrics } 입니다. ― 이는 /metrics에 대한 requests를 가로채고 HAProxy의 내장 promex 모듈을 통해 Prometheus 형식의 메트릭을 제공합니다.
팁
HAProxy 2.0~2.3을 실행 중인 경우, 프런트엔드에 option http-use-htx도 추가해야 합니다. 이 옵션은 HAProxy 2.4+에서 기본값이 되었으며 더 이상 필요하지 않습니다.
HAProxy 다시 로드:
$sudo systemctl reload haproxyPrometheus 엔드포인트를 확인하십시오:
$curl -s http://localhost:8404/metrics | head -20haproxy_frontend_current_sessions 및 haproxy_backend_http_responses_total과(와) 같은 Prometheus 형식의 메트릭을 확인하실 수 있습니다. HAProxy는 이 엔드포인트를 통해 약 204개의 메트릭을 노출합니다.
중요
Prometheus 엔드포인트는 HAProxy 2.0 이상이 필요합니다. 이전 버전을 실행 중인 경우 CSV 통계 엔드포인트를 사용하고 모든 HAProxy 버전에서 작동하는 haproxyreceiver와 함께 OTel Collector Contrib 탭을 대신 사용하십시오.
아직 OpenTelemetry Collector Contrib을 설치하지 않은 경우 OpenTelemetry Collector 릴리스에서 최신 릴리스를 다운로드하여 설치합니다:
Debian/Ubuntu의 경우:
$wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/latest/download/otelcol-contrib_<VERSION>_linux_amd64.deb$sudo dpkg -i otelcol-contrib_<VERSION>_linux_amd64.debRHEL/Amazon Linux의 경우:
$wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/latest/download/otelcol-contrib_<VERSION>_linux_amd64.rpm$sudo rpm -U otelcol-contrib_<VERSION>_linux_amd64.rpm이 설정은 HAProxy의 Prometheus 엔드포인트를 스크랩하고, 관련 메트릭으로 필터링하며, haproxyreceiver 속성 체계(haproxy.proxy_name, haproxy.service_name)와 일치하도록 레이블을 변환하고, 메트릭의 이름을 OTel haproxy.* 명명 규칙으로 바꿉니다.
이 설정은 NRDOT 및 OTel Collector Contrib 모두에서 작동합니다. 적절한 설정 위치에 배치하십시오:
NRDOT:
/etc/nrdot-collector/config.yamlOTel Collector Contrib:
/etc/otelcol-contrib/config.yaml중요
편집하기 전에: 기존 설정을 백업하세요.
bash$# NRDOT$sudo cp /etc/nrdot-collector/config.yaml /etc/nrdot-collector/config.yaml.backup$# OTel Collector Contrib$sudo cp /etc/otelcol-contrib/config.yaml /etc/otelcol-contrib/config.yaml.backup수집기 설정 파일의 내용을 다음으로 교체하십시오:
receivers:prometheus/haproxy_transform:config:scrape_configs:- job_name: haproxy_transformscrape_interval: 30sstatic_configs:- targets: ["localhost:8404"]metrics_path: /metricsprocessors:# Filter to keep only the metrics we need to transformfilter/haproxy:metrics:include:match_type: regexpmetric_names:- "haproxy_frontend_bytes_in_total"- "haproxy_frontend_bytes_out_total"- "haproxy_frontend_requests_denied_total"- "haproxy_frontend_request_errors_total"- "haproxy_frontend_responses_denied_total"- "haproxy_frontend_http_requests_total"- "haproxy_frontend_connections_rate_max"- "haproxy_frontend_http_requests_rate_max"- "haproxy_frontend_current_sessions"- "haproxy_frontend_max_session_rate"- "haproxy_backend_bytes_in_total"- "haproxy_backend_bytes_out_total"- "haproxy_backend_connection_errors_total"- "haproxy_backend_retry_warnings_total"- "haproxy_backend_requests_denied_total"- "haproxy_backend_responses_denied_total"- "haproxy_backend_redispatch_warnings_total"- "haproxy_backend_http_requests_total"- "haproxy_backend_response_errors_total"- "haproxy_backend_loadbalanced_total"- "haproxy_backend_current_queue"- "haproxy_backend_total_time_average_seconds"- "haproxy_backend_current_sessions"- "haproxy_backend_max_session_rate"- "haproxy_server_bytes_in_total"- "haproxy_server_bytes_out_total"- "haproxy_server_connection_errors_total"- "haproxy_server_retry_warnings_total"- "haproxy_server_responses_denied_total"- "haproxy_server_redispatch_warnings_total"- "haproxy_server_response_errors_total"- "haproxy_server_loadbalanced_total"- "haproxy_server_current_queue"- "haproxy_server_total_time_average_seconds"- "haproxy_server_current_sessions"- "haproxy_server_max_session_rate"# Add haproxy.service_name and haproxy.proxy_name attributes using OTTLtransform/add_labels:metric_statements:- context: datapointstatements:# Frontend metrics: haproxy.service_name = "FRONTEND"- set(attributes["haproxy.service_name"], "FRONTEND") where metric.name == "haproxy_frontend_bytes_in_total"- set(attributes["haproxy.service_name"], "FRONTEND") where metric.name == "haproxy_frontend_bytes_out_total"- set(attributes["haproxy.service_name"], "FRONTEND") where metric.name == "haproxy_frontend_requests_denied_total"- set(attributes["haproxy.service_name"], "FRONTEND") where metric.name == "haproxy_frontend_request_errors_total"- set(attributes["haproxy.service_name"], "FRONTEND") where metric.name == "haproxy_frontend_responses_denied_total"- set(attributes["haproxy.service_name"], "FRONTEND") where metric.name == "haproxy_frontend_http_requests_total"- set(attributes["haproxy.service_name"], "FRONTEND") where metric.name == "haproxy_frontend_connections_rate_max"- set(attributes["haproxy.service_name"], "FRONTEND") where metric.name == "haproxy_frontend_http_requests_rate_max"- set(attributes["haproxy.service_name"], "FRONTEND") where metric.name == "haproxy_frontend_current_sessions"- set(attributes["haproxy.service_name"], "FRONTEND") where metric.name == "haproxy_frontend_max_session_rate"# Backend metrics: haproxy.service_name = "BACKEND"- set(attributes["haproxy.service_name"], "BACKEND") where metric.name == "haproxy_backend_bytes_in_total"- set(attributes["haproxy.service_name"], "BACKEND") where metric.name == "haproxy_backend_bytes_out_total"- set(attributes["haproxy.service_name"], "BACKEND") where metric.name == "haproxy_backend_connection_errors_total"- set(attributes["haproxy.service_name"], "BACKEND") where metric.name == "haproxy_backend_retry_warnings_total"- set(attributes["haproxy.service_name"], "BACKEND") where metric.name == "haproxy_backend_requests_denied_total"- set(attributes["haproxy.service_name"], "BACKEND") where metric.name == "haproxy_backend_responses_denied_total"- set(attributes["haproxy.service_name"], "BACKEND") where metric.name == "haproxy_backend_redispatch_warnings_total"- set(attributes["haproxy.service_name"], "BACKEND") where metric.name == "haproxy_backend_http_requests_total"- set(attributes["haproxy.service_name"], "BACKEND") where metric.name == "haproxy_backend_response_errors_total"- set(attributes["haproxy.service_name"], "BACKEND") where metric.name == "haproxy_backend_loadbalanced_total"- set(attributes["haproxy.service_name"], "BACKEND") where metric.name == "haproxy_backend_current_queue"- set(attributes["haproxy.service_name"], "BACKEND") where metric.name == "haproxy_backend_total_time_average_seconds"- set(attributes["haproxy.service_name"], "BACKEND") where metric.name == "haproxy_backend_current_sessions"- set(attributes["haproxy.service_name"], "BACKEND") where metric.name == "haproxy_backend_max_session_rate"# Server metrics: haproxy.service_name = server label value- set(attributes["haproxy.service_name"], attributes["server"]) where metric.name == "haproxy_server_bytes_in_total"- set(attributes["haproxy.service_name"], attributes["server"]) where metric.name == "haproxy_server_bytes_out_total"- set(attributes["haproxy.service_name"], attributes["server"]) where metric.name == "haproxy_server_connection_errors_total"- set(attributes["haproxy.service_name"], attributes["server"]) where metric.name == "haproxy_server_retry_warnings_total"- set(attributes["haproxy.service_name"], attributes["server"]) where metric.name == "haproxy_server_responses_denied_total"- set(attributes["haproxy.service_name"], attributes["server"]) where metric.name == "haproxy_server_redispatch_warnings_total"- set(attributes["haproxy.service_name"], attributes["server"]) where metric.name == "haproxy_server_response_errors_total"- set(attributes["haproxy.service_name"], attributes["server"]) where metric.name == "haproxy_server_loadbalanced_total"- set(attributes["haproxy.service_name"], attributes["server"]) where metric.name == "haproxy_server_current_queue"- set(attributes["haproxy.service_name"], attributes["server"]) where metric.name == "haproxy_server_total_time_average_seconds"- set(attributes["haproxy.service_name"], attributes["server"]) where metric.name == "haproxy_server_current_sessions"- set(attributes["haproxy.service_name"], attributes["server"]) where metric.name == "haproxy_server_max_session_rate"# Rename proxy label to haproxy.proxy_name for ALL metrics- set(attributes["haproxy.proxy_name"], attributes["proxy"]) where attributes["proxy"] != nil# Remove old Prometheus labels- delete_key(attributes, "proxy") where attributes["proxy"] != nil- delete_key(attributes, "server") where attributes["server"] != nil# Rename metrics to match haproxyreceiver naming conventionmetricstransform/rename:transforms:# haproxy.bytes.input- include: haproxy_frontend_bytes_in_totalaction: updatenew_name: haproxy.bytes.input- include: haproxy_backend_bytes_in_totalaction: updatenew_name: haproxy.bytes.input- include: haproxy_server_bytes_in_totalaction: updatenew_name: haproxy.bytes.input# haproxy.bytes.output- include: haproxy_frontend_bytes_out_totalaction: updatenew_name: haproxy.bytes.output- include: haproxy_backend_bytes_out_totalaction: updatenew_name: haproxy.bytes.output- include: haproxy_server_bytes_out_totalaction: updatenew_name: haproxy.bytes.output# haproxy.connections.errors- include: haproxy_backend_connection_errors_totalaction: updatenew_name: haproxy.connections.errors- include: haproxy_server_connection_errors_totalaction: updatenew_name: haproxy.connections.errors# haproxy.connections.retries- include: haproxy_backend_retry_warnings_totalaction: updatenew_name: haproxy.connections.retries- include: haproxy_server_retry_warnings_totalaction: updatenew_name: haproxy.connections.retries# haproxy.requests.denied- include: haproxy_frontend_requests_denied_totalaction: updatenew_name: haproxy.requests.denied- include: haproxy_backend_requests_denied_totalaction: updatenew_name: haproxy.requests.denied# haproxy.requests.errors- include: haproxy_frontend_request_errors_totalaction: updatenew_name: haproxy.requests.errors# haproxy.requests.redispatched- include: haproxy_backend_redispatch_warnings_totalaction: updatenew_name: haproxy.requests.redispatched- include: haproxy_server_redispatch_warnings_totalaction: updatenew_name: haproxy.requests.redispatched# haproxy.requests.total- include: haproxy_frontend_http_requests_totalaction: updatenew_name: haproxy.requests.total- include: haproxy_backend_http_requests_totalaction: updatenew_name: haproxy.requests.total# haproxy.responses.denied- include: haproxy_frontend_responses_denied_totalaction: updatenew_name: haproxy.responses.denied- include: haproxy_backend_responses_denied_totalaction: updatenew_name: haproxy.responses.denied- include: haproxy_server_responses_denied_totalaction: updatenew_name: haproxy.responses.denied# haproxy.responses.errors- include: haproxy_backend_response_errors_totalaction: updatenew_name: haproxy.responses.errors- include: haproxy_server_response_errors_totalaction: updatenew_name: haproxy.responses.errors# haproxy.server_selected.total- include: haproxy_backend_loadbalanced_totalaction: updatenew_name: haproxy.server_selected.total- include: haproxy_server_loadbalanced_totalaction: updatenew_name: haproxy.server_selected.total# haproxy.connections.rate- include: haproxy_frontend_connections_rate_maxaction: updatenew_name: haproxy.connections.rate# haproxy.requests.queued- include: haproxy_backend_current_queueaction: updatenew_name: haproxy.requests.queued- include: haproxy_server_current_queueaction: updatenew_name: haproxy.requests.queued# haproxy.requests.rate- include: haproxy_frontend_http_requests_rate_maxaction: updatenew_name: haproxy.requests.rate# haproxy.sessions.average- include: haproxy_backend_total_time_average_secondsaction: updatenew_name: haproxy.sessions.average- include: haproxy_server_total_time_average_secondsaction: updatenew_name: haproxy.sessions.average# haproxy.sessions.count- include: haproxy_frontend_current_sessionsaction: updatenew_name: haproxy.sessions.count- include: haproxy_backend_current_sessionsaction: updatenew_name: haproxy.sessions.count- include: haproxy_server_current_sessionsaction: updatenew_name: haproxy.sessions.count# haproxy.sessions.rate- include: haproxy_frontend_max_session_rateaction: updatenew_name: haproxy.sessions.rate- include: haproxy_backend_max_session_rateaction: updatenew_name: haproxy.sessions.rate- include: haproxy_server_max_session_rateaction: updatenew_name: haproxy.sessions.rate# Add resource attributes and strip Prometheus auto-labelsresource/haproxy_transform:attributes:- key: haproxy.addrvalue: "http://localhost:8404/stats"action: upsert- key: service.nameaction: delete- key: service.instance.idaction: delete- key: net.host.nameaction: delete- key: net.host.portaction: delete- key: server.portaction: delete- key: url.schemeaction: deleteresourcedetection:detectors: [system]system:resource_attributes:host.name:enabled: truehost.id:enabled: trueos.type:enabled: truetransform/metadata_nullify:metric_statements:- context: metricstatements:- set(description, "")- set(unit, "")batch:exporters:otlphttp:endpoint: ${env:OTEL_EXPORTER_OTLP_ENDPOINT}headers:api-key: ${env:NEW_RELIC_LICENSE_KEY}service:pipelines:metrics/haproxy_transform:receivers:- prometheus/haproxy_transformprocessors:- filter/haproxy- transform/add_labels- metricstransform/rename- resourcedetection- resource/haproxy_transform- transform/metadata_nullify- batchexporters:- otlphttp중요
이 설정은 세 가지 주요 변환을 수행합니다.
- 17개의 OTel 기본 메트릭(프런트엔드/백앤드/서버 티어 전체)에 해당하는 36개의 Prometheus 메트릭으로만 필터링 합니다.
- haproxyreceiver의 속성 체계와 일치하는 차원 속성 (
haproxy.proxy_name,haproxy.service_name)을 추가합니다. - 일관된 대시보드 및 알림을 위해 Prometheus 명명(
haproxy_frontend_*)에서 OTel 명명(haproxy.*)으로 메트릭의 이름을 변경합니다.
구성 매개변수
매개변수
설명
targetsHAProxy Prometheus 엔드포인트 주소(기본값
localhost:8404)
haproxy.addr값
HAProxy 통계 엔드포인트 URL로 교체하십시오.
scrape_intervalPrometheus 엔드포인트를 스크랩하는 빈도입니다. 기본:
30s
뉴렐릭 자격 증명을 사용하여 systemd 재정의 파일을 생성하십시오:
$sudo mkdir -p /etc/systemd/system/<collector-service>.service.d$cat <<EOF | sudo tee /etc/systemd/system/<collector-service>.service.d/environment.conf$[Service]$Environment="NEW_RELIC_LICENSE_KEY=<YOUR_LICENSE_KEY>"$Environment="OTEL_EXPORTER_OTLP_ENDPOINT=<YOUR_NEWRELIC_OTLP_ENDPOINT>"$EOF<YOUR_LICENSE_KEY>을(를) (으)로, <collector-service>을(를) 수집기 서비스 이름(예: otelcol-contrib 또는 nrdot-collector)(으)로 바꾸십시오.
$sudo systemctl daemon-reload$sudo systemctl restart <collector-service>서비스 상태 및 로그를 확인하십시오:
$sudo systemctl status <collector-service>$sudo journalctl -u <collector-service> -n 20오류 없이 Active: active (running)이(가) 표시되어야 합니다.
몇 분 후, 쿼리 빌더에서 이 NRQL 쿼리를 실행하십시오:
FROM Metric SELECT *WHERE metricName LIKE 'haproxy.%'SINCE 10 minutes agoNew Relic에서 데이터 보기
데이터가 흐르기 시작하면 뉴렐릭에서 HAProxy 메트릭을 찾습니다:
- one.newrelic.com > All capabilities > All entities 으)로 이동합니다.
- 이름으로 HAProxy 엔티티를 검색하거나 엔티티 유형
HAPROXYINSTANCE(으)로 필터링합니다. - 엔티티를 선택하여 골든 메트릭(초당 세션 수, 초당 requests 수, 연결 오류)이 포함된 요약 페이지를 확인하세요.
데이터를 탐색하는 더 많은 방법은 HAProxy 데이터 찾기 및 쿼리를 참조하십시오.
문제점 해결
설치 중에 문제가 발생하면 이 문제 진단 및 해결 가이드를 사용하여 일반적인 문제를 진단하고 해결하십시오.
stats 프런트엔드가 haproxy.cfg에 구성되어 있는지 확인하십시오:
$sudo haproxy -c -f /etc/haproxy/haproxy.cfg$grep -A 4 "frontend stats" /etc/haproxy/haproxy.cfg해결책:
bind포트(기본값 8404)가 다른 프로세스에서 사용되지 않는지 확인하십시오:sudo ss -tlnp | grep 8404- HAProxy가 실행 중인지 확인하십시오.
sudo systemctl status haproxy - 변경 후 설정을 다시 로드하십시오:
sudo systemctl reload haproxy
설정 오류가 있는지 수집기 로그를 확인하십시오:
$sudo journalctl -u otelcol-contrib -n 100 --no-pager$# or for NRDOT:$sudo journalctl -u nrdot-collector -n 100 --no-pager일반적인 원인:
- 설정 파일의 YAML 구문이 잘못되었습니다.
- 누락된 환경 변수(
NEW_RELIC_LICENSE_KEY,OTEL_EXPORTER_OTLP_ENDPOINT) - 수집기의 텔레메트리 포트 충돌
- 초기 데이터 수집을 위해 2~3분 정도 기다려 주십시오
- 수집기가 실행 중인지 확인하십시오.
sudo systemctl status otelcol-contrib - 수집기 호스트에서 stats 엔드포인트에 연결할 수 있는지 확인하십시오:
curl -s http://localhost:8404/stats - 라이선스 키가 올바르고 OTLP 엔드포인트가 올바르게 설정되었는지 확인하십시오. 자세한 내용은 뉴렐릭 OTLP 엔드포인트를 참조하십시오.
- 모든 HAProxy 메트릭 쿼리:FROM Metric SELECT count(*) WHERE metricName LIKE 'haproxy.%' SINCE 30 minutes ago
수집기 로그에 401 Unauthorized 또는 403 Forbidden이(가) 표시되는 경우:
- 라이선스 키를 확인하십시오: 사용자 키가 아닌 수집 (INGEST-LICENSE) 라이선스 키인지 확인하십시오.
- 엔드포인트가 올바르게 설정되었는지 확인하십시오. 자세한 내용은 뉴렐릭 OTLP 엔드포인트를 참조하십시오.
- 환경 변수가 올바르게 설정되었는지 확인하십시오:
echo $NEW_RELIC_LICENSE_KEY
HAProxy의 내장 Prometheus 익스포터(promex)는 버전 2.0 이상이 필요합니다.
HAProxy 버전을 확인하십시오:
$haproxy -v2.0 이전 버전을 실행 중인 경우 CSV 통계 엔드포인트를 사용하고 통계를 지원하는 모든 HAProxy 버전에서 작동하는 haproxyreceiver와 함께 OTel Collector Contrib 탭을 대신 사용하십시오.
HAProxy 2.0~2.3을 실행 중인 경우, stats 프런트엔드 설정에 option http-use-htx이(가) 있는지 확인하십시오. 이 옵션은 HAProxy 2.4+에서 기본값이 되었으며 최신 버전에서는 필요하지 않습니다.
다음 단계
- Kubernetes에서 HAProxy 모니터 — 컨테이너화된 환경을 위한 자동 파드 검색
- HAProxy 데이터 찾기 및 쿼리 ― 대시보드, NRQL 쿼리 및 데이터 탐색
- HAProxy OTel 메트릭 참조 — 수집된 메트릭의 전체 목록
- OpenTelemetry 모범 사례 — 뉴렐릭과 함께 사용하는 OTel에 대한 일반적인 지침