Prometheus
Prometheus 으로 메트릭 데이터를 수집하는 것이 점점 더 인기를 얻고 있습니다. Instana를 사용하면 광범위한 지식 그래프를 사용하여 Prometheus 메트릭을 쉽게 캡처하고 상호 연관성을 파악할 수 있습니다. 대표적인 예로 사용자 지정 비즈니스 지표를 들 수 있습니다.
Instana 호스트 에이전트를 설치하면 Instana Prometheus 센서가 자동으로 설치되지만 구성 섹션에 설명된 대로 센서를 구성해야 합니다. 그런 다음 Instana UI에서 Prometheus 와 관련된 메트릭을 볼 수 있습니다.
Instana는 Prometheus Alertmanager 웹훅 수신기 구성에 설명된 대로 Prometheus Alertmanager 웹훅의 페이로드 형식으로 HTTP POST 요청을 보낼 수 있는 Prometheus Alertmanager 웹훅 알림 채널을 제공합니다.
Instana에서 Prometheus 로 실시간으로 알림 알림을 보내려면 Instana UI에서 Prometheus Alertmanager 웹훅 알림 채널을 만드세요. 그런 다음 HTTP POST 요청이 Prometheus 으로 전송됩니다.
소개
Instana Prometheus 센서에는 Prometheus 서버가 필요하지 않습니다. 센서는 모니터링되는 시스템에 의해 노출된 엔드포인트에서 직접 메트릭을 캡처합니다.
각 Instana 호스트 에이전트에 대해 폴링할 Prometheus 엔드포인트와 정규식을 사용하여 수집해야 하는 메트릭을 지정합니다. 자세한 내용은 구성 섹션을 참조하세요.
마이크로미터 주제에서는 마이크로미터 메트릭을 수집하는 방법을 보여줍니다.
Prometheus -java-client 항목에서는 Prometheus Java 클라이언트 라이브러리 또는 Micrometer의 Prometheus 미터 레지스트리에서 메트릭을 수집하는 방법을 보여 줍니다.
Jmx 주제에서는 JMX 빈에서 사용자 지정 메트릭을 수집하는 방법을 보여줍니다.
구성
Kubernetes 환경용 구성
호스트 에이전트 구성 파일 configuration.yaml 에 엔드포인트 목록으로 메트릭 소스를 정의해야 합니다. Instana 호스트 에이전트가 Kubernetes 환경에서 실행되는 경우, 에이전트는 실행 중인 파드에서 IP 주소와 컨테이너 포트를 자동으로 인식하고 수집합니다. Kubernetes 환경에서는 agent.configuration_yaml 값을 통해 이 구성을 상담원에게 전달해야 합니다. 운영자를 사용하여 에이전트를 설치하는 경우 spec.agent.configuration_yaml 아래에 있는 사용자 지정 리소스 YAML 파일 instana-agent.customresource.yaml 에 구성을 추가합니다. Helm 차트를 사용하여 에이전트를 설치하는 경우 --set
agent.configuration_yaml=<config> 플래그를 통해 구성을 전달합니다. 또는 values.yaml 파일에서 구성을 설정하고 -f 플래그를 사용하여 helm install 명령에 전달합니다.
다음 구성 예제를 참조하십시오.
com.instana.plugin.prometheus:
poll_rate: 15 # Global polling interval in seconds (optional, default is 1 second)
username: '' # Global (all) endpoints username/password configuration (optional)
password: ''
podConnectTimeout: 750 # discovery TCP connect timeout in ms used during discovery request (optional, default is 750ms)
podReadTimeout: 2500 # discovery TCP read timeout in ms used during discovery request (optional, default is 2500ms)
customMetricSources:
- url: '/prometheus/endpoint/1' # metrics endpoint, the IP and port are auto-discovered
metricNameIncludeRegex: '^.' # regular expression to filter metrics
username: '' # endpoint specific username/password configuration
password: ''
- url: '/prometheus/endpoint/2'
metricNameIncludeRegex: '^.'
- url: '/metrics' # metrics endpoint, the IP and port are auto-discovered
metricNameIncludeRegex: '^.' # regular expression to filter metrics
labels: # labels are used to limit discovery with pods that match. labels are treated as a boolean AND
planet: "mars"
app: "rover"
prometheus.io/scrape, prometheus.io/port 및 prometheus.io/path 와 같은 프로메테우스 어노테이션이 포함된 쿠버네티스 리소스를 스크랩하려는 경우, 프로메테우스 구성에서 prometheusAnnotations 필드를 strict 로 설정하면 해당 특정 리소스에 대해 customMetricsSources 섹션을 사용할 필요가 없습니다. 예를 들어,
com.instana.plugin.prometheus:
podConnectTimeout: 750 # discovery TCP connect timeout in ms used during discovery request (optional, default is 750ms)
podReadTimeout: 2500 # discovery TCP read timeout in ms used during discovery request (optional, default is 2500ms)
prometheusAnnotations: strict # use prometheus annotations as defined, no metric source is required
참고:
Kubernetes 환경의 경우,
url필드에 호스트 및 포트 정보를 추가하지 말고/prometheus/endpoint/metrics과 같은 메트릭 엔드포인트 URL 만 추가하세요. Prometheus 센서는https://prod-myapp.server.com/prometheus/metrics과 같이 전체 URL로 지정된 엔드포인트를 모니터링하지 않습니다.프로메테우스 어노테이션을 사용하지 않는 경우, Kubernetes 포드 배포 사양의 컨테이너 포트(
containerPort) 정의가 메트릭 엔드포인트 포트를 결정하는 데 사용됩니다.metricNameIncludeRegex필드에 정규식을 사용하여 특정 메트릭 엔드포인트에 대해 캡처할 메트릭을 정의할 수 있습니다.Prometheus 센서에는 글로벌 수준(모든 엔드포인트) 또는 엔드포인트별로 정의할 수 있는 기본 인증이 지원됩니다.
Kubernetes 이외의 환경을 위한 정적 구성
정적 구성은 Kubernetes 환경이 아닌 경우에 사용됩니다. Kubernetes 환경이 아닌 로컬 또는 원격 엔드포인트에서 Prometheus 메트릭을 캡처하려면 <agent_install_dir>/etc/instana/configuration.yaml 파일의 customMetricSources 섹션을 다음과 같이 구성하세요:
com.instana.plugin.prometheus:
# Global polling interval in seconds (optional)
poll_rate: 15 # Default is 1 second
username: '' # Global (all) endpoints username/password configuration (optional)
password: ''
customMetricSources:
- url: 'http://localhost:8080/metrics'
username: '' # endpoint specific username/password configuration
password: ''
metricNameIncludeRegex: '^sample_app_request'
- url: 'http://223.58.1.10:9100/prometheus'
metricNameIncludeRegex: '^sample_app_request'
labels: # labels are used to limit discovery with pods that match. labels are treated as a boolean AND
planet: "mars"
app: "rover"
metricNameIncludeRegex 을 정의하지 않으면 Prometheus 센서가 메트릭 유형당 정의된 한도인 600개의 메트릭 유형까지 모든 메트릭 유형을 수집합니다.원격 쓰기
Instana 호스트 에이전트 번들 1.1.587 에서 시작하여 호스트 에이전트는 remote_write 엔드포인트에 대한 지원을 포함하므로 메트릭을 수집할 수 있으며 이러한 메트릭은 Prometheus 엔티티 또는 프로세스 사용자 지정 메트릭의 일부로 표시됩니다.
remote_write 엔드포인트를 사용하려면 다음과 같이 <agent_install_dir>/etc/instana/configuration.yaml 파일을 구성합니다:
com.instana.plugin.prometheus:
remote_write:
enabled: true
참고:
Prometheus remote_write 문서에 설명된 대로 발신자(메트릭을 전송하는 컴포넌트)를 설정합니다.
remote_write엔드포인트는42699포트의/prometheus/v1/receive경로에서 사용할 수 있습니다. 따라서 Prometheus 구성에서 구성해야 하는 URL 은http://<agent_ip>:42699/prometheus/v1/receive입니다.Instana가 메트릭을 올바르게 구문 분석하도록 하려면 발신자가 메타데이터를 보내야 합니다. 발신자는 Prometheus 에서 기본값으로 설정되어 있으므로 끄지 마세요.
선택 사항인 Instana 에이전트 Helm 차트를 사용하여 Kubernetes 에서 제공되는 Instana 에이전트 서비스는
remote_writeAPI와 함께 사용하면 매우 유용합니다. Instana 에이전트 서비스를 사용하면 데이터가 동일한 Kubernetes 노드에서 실행되는 Instana 에이전트로 푸시되므로 Instana 에이전트가 인프라 상관관계 데이터를 올바르게 채울 수 있습니다.현재
remote_write엔드포인트는 인증이 지원되지 않으므로 발신자의basic_auth및bearer_token(bearer_token_file포함) 옵션을 Prometheus 으로 구성하지 마세요.
원격 쓰기를 위한 TLS 암호화
호스트 에이전트에서 TLS 암호화를 사용 설정할 수 있습니다. 그런 다음 remote_write 엔드포인트로 전송되는 모든 데이터는 TLS로 암호화됩니다.
TLS 암호화를 설정하는 방법에 대한 자세한 내용은 TLS 암호화 사용하기를 참조하세요.
인프라 상관
Linux 호스트에 대한 인프라 상관 관계는 상담원의 HTTP API 엔드포인트를 참조하세요.
델타 카운터
카운터의 증가를 이전 값과 비교하여 측정할 수 있습니다. 그러나 이러한 측정에 적합한 Prometheus UI의 increase 집계는 동일한 버킷 내에서 카운터 리셋 직후에 발생한 증가분을 삭제하기 때문에 잘못된 결과를 생성할 수 있습니다. Counter 에 대한 자세한 내용은 Prometheus 문서를 참조하세요.
Delta counters 카운터 재설정을 허용하면서 값의 증가를 정확하게 측정하여 이 문제를 해결합니다. 모든 카운터 지표에 대해 해당 델타 카운터 지표가 생성됩니다. 예를 들어 Prometheus 엔드포인트의 카운터 메트릭 foo 은 다음 두 가지 메트릭을 생성합니다:
metrics.counters.foometrics.delta_counters.foo
이러한 메트릭의 생성은 구성 파일 configuration.yaml 에서 설정할 수 있습니다:
com.instana.plugin.prometheus:
---
sendCounterMetrics: true
sendDeltaCounterMetrics: true
Counters 및 Delta counters 모두 기본적으로 활성화되어 있습니다. Delta
counters 만 필요한 경우 다음 매개 변수를 설정하여 Counters 을 비활성화할 수 있습니다:
sendCounterMetrics: false
메트릭 보기
메트릭을 보려면 다음 단계를 완료하세요:
- Instana UI의 사이드바에서 인프라를 선택합니다.
- 모니터링되는 특정 호스트를 클릭합니다.
그러면 수집된 모든 메트릭과 모니터링된 프로세스가 포함된 호스트 대시보드를 볼 수 있습니다.
Prometheus 메트릭은 호스트 또는 수집된 프로세스와 연결된 " Prometheus 앱"으로 표시됩니다( remote_write 엔드포인트를 사용하는 경우). 동적 초점, 이벤트 및 알림, Grafana 플러그인( entity.type:prometheus)을 사용하여 Prometheus 사용자 지정 메트릭을 쿼리할 수 있습니다.
Prometheus 센서는 모든 핵심 지표 유형을 수집하며, 유형당 최대 600개의 지표를 수집합니다:
- 카운터
- 게이지
- 히스토그램
- 요약
- 입력되지 않음
경보 중
Prometheus Alertmanager 웹훅 알림 채널 만들기
Prometheus Alertmanager Webhook 알림 채널을 생성하려면 Instana UI에서 설정 > 글로벌 설정 > 이벤트 및 알림 > 알림 채널 > 알림 채널 추가를 클릭한 다음 Prometheus Alertmanager Webhook을 클릭합니다.

Instana는 이 알림 채널을 통해 구성된 Prometheus Alertmanager 웹훅 수신기 (예: 알림 스니치 또는 SNMP 알림기 )에 HTTP POST 요청으로 알림을 보냅니다.
SNMP 알림
SNMP 알림 프로젝트는 Prometheus 알림을 구성된 모든 SNMP 수신기에 SNMP 트랩으로 전달합니다.
Instana는 Instana 이미지 레지스트리에서 SNMP 알림에 대한 이미지를 제공하지 않습니다. 자세한 내용은 SNMP 알리미에서 안내를 참조하세요. SNMP 알림장 설치에 대한 예는 Kubernetes 에서 SNMP 알림장 실행하기 섹션을 참조하세요.
알림 채널 구성
생성한 Prometheus Alertmanager 웹훅 알림 채널을 구성하고 Prometheus Alertmanager 웹훅 수신기 URL 필드를 http://{SNMP-Notifier-Host}:9464/alerts 으로 설정해야 합니다. SNMP 알림이 snmp-notifier 라는 네임스페이스에 Instana 백엔드와 동일한 클러스터에 설치된 경우 Prometheus Alertmanager 웹훅 수신기 URL 는 http://snmp-notifier-alertmanager-snmp-notifier.snmp-notifier.svc:9464/alerts 처럼 보입니다.
예시: 다음에서 SNMP 알리미를 실행합니다 Kubernetes
Docker 허브 자격 증명을 사용하여 SNMP 알리미용 네임스페이스와 공개 Docker 레지스트리용 비밀 번호를 만듭니다:
kubectl create namespace snmp-notifier kubectl -n snmp-notifier create secret docker-registry image-pull-secret \ --docker-server=docker.io \ --docker-username=${YOUR_USERNAME} \ --docker-password=${YOUR_PASSWORD}SNMP 트랩으로 알림을 수신하는 서버의 IP 주소를 사용하여 SNMP 알림을 설치합니다:
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm install snmp-notifier prometheus-community/alertmanager-snmp-notifier \ -n snmp-notifier \ --set 'imagePullSecrets={image-pull-secret}' \ --set 'snmpNotifier.snmpDestinations={IP_ADDRESS_OF_SNMP_TRAP_RECEIVER_SERVER:162}'
SNMP 알리미 구성에 대한 자세한 내용은 SNMP 알리 미를 참조하세요. 지원되는 모든 차트 매개변수 및 기본값에 대한 자세한 내용은 values.yaml.
문제점 해결
원격 쓰기 높은 메트릭 지연
문제 유형 모니터링: prometheus_remote_write_high_delay
Prometheus remote_write 엔드포인트에서 수집되는 메트릭이 높은 지연 시간으로 수신되고 있습니다. 이 문제로 인해 알림이 지연될 가능성이 있으며 다른 소스의 메트릭과 연관 짓기가 더 어려워집니다.
Prometheus remote_write 구성을 조정합니다. 구체적으로 다음과 같이 batch_send_deadline 매개 변수를 추가하여 지연을 1초로 제한합니다:
remote_write:
- url: "http://xxx.xxx.xxx.xxx:42699/prometheus/v1/receive"
queue_config:
batch_send_deadline: 1s
자세한 구성 옵션은 Prometheus 매뉴얼을 참조하세요.
Prometheus 메트릭 구문 분석 오류
문제 유형 모니터링: prometheus_metric_parse_error
Prometheus 엔드포인트에서 검색되는 메트릭에 프로메테우스 메트릭 사양에 맞지 않는 정보가 포함되어 있는 경우. 이 문제로 인해 잠재적으로 엔드포인트의 일부 프로메테우스 메트릭이 처리되지 않을 수 있습니다. 모니터링 문제 정보를 사용하여 문제의 원인을 파악하고 프로메테우스 엔드포인트를 수정하세요.