이 Kubernetes 통합은 클러스터의 HAProxy 파드를 자동으로 검색하고 각 인스턴스에 대한 수동 설정 없이 메트릭을 수집합니다. 이것은 OpenTelemetry haproxyreceiver 및 receivercreator 를 사용하여 컨테이너화된 환경 전체에서 HAProxy 세션, requests, 오류 및 백앤드 서버 상태를 동적으로 모니터합니다.
팁
Linux 호스트에서 HAProxy를 실행 중이신가요? 가상 머신 또는 베어메탈 배포를 위한 자체 호스팅 설치 가이드 를 참조하세요.
시작하기 전에
다음 사항을 확인하십시오:
- 유효한 뉴렐릭 클러스터
- stats 엔드포인트가 활성화된 HAProxy 파드(일반적으로 8404 포트)
- 검색을 위한 각 HAProxy 파드의 레이블(예:
app: haproxy) - Helm 설치 방법을 사용하는 경우 기본 Kubernetes OpenTelemetry Helm 설치를 완료하세요.
HAProxy 모니터링 설정
values.yaml의deployment.extraConfig아래에 다음 섹션을 추가합니다:중요
deployment.extraConfig에서pipelines:은(는)service:아래에 중첩되지 않고 루트 수준에서 정의되어야 합니다. Helm 차트 템플릿은extraConfig.pipelines을(를)service.pipelines에,extraConfig.service.extensions을(를)service.extensions에 매핑합니다.확장:
extensions:k8s_observer:auth_type: serviceAccountobserve_pods: trueobserve_nodes: false환경 변수(
deployment.envs아래에 추가):deployment:envs:- name: OTEL_RESOURCE_ATTRIBUTESvalue: "host.id=$(KUBE_NODE_NAME)"중요
엔티티 합성을 위해
host.id리소스 속성이 필요합니다. 컨테이너 이미지에는/etc/machine-id이(가) 없으므로OTEL_RESOURCE_ATTRIBUTES을(를) 통해 주입해야 합니다. Helm 차트는 이미 Kubernetes Downward API에서KUBE_NODE_NAME을(를) 설정합니다.수신기:
receivers:receiver_creator/haproxy:watch_observers: [k8s_observer]receivers:haproxy:rule: type == "pod" && labels["app"] == "haproxy"config:endpoint: 'http://`endpoint`:8404/stats'collection_interval: 30s프로세서:
processors:resource/cluster:attributes:- key: k8s.cluster.namevalue: "<YOUR_CLUSTER_NAME>"action: inserttransform/haproxy:metric_statements:- context: resourcestatements:- set(attributes["haproxy.display.name"], Concat(["server","k8s",attributes["k8s.cluster.name"],attributes["k8s.namespace.name"],"pod",attributes["k8s.pod.name"],"haproxy","8404"], ":"))transform/metadata_nullify:metric_statements:- context: metricstatements:- set(description, "")- set(unit, "")서비스 확장:
service:extensions: [k8s_observer]파이프라인:
pipelines:metrics/haproxy:receivers: [receiver_creator/haproxy]processors: [batch, resource/cluster, transform/haproxy, transform/metadata_nullify, memory_limiter]exporters: [otlphttp/newrelic]구성 매개변수
다음 표에서는 주요 설정 시위에 대해 설명합니다.
매개변수
설명
labels["app"] == "haproxy"HAProxy 파드를 검색하는 데 사용되는 파드 레이블 선택기입니다. 파드 레이블과 일치하도록 규칙을 업데이트하세요.
<YOUR_PORT_NUMBER>HAProxy가 통계 엔드포인트를 노출하는 포트입니다.
<YOUR_CLUSTER_NAME>뉴렐릭에서 식별할 수 있도록 쿠버네티스 클러스터 이름으로 바꾸세요.
collection_interval메트릭을 수집하는 빈도입니다. 기본값은
30s입니다.
실행 중인 Helm 릴리스에 업데이트된 값을 적용합니다:
bash$helm upgrade nr-k8s-otel-collector newrelic/nr-k8s-otel-collector \>--namespace newrelic \>--reuse-values \>-f values.yaml
기본 Kubernetes OpenTelemetry 매니페스트 설치를 완료한 후 HAProxy 모니터링을 구성하세요:
NRDOT 수집기를 사용하도록 수집기 이미지를 업데이트하세요.
로컬
rendered디렉터리에 있는deployment.yaml파일에서 이미지를 다음으로 업데이트하세요:image: newrelic/nrdot-collector:latest배포 사양에 다음을 추가하여 호스트의
/etc/machine-id을(를) 수집기 컨테이너에 마운트합니다:volumeMounts:- name: machine-idmountPath: /etc/machine-idreadOnly: truevolumes:- name: machine-idhostPath:path: /etc/machine-idtype: File중요
엔티티 합성을 위해
host.id리소스 속성이 필요합니다.resourcedetection프로세서는/etc/machine-id을(를) 읽어 이를 채웁니다. 이 볼륨 마운트가 없으면host.id이(가) 설정되지 않고 엔티티가 생성되지 않습니다.deployment-configmap.yaml의deployment-config.yaml: |아래에 있는 내용을 다음으로 바꿉니다:extensions:health_check:endpoint: 0.0.0.0:13133k8s_observer:auth_type: serviceAccountobserve_pods: trueobserve_nodes: falsereceivers:receiver_creator/haproxy:watch_observers: [k8s_observer]receivers:haproxy:rule: type == "pod" && labels["app"] == "haproxy"config:endpoint: 'http://`endpoint`:8404/stats'collection_interval: 30sprocessors:resourcedetection:detectors: [env, system]system:resource_attributes:host.name:enabled: truehost.id:enabled: trueos.type:enabled: truebatch:send_batch_max_size: 1000timeout: 30ssend_batch_size: 800memory_limiter:check_interval: 1slimit_percentage: 80spike_limit_percentage: 25resource/cluster:attributes:- key: k8s.cluster.namevalue: "<YOUR_CLUSTER_NAME>"action: inserttransform/haproxy:metric_statements:- context: resourcestatements:- set(attributes["haproxy.display.name"], Concat(["server","k8s",attributes["k8s.cluster.name"],attributes["k8s.namespace.name"],"pod",attributes["k8s.pod.name"],"haproxy","8404"], ":"))transform/metadata_nullify:metric_statements:- context: metricstatements:- set(description, "")- set(unit, "")exporters:otlp_http/newrelic:endpoint: "<YOUR_NEWRELIC_OTLP_ENDPOINT>"headers:api-key: ${env:NR_LICENSE_KEY}service:extensions: [health_check, k8s_observer]pipelines:metrics/haproxy:receivers: [receiver_creator/haproxy]processors: [resourcedetection, batch, resource/cluster, transform/haproxy, transform/metadata_nullify, memory_limiter]exporters: [otlp_http/newrelic]DaemonSet 및 kube-state-metrics 배포를 삭제합니다(HAProxy 전용 모니터링에는 필요하지 않음):
bash$kubectl delete daemonset nr-k8s-otel-collector-daemonset -n newrelic$kubectl delete deployment nr-k8s-otel-collector-kube-state-metrics -n newrelic변경 사항을 적용하려면 수집기 배포를 다시 시작합니다:
bash$kubectl rollout restart deployment nr-k8s-otel-collector-deployment -n newrelic구성 매개변수
매개변수
설명
labels["app"] == "haproxy"HAProxy 파드를 검색하는 데 사용되는 파드 레이블 선택기입니다. 파드 레이블과 일치하도록 규칙을 업데이트하세요.
<YOUR_PORT_NUMBER>HAProxy가 통계 엔드포인트를 노출하는 포트입니다.
<YOUR_CLUSTER_NAME>뉴렐릭에서 식별할 수 있도록 쿠버네티스 클러스터 이름으로 바꾸세요.
<YOUR_NEWRELIC_OTLP_ENDPOINT>귀하의 뉴렐릭 OTLP 엔드포인트. 미국은
https://otlp.nr-data.net을(를) 사용하고, EU는
https://otlp.eu01.nr-data.net을(를) 사용합니다.
쿠버네티스 클러스터에 OpenTelemetry Collector Contrib를 배포합니다. 수집기는 HAProxy 파드에서 메트릭을 자동으로 검색하고 스크랩합니다. Helm(업스트림 OTel Helm 차트 사용) 또는 원시 Kubernetes 매니페스트 중에서 선택합니다.
다음 HAProxy 모니터링 설정으로
values.yaml파일을 만듭니다:mode: deploymentimage:repository: otel/opentelemetry-collector-contribclusterRole:create: truerules:- apiGroups: [""]resources: ["pods", "nodes"]verbs: ["get", "list", "watch"]- apiGroups: ["apps"]resources: ["replicasets"]verbs: ["get", "list", "watch"]extraVolumes:- name: machine-idhostPath:path: /etc/machine-idtype: FileextraVolumeMounts:- name: machine-idmountPath: /etc/machine-idreadOnly: trueconfig:extensions:health_check:endpoint: ${env:MY_POD_IP}:13133k8s_observer:auth_type: serviceAccountobserve_pods: trueobserve_nodes: falsereceivers:receiver_creator/haproxy:watch_observers: [k8s_observer]receivers:haproxy:rule: type == "pod" && labels["app"] == "haproxy"config:endpoint: 'http://`endpoint`:8404/stats'collection_interval: 30sprocessors:resourcedetection:detectors: [env, system]system:resource_attributes:host.name:enabled: truehost.id:enabled: trueos.type:enabled: truebatch:send_batch_size: 1024timeout: 30smemory_limiter:check_interval: 1slimit_percentage: 80spike_limit_percentage: 25resource/cluster:attributes:- key: k8s.cluster.namevalue: "<YOUR_CLUSTER_NAME>"action: inserttransform/haproxy:metric_statements:- context: resourcestatements:- set(attributes["haproxy.display.name"], Concat(["server", "k8s", attributes["k8s.cluster.name"], attributes["k8s.namespace.name"], "pod", attributes["k8s.pod.name"], "haproxy", "8404"], ":"))transform/metadata_nullify:metric_statements:- context: metricstatements:- set(description, "")- set(unit, "")exporters:otlp_http/newrelic:endpoint: "<YOUR_NEWRELIC_OTLP_ENDPOINT>"headers:api-key: "<YOUR_NEW_RELIC_LICENSE_KEY>"service:extensions: [health_check, k8s_observer]pipelines:metrics/haproxy:receivers: [receiver_creator/haproxy]processors: [resourcedetection, batch, resource/cluster, transform/haproxy, transform/metadata_nullify, memory_limiter]exporters: [otlp_http/newrelic]구성 매개변수
매개변수
설명
labels["app"] == "haproxy"HAProxy 파드를 검색하는 데 사용되는 파드 레이블 선택기입니다. 파드 레이블과 일치하도록 규칙을 업데이트하세요.
<YOUR_PORT_NUMBER>HAProxy가 통계 엔드포인트를 노출하는 포트입니다.
<YOUR_CLUSTER_NAME>뉴렐릭에서 식별할 수 있도록 쿠버네티스 클러스터 이름으로 바꾸세요.
<YOUR_NEWRELIC_OTLP_ENDPOINT>귀하의 뉴렐릭 OTLP 엔드포인트. 미국은
https://otlp.nr-data.net을(를) 사용하고, EU는
https://otlp.eu01.nr-data.net을(를) 사용합니다.
<YOUR_NEW_RELIC_LICENSE_KEY>귀하의 뉴렐릭 수집 라이선스 키.
업스트림 OpenTelemetry Helm 차트를 사용하여 설치합니다:
bash$helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts$helm repo update$helm upgrade --install haproxy-otel-collector open-telemetry/opentelemetry-collector \>-f values.yaml \>-n newrelic --create-namespace
Helm을 사용할 수 없거나 kubectl을(를) 사용하여 Kubernetes 리소스를 직접 관리하려는 경우 이 옵션을 사용합니다.
뉴렐릭 라이선스 키로 시크릿을 만듭니다:
bash$kubectl create namespace newrelic$kubectl create secret generic otel-collector-haproxy-secret \>--namespace newrelic \>--from-literal=licenseKey='<YOUR_NEW_RELIC_LICENSE_KEY>'다음 매니페스트를 파일(예:
otel-collector-haproxy.yaml)에 저장합니다:---apiVersion: v1kind: ServiceAccountmetadata:name: otel-collector-haproxynamespace: newreliclabels:app: otel-collector-haproxy---apiVersion: rbac.authorization.k8s.io/v1kind: ClusterRolemetadata:name: otel-collector-haproxylabels:app: otel-collector-haproxyrules:- apiGroups: [""]resources: ["pods", "nodes"]verbs: ["get", "list", "watch"]- apiGroups: ["apps"]resources: ["replicasets"]verbs: ["get", "list", "watch"]---apiVersion: rbac.authorization.k8s.io/v1kind: ClusterRoleBindingmetadata:name: otel-collector-haproxylabels:app: otel-collector-haproxyroleRef:apiGroup: rbac.authorization.k8s.iokind: ClusterRolename: otel-collector-haproxysubjects:- kind: ServiceAccountname: otel-collector-haproxynamespace: newrelic---apiVersion: v1kind: ConfigMapmetadata:name: otel-collector-haproxy-confignamespace: newreliclabels:app: otel-collector-haproxydata:collector-config.yaml: |extensions:health_check:endpoint: 0.0.0.0:13133k8s_observer:auth_type: serviceAccountobserve_pods: trueobserve_nodes: falsereceivers:receiver_creator/haproxy:watch_observers: [k8s_observer]receivers:haproxy:rule: type == "pod" && labels["app"] == "haproxy"config:endpoint: 'http://`endpoint`:8404/stats'collection_interval: 30sprocessors:resourcedetection:detectors: [env, system]system:resource_attributes:host.name:enabled: truehost.id:enabled: trueos.type:enabled: truebatch:send_batch_size: 1024timeout: 30smemory_limiter:check_interval: 1slimit_percentage: 80spike_limit_percentage: 25resource/cluster:attributes:- key: k8s.cluster.namevalue: "<YOUR_CLUSTER_NAME>"action: inserttransform/haproxy:metric_statements:- context: resourcestatements:- set(attributes["haproxy.display.name"], Concat(["server", "k8s", attributes["k8s.cluster.name"], attributes["k8s.namespace.name"], "pod", attributes["k8s.pod.name"], "haproxy", "8404"], ":"))transform/metadata_nullify:metric_statements:- context: metricstatements:- set(description, "")- set(unit, "")exporters:otlp_http/newrelic:endpoint: "<YOUR_NEWRELIC_OTLP_ENDPOINT>"headers:api-key: ${env:NR_LICENSE_KEY}service:extensions: [health_check, k8s_observer]pipelines:metrics/haproxy:receivers: [receiver_creator/haproxy]processors: [resourcedetection, batch, resource/cluster, transform/haproxy, transform/metadata_nullify, memory_limiter]exporters: [otlp_http/newrelic]---apiVersion: apps/v1kind: Deploymentmetadata:name: otel-collector-haproxynamespace: newreliclabels:app: otel-collector-haproxyspec:replicas: 1selector:matchLabels:app: otel-collector-haproxytemplate:metadata:labels:app: otel-collector-haproxyspec:serviceAccountName: otel-collector-haproxycontainers:- name: otel-collectorimage: otel/opentelemetry-collector-contrib:latestcommand:- "/otelcol-contrib"- "--config=/conf/collector-config.yaml"env:- name: NR_LICENSE_KEYvalueFrom:secretKeyRef:name: otel-collector-haproxy-secretkey: licenseKey- name: GOGCvalue: "80"ports:- name: healthcontainerPort: 13133protocol: TCPresources:limits:cpu: 500mmemory: 512Mirequests:cpu: 100mmemory: 256MivolumeMounts:- name: configmountPath: /conf- name: machine-idmountPath: /etc/machine-idreadOnly: truevolumes:- name: configconfigMap:name: otel-collector-haproxy-configitems:- key: collector-config.yamlpath: collector-config.yaml- name: machine-idhostPath:path: /etc/machine-idtype: File중요
엔티티 합성을 위해
/etc/machine-id볼륨 마운트가 필요합니다.resourcedetection프로세서는 이 파일을 읽어host.id리소스 속성을 채웁니다. 이것이 없으면 뉴렐릭에 엔티티가 생성되지 않습니다.매니페스트를 적용합니다:
bash$kubectl apply -f otel-collector-haproxy.yaml수집기가 실행 중이고 HAProxy 파드를 검색하는지 확인합니다:
bash$kubectl get pods -n newrelic -l app=otel-collector-haproxy$kubectl logs -n newrelic -l app=otel-collector-haproxyHAProxy 파드 IP와 함께
starting receiver을(를) 보여주는 로그 라인이 표시되어야 합니다.구성 매개변수
매개변수
설명
labels["app"] == "haproxy"HAProxy 파드를 검색하는 데 사용되는 파드 레이블 선택기입니다. 파드 레이블과 일치하도록 규칙을 업데이트하세요.
<YOUR_PORT_NUMBER>HAProxy가 통계 엔드포인트를 노출하는 포트입니다.
<YOUR_CLUSTER_NAME>뉴렐릭에서 식별할 수 있도록 쿠버네티스 클러스터 이름으로 바꾸세요.
<YOUR_NEWRELIC_OTLP_ENDPOINT>귀하의 뉴렐릭 OTLP 엔드포인트. 미국은
https://otlp.nr-data.net을(를) 사용하고, EU는
https://otlp.eu01.nr-data.net을(를) 사용합니다.
<YOUR_NEW_RELIC_LICENSE_KEY>귀하의 뉴렐릭 수집 라이선스 키.
HAProxy 파드가 이미 Prometheus /metrics 엔드포인트(HAProxy 2.0+)를 노출하고 있고 CSV 통계 엔드포인트에 연결하는 것보다 Prometheus 메트릭을 스크랩하는 것을 선호하는 경우 이 접근 방식을 사용합니다.
팁
Prometheus 엔드포인트가 아직 활성화되어 있지 않은 경우, 대신 NRDOT 수집기 또는 OpenTelemetry Collector Contrib 탭을 사용하세요. Prometheus 지원 없이 HAProxy 통계 엔드포인트에 직접 연결합니다.
중요
이 접근 방식은 내장된 Prometheus 엔드포인트가 활성화된 HAProxy 2.0+가 필요합니다. HAProxy 설정에는 다음이 포함되어야 합니다:
frontend stats bind *:8404 http-request use-service prometheus-exporter if { path /metrics }그리고 HAProxy 파드는 메트릭 엔드포인트를 위한 명명된 포트를 노출해야 합니다:
ports: - name: metrics containerPort: 8404계속하기 전에 nr-k8s-otel-collector 에 대한 기본 Kubernetes OpenTelemetry Helm 설치 를 완료하세요.
values.yaml의deployment.configMap.extraConfig아래에 다음 섹션을 추가합니다:중요
deployment.configMap.extraConfig에서pipelines:은(는)service:아래에 중첩되지 않고 루트 수준에서 정의되어야 합니다. Helm 차트 템플릿은extraConfig.pipelines을(를)service.pipelines에,extraConfig.service.extensions을(를)service.extensions에 매핑합니다.확장:
extensions:k8s_observer:auth_type: serviceAccountobserve_pods: trueobserve_nodes: false환경 변수(
deployment.envs아래에 추가):deployment:envs:- name: OTEL_RESOURCE_ATTRIBUTESvalue: "host.id=$(KUBE_NODE_NAME)"중요
엔티티 합성을 위해
host.id리소스 속성이 필요합니다.resourcedetection프로세서는OTEL_RESOURCE_ATTRIBUTES을(를) 읽어 이를 채웁니다. Helm 차트는 이미 Kubernetes Downward API에서KUBE_NODE_NAME을(를) 설정합니다.수신기:
receivers:receiver_creator/haproxy_prom:watch_observers: [k8s_observer]receivers:prometheus:rule: type == "port" && pod.labels["app"] == "haproxy" && port == 8404config:config:scrape_configs:- job_name: haproxy_prommetrics_path: /metricsscrape_interval: 30sstatic_configs:- targets:- '`endpoint`'resource_attributes:haproxy.addr: 'http://`endpoint`/metrics'프로세서:
processors:resourcedetection:detectors: [env]filter/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_http_requests_total"- "haproxy_frontend_current_sessions"- "haproxy_frontend_max_session_rate"- "haproxy_frontend_http_requests_rate_max"- "haproxy_frontend_connections_rate_max"- "haproxy_backend_bytes_in_total"- "haproxy_backend_bytes_out_total"- "haproxy_backend_connection_errors_total"- "haproxy_backend_http_requests_total"- "haproxy_backend_current_sessions"- "haproxy_backend_max_session_rate"- "haproxy_backend_current_queue"- "haproxy_server_bytes_in_total"- "haproxy_server_bytes_out_total"- "haproxy_server_connection_errors_total"- "haproxy_server_current_sessions"- "haproxy_server_max_session_rate"- "haproxy_server_current_queue"transform/add_labels:metric_statements:- context: datapointstatements:- set(attributes["haproxy.service_name"], "FRONTEND") where IsMatch(metric.name, "^haproxy_frontend_.*")- set(attributes["haproxy.service_name"], "BACKEND") where IsMatch(metric.name, "^haproxy_backend_.*")- set(attributes["haproxy.service_name"], attributes["server"]) where IsMatch(metric.name, "^haproxy_server_.*")- set(attributes["haproxy.proxy_name"], attributes["proxy"]) where attributes["proxy"] != nil- delete_key(attributes, "proxy") where attributes["proxy"] != nil- delete_key(attributes, "server") where attributes["server"] != nilmetricstransform/rename:transforms:- 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- 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- include: haproxy_backend_connection_errors_totalaction: updatenew_name: haproxy.connections.errors- include: haproxy_server_connection_errors_totalaction: updatenew_name: haproxy.connections.errors- include: haproxy_frontend_requests_denied_totalaction: updatenew_name: haproxy.requests.denied- include: haproxy_frontend_request_errors_totalaction: updatenew_name: haproxy.requests.errors- include: haproxy_frontend_http_requests_totalaction: updatenew_name: haproxy.requests.total- include: haproxy_backend_http_requests_totalaction: updatenew_name: haproxy.requests.total- include: haproxy_backend_current_queueaction: updatenew_name: haproxy.requests.queued- include: haproxy_server_current_queueaction: updatenew_name: haproxy.requests.queued- 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- include: haproxy_frontend_http_requests_rate_maxaction: updatenew_name: haproxy.requests.rate- include: haproxy_frontend_connections_rate_maxaction: updatenew_name: haproxy.connections.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.rateresource/cluster:attributes:- key: k8s.cluster.namevalue: "<YOUR_CLUSTER_NAME>"action: inserttransform/haproxy:metric_statements:- context: resourcestatements:- set(attributes["haproxy.display.name"], Concat(["server", "k8s", attributes["k8s.cluster.name"], attributes["k8s.namespace.name"], "pod", attributes["k8s.pod.name"], "haproxy", "8404"], ":"))transform/metadata_nullify:metric_statements:- context: metricstatements:- set(description, "")- set(unit, "")서비스 확장:
service:extensions: [k8s_observer]파이프라인:
pipelines:metrics/haproxy_prom:receivers: [receiver_creator/haproxy_prom]processors: [resourcedetection, filter/haproxy, transform/add_labels, metricstransform/rename, resource/cluster, batch, transform/haproxy, transform/metadata_nullify, memory_limiter]exporters: [otlp_http/newrelic]구성 매개변수
매개변수
설명
labels["app"] == "haproxy"HAProxy 파드를 검색하는 데 사용되는 파드 레이블 선택기입니다. 파드 레이블과 일치하도록 규칙을 업데이트하세요.
<YOUR_PORT_NUMBER>HAProxy가 Prometheus 엔드포인트를 노출하는 포트입니다.
<YOUR_CLUSTER_NAME>뉴렐릭에서 식별할 수 있도록 쿠버네티스 클러스터 이름으로 바꾸세요.
scrape_intervalPrometheus 메트릭을 스크랩하는 빈도입니다. 기본값:
30s.
실행 중인 Helm 릴리스에 업데이트된 값을 적용합니다:
bash$helm upgrade nr-k8s-otel-collector newrelic/nr-k8s-otel-collector \>--namespace newrelic \>--reuse-values \>-f values.yaml
Prometheus 수신자 설정이 포함된
values.yaml파일을 생성합니다:mode: deploymentimage:repository: otel/opentelemetry-collector-contribclusterRole:create: truerules:- apiGroups: [""]resources: ["pods", "nodes"]verbs: ["get", "list", "watch"]- apiGroups: ["apps"]resources: ["replicasets"]verbs: ["get", "list", "watch"]extraVolumes:- name: machine-idhostPath:path: /etc/machine-idtype: FileextraVolumeMounts:- name: machine-idmountPath: /etc/machine-idreadOnly: trueconfig:extensions:health_check:endpoint: ${env:MY_POD_IP}:13133k8s_observer:auth_type: serviceAccountobserve_pods: trueobserve_nodes: falsereceivers:receiver_creator/haproxy_prom:watch_observers: [k8s_observer]receivers:prometheus:rule: type == "port" && pod.labels["app"] == "haproxy" && port == 8404config:config:scrape_configs:- job_name: haproxy_prommetrics_path: /metricsscrape_interval: 30sstatic_configs:- targets:- '`endpoint`'resource_attributes:haproxy.addr: 'http://`endpoint`/metrics'processors:resourcedetection:detectors: [env, system]system:resource_attributes:host.name:enabled: truehost.id:enabled: trueos.type:enabled: truefilter/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_http_requests_total"- "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_http_requests_total"- "haproxy_backend_current_sessions"- "haproxy_backend_max_session_rate"- "haproxy_backend_current_queue"- "haproxy_server_bytes_in_total"- "haproxy_server_bytes_out_total"- "haproxy_server_connection_errors_total"- "haproxy_server_current_sessions"- "haproxy_server_max_session_rate"- "haproxy_server_current_queue"transform/add_labels:metric_statements:- context: datapointstatements:- set(attributes["haproxy.service_name"], "FRONTEND") where IsMatch(metric.name, "^haproxy_frontend_.*")- set(attributes["haproxy.service_name"], "BACKEND") where IsMatch(metric.name, "^haproxy_backend_.*")- set(attributes["haproxy.service_name"], attributes["server"]) where IsMatch(metric.name, "^haproxy_server_.*")- set(attributes["haproxy.proxy_name"], attributes["proxy"]) where attributes["proxy"] != nil- delete_key(attributes, "proxy") where attributes["proxy"] != nil- delete_key(attributes, "server") where attributes["server"] != nilmetricstransform/rename:transforms:- 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- 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- include: haproxy_backend_connection_errors_totalaction: updatenew_name: haproxy.connections.errors- include: haproxy_server_connection_errors_totalaction: updatenew_name: haproxy.connections.errors- include: haproxy_frontend_requests_denied_totalaction: updatenew_name: haproxy.requests.denied- include: haproxy_frontend_request_errors_totalaction: updatenew_name: haproxy.requests.errors- include: haproxy_frontend_http_requests_totalaction: updatenew_name: haproxy.requests.total- include: haproxy_backend_http_requests_totalaction: updatenew_name: haproxy.requests.total- include: haproxy_backend_current_queueaction: updatenew_name: haproxy.requests.queued- include: haproxy_server_current_queueaction: updatenew_name: haproxy.requests.queued- 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- 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.rateresource/cluster:attributes:- key: k8s.cluster.namevalue: "<YOUR_CLUSTER_NAME>"action: insertbatch:send_batch_size: 1024timeout: 30smemory_limiter:check_interval: 1slimit_percentage: 80spike_limit_percentage: 25transform/haproxy:metric_statements:- context: resourcestatements:- set(attributes["haproxy.display.name"], Concat(["server", "k8s", attributes["k8s.cluster.name"], attributes["k8s.namespace.name"], "pod", attributes["k8s.pod.name"], "haproxy", "8404"], ":"))transform/metadata_nullify:metric_statements:- context: metricstatements:- set(description, "")- set(unit, "")exporters:otlp_http/newrelic:endpoint: "<YOUR_NEWRELIC_OTLP_ENDPOINT>"headers:api-key: "<YOUR_NEW_RELIC_LICENSE_KEY>"service:extensions: [health_check, k8s_observer]pipelines:metrics/haproxy_prom:receivers: [receiver_creator/haproxy_prom]processors: [resourcedetection, filter/haproxy, transform/add_labels, metricstransform/rename, resource/cluster, batch, transform/haproxy, transform/metadata_nullify, memory_limiter]exporters: [otlp_http/newrelic]중요
엔티티 합성을 위해
/etc/machine-id볼륨 마운트가 필요합니다.resourcedetection프로세서는 이 파일을 읽어host.id리소스 속성을 채웁니다. 이것이 없으면 뉴렐릭에 엔티티가 생성되지 않습니다.구성 매개변수
매개변수
설명
labels["app"] == "haproxy"HAProxy 파드를 검색하는 데 사용되는 파드 레이블 선택기입니다. 파드 레이블과 일치하도록 규칙을 업데이트하세요.
<YOUR_PORT_NUMBER>HAProxy가 Prometheus 엔드포인트를 노출하는 포트입니다.
<YOUR_CLUSTER_NAME>뉴렐릭에서 식별할 수 있도록 쿠버네티스 클러스터 이름으로 바꾸세요.
<YOUR_NEWRELIC_OTLP_ENDPOINT>귀하의 뉴렐릭 OTLP 엔드포인트. 미국은
https://otlp.nr-data.net을(를) 사용하고, EU는
https://otlp.eu01.nr-data.net을(를) 사용합니다.
<YOUR_NEW_RELIC_LICENSE_KEY>귀하의 뉴렐릭 수집 라이선스 키.
scrape_intervalPrometheus 메트릭을 스크랩하는 빈도입니다. 기본값:
30s.
업스트림 OpenTelemetry Helm 차트를 사용하여 설치합니다:
bash$helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts$helm repo update$helm upgrade --install haproxy-prom-collector open-telemetry/opentelemetry-collector \>-f values.yaml \>-n newrelic --create-namespace
New Relic에서 데이터 보기
몇 분 후 HAProxy 메트릭이 뉴렐릭에 나타납니다. 데이터를 찾으려면:
- one.newrelic.com > All capabilities > All entities 으)로 이동합니다.
- 이름으로 HAProxy 엔티티를 검색하거나 엔티티 유형
HAPROXYINSTANCE(으)로 필터링합니다. - 엔티티를 선택하여 골든 메트릭(초당 세션 수, 초당 requests 수, 연결 오류)이 포함된 요약 페이지를 확인하세요.
문제점 해결
- HAProxy 파드에 올바른 레이블(예:
app: haproxy)이 있는지 확인합니다:kubectl get pods -l app=haproxy - stats 엔드포인트가 응답하는지 확인합니다:
kubectl exec -it <haproxy-pod> -- curl -s http://localhost:8404/stats - 검색 오류에 대해 수집기 로그를 검토합니다:
kubectl logs -n newrelic -l app.kubernetes.io/name=nr-k8s-otel-collector -f(NRDOT) 또는kubectl logs -n newrelic -l app=otel-collector-haproxy -f(OTel Contrib 매니페스트) - 수집기 ServiceAccount에 파드에 대한
get,list및watch권한이 있는지 확인합니다.
각 HAProxy 파드는 뉴렐릭에 별도의 엔티티를 생성해야 합니다. 하나의 엔티티만 표시되는 경우:
- 수집기에
host.id이(가) 설정되어 있는지 확인합니다. 컨테이너화된 환경에서는 수집기 배포에 다음을 추가합니다:env:- name: K8S_NODE_NAMEvalueFrom:fieldRef:fieldPath: spec.nodeName- name: OTEL_RESOURCE_ATTRIBUTESvalue: "host.id=$(K8S_NODE_NAME)" - 다음을 쿼리하여 파드별로 다른
haproxy.addr값을 확인합니다:FROM Metric SELECT uniques(haproxy.addr) WHERE metricName LIKE 'haproxy.%' SINCE 10 minutes ago
receiver_creator은(는) HAProxy에 도달하기 위해 파드 IP(localhost아님)를 사용합니다. stats 프런트엔드가127.0.0.1:8404이(가) 아닌*:8404(모든 인터페이스)에 바인딩되어 있는지 확인합니다.- 수집기 파드와 HAProxy 파드 간의 트래픽을 차단할 수 있는 네트워크 정책을 확인합니다.
다음 단계
- 수집된 메트릭의 전체 목록은 메트릭 참조 를 검토하세요.
- HAProxy 데이터를 찾고 쿼리하는 방법을 알아보세요.
- HAProxy 골든 메트릭을 기반으로 알림 을 설정합니다.