[Bug]: /metrics returns a fixed short body while last_collection_error stays 0
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- go, kubernetes, postgresql, prometheus
- Lĩnh vực
- databases, observability
Hướng nghiên cứu
Start with pkg/management/postgres/webserver/metricserver/metrics.go, which the issue identifies as the metrics server entry point, then trace how the SQL-backed metric families are collected and how collection errors affect the exported metrics. Compare behavior during a burst of Defaulting for Cluster logs with a normal scrape. Done means a scrape includes the expected metric families or sets cnpg_collector_last_collection_error to 1 when they are missing.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Is there an existing issue already for this bug?
- I have searched for an existing issue, and could not find anything. I believe this is a new bug.
I have read the troubleshooting guide
- I have read the troubleshooting guide and I think this is a new bug.
I am running a supported version of CloudNativePG
- I have read the troubleshooting guide and I think this is a new bug.
Version
1.30 (latest patch) — image ghcr.io/cloudnative-pg/cloudnative-pg:1.30.1. No release is newer than v1.30.1 (published 2026-09-23).
What version of Kubernetes are you using?
1.36
What is your Kubernetes environment?
Other (self-managed Talos)
How did you install the operator?
Helm
What happened?
During a burst of Defaulting for Cluster logs, instance /metrics returns HTTP 200 with a fixed short body. cnpg_collector_up stays 1 and cnpg_collector_last_collection_error stays 0. Families that alerts need, including cnpg_pg_replication_in_recovery and cnpg_backends_total, are absent. A normal body for these instances is about 460–560 samples. The short body is 77 samples on a primary and 76 on a replica, including when the scrape finishes in a few hundred milliseconds.
This is not the Prometheus client hitting its deadline. scrape_timeout_seconds is 10. The slowest scrape in the window below is 5.63s. In v1.30.1 pkg/management/postgres/webserver/metricserver/metrics.go the metrics server sets ReadTimeout and ReadHeaderTimeout and does not set WriteTimeout. promhttp.HandlerFor is called with empty HandlerOpts. A completed 76-sample response is the registry contents for that request.
The same process logs the defaulting line. In one minute of the window below, the operator logged it 550 times and each instance's postgres container logged it tens to about 140 times. Outside the window the fleet total is about 1–8 lines per minute. cloudnative-pg/cloudnative-pg#11487 and the open pull request cloudnative-pg/cloudnative-pg#11556 cover that log volume. They do not cover the short body.
Two windows, same operator:
-
2026-10-18, after switchovers. Affected instances served about 77 samples instead of 480–520.
cnpg_pg_replication_in_recoveryandcnpg_backends_totalwere missing.cnpg_collector_upwas 1 andcnpg_collector_last_collection_errorwas 0.Defaulting for Clusterran about 90–170 times per minute in that window. Primaries that were not restarted were short as well. -
2026-10-19 06:21Z–06:26Z, retained VictoriaMetrics and VictoriaLogs. Seven three-instance clusters. For job
victoria-metrics/cnpg,min(scrape_samples_scraped)is 76 for each of those six minutes and about 460 outside them. Short primaries are 77, short replicas are 76. The same pod can return a full body (about 480–550) on one scrape and 76 on the next, so the exporter is not stuck.max(scrape_duration_seconds)across the six minutes is 5.63, 4.42, 4.01, 3.14, 2.75, 2.70.cnpg_collector_collection_duration_seconds{collector="Collect.cnpg"}rises to about 3.6s on some primaries; outside the window it is about 0.1–0.4s. The count ofcnpg_pg_replication_in_recoveryseries falls from 22 to 2, andcnpg_backends_totalfrom 42 to 3. Wherecnpg_collector_upandcnpg_collector_last_collection_errorare still present they are 1 and 0.Defaulting for Clustercounts per minute from 06:20Z: 625, 1843, 2012, 1965, 2122, 1895, 262, then single digits. The one single-instance cluster did not drop to 76.
Expected: a scrape either returns the full set, or cnpg_collector_last_collection_error is 1 when the body is missing the SQL-backed families.
Cluster resource
Not pasted. The affected clusters are ordinary 3-instance postgresql.cnpg.io/v1 Clusters with the chart's default monitoring queries. The short body hit primaries and replicas, including primaries whose node was not rebooted.
Relevant log output
No exporter error line. The correlated line is msg="Defaulting for Cluster", logger="cluster-resource", from both cnpg-system manager and the instance postgres container. Rate is above.
Code of Conduct
- I agree to follow this project's Code of Conduct
- Ngôn ngữ chính
- Go
- Star
- 9.7k
- Fork
- 830
- Merge trung bình
- 2 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 122
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của cloudnative-pg/cloudnative-pg
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
cloudnative-pg/cloudnative-pg#12059 · 3 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Docs]: Document the egress traffic that instance pods need when a NetworkPolicy restricts egressCó thể làm lại được @fjvbn2003 đã nhận 14 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
cloudnative-pg/cloudnative-pg#11750 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: A failed plugin backup sets the deprecated `status.lastFailedBackup`, so `cnpg_collector_last_failed_backup_timestamp` stays newer than the last available backupCó thể làm lại được @fjvbn2003 đã nhận 14 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
cloudnative-pg/cloudnative-pg#11749 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Managed role stays pending-reconciliation when a membership has several grantor rowsCó thể đã có người làm @MatheuslFavaretto đã nhận 45 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
cloudnative-pg/cloudnative-pg#11624 · 2 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: enablePDB=false deletes independently managed PDBs with matching namesCó thể đã có người làm @WoahitsJoe đã nhận 62 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
cloudnative-pg/cloudnative-pg#11600 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của cloudnative-pg/cloudnative-pg
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
eryajf/learning-weekly#260 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
OpenAI embedding client returns batch vectors in response order despite explicit input indicesCó thể đã có người làm @ningsiyuan1024 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày