🔍 오류 발생 원인
Prometheus에서 특정 타겟을 스크래핑할 때, 다음과 같은 오류가 발생할 수 있습니다.
Error scraping target: non-compliant scrape target sending blank Content-Type and no fallback_scrape_protocol specified for target
이 오류는 Prometheus가 대상 엔드포인트(NiFi, Spring Actuator, 기타 메트릭 제공 서비스)로부터 데이터를 가져올 때, Content-Type이 올바르게 설정되지 않았거나, 예상한 프로토콜 형식이 일치하지 않을 때 발생합니다.
특히 Prometheus 2.43 버전 이상에서는 Content-Type 검증이 더욱 엄격해지면서 이전에는 문제없이 동작하던 서비스에서도 위와 같은 오류가 발생할 수 있습니다.
🛠 해결 방법
✅ 1. Prometheus 설정 변경
global:
scrape_interval: 5s # 기본 스크래핑 간격
scrape_configs:
- job_name: "nifi"
scheme: "http" # 또는 "https" (해당 엔드포인트가 HTTPS를 사용한다면)
follow_redirects: true # 리다이렉션 자동 따라가기
# 🚀 추가: fallback_scrape_protocol 설정
fallback_scrape_protocol: "PrometheusText0.0.4"
metrics_path: "/metrics" # PrometheusReportingTask 등의 기본 메트릭 경로
static_configs:
- targets: ["nifi:9092"] # 대상 엔드포인트 (예: NiFi)
✅ 2. Prometheus 컨테이너 재시작
설정 파일을 수정한 후, Prometheus 컨테이너를 재시작해야 변경 사항이 반영됩니다
docker-compose down
docker-compose up -d
🔍 추가 분석: fallback_scrape_protocol이란?
fallback_scrape_protocol 옵션은 Prometheus가 특정 타겟에서 표준 Content-Type을 제공하지 않는 경우, 특정 프로토콜을 강제로 적용할 수 있도록 합니다.
- "PrometheusText0.0.4": Prometheus 0.0.4 텍스트 포맷을 강제 적용하여 Content-Type이 비어 있거나 예상과 다를 때도 데이터를 정상적으로 수집할 수 있도록 합니다.
🎯 결론
이 오류(non-compliant scrape target sending blank Content-Type and no fallback_scrape_protocol specified for target )는 Prometheus의 최신 버전에서 Content-Type 검증이 강화되면서 발생하는 문제입니다.
fallback_scrape_protocol: "PrometheusText0.0.4"을 추가하여 올바른 프로토콜을 강제 적용 하여 해결할 수 있었습니다.
위 방법을 적용하면, Prometheus가 비표준 응답을 포함한 다양한 서비스에서 메트릭을 정상적으로 수집할 수 있을 것입니다.