prometheus-community / prometheus-community/postgres_exporter
Multi-target pattern: /probe endpoint cannot handle array of targets from ServiceMonitor
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 3.6k
- Forks
- 835
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 10
Description
What did you do?
I created a service monitor to use multi target pattern by feeding an array of targets to the targets params.
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
annotations:
meta.helm.sh/release-name: prometheus-postgres-exporter
meta.helm.sh/release-namespace: monitoring
labels:
app.kubernetes.io/managed-by: Helm
name: prometheus-postgres-exporter
namespace: monitoring
spec:
endpoints:
- targetPort: http
path: /probe
params:
targets:
- postgres:password@svc-postgres.ns-app1.svc.cluster.local:5432/app_db?sslmode=disable
- postgres:password@svc-postgres.ns-app2.svc.cluster.local:5432/app_db?sslmode=disable
- postgres:password@svc-postgres.ns-app3.svc.cluster.local:5432/app_db?sslmode=disable
- postgres:password@svc-postgres.ns-app4.svc.cluster.local:5432/app_db?sslmode=disable
relabelings:
# - sourceLabels: [__address__]
# targetLabel: __param_target
- sourceLabels: [__param_target]
targetLabel: instance
- targetLabel: __address__
replacement: prometheus-postgres-exporter:80
metricRelabelings:
- sourceLabels: [instance]
regex: (.*\.(\w+-\w+).*)
targetLabel: shortname
replacement: ${2}
action: replace
jobLabel: prometheus-postgres-exporter
namespaceSelector:
matchNames:
- monitoring
selector:
matchLabels:
app: prometheus-postgres-exporter
release: prometheus-postgres-exporter
What did you expect to see?
I expected this to work, similarly to blackbox exporter which accepts an array of targets.
What did you see instead? Under which circumstances?
/probe sends a 400 error bad request to prometheus as /probe cannot handle an array of values being sent to it.
Environment
-
System information:
Kubernetes 1.23 Helm3 -
postgres_exporter version:
postgres-exporter:master -
postgres_exporter flags:
/bin/postgres_exporter --extend.query-path=/etc/config.yaml --web.listen-address
-
PostgreSQL version:
PostgreSQL 14.7 (Debian 14.7-1.pgdg110+1) -
Logs:
no relevant logs
As an alternative I am currently running multiple endpoints, each with its own target, but this is hard to maintain (servicemonitor will have many config duplicates) when you have many postgres instances to monitor from a single postgres-exporter deployment.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the /probe endpoint and reproduce the 400 response with the repeated targets shown in the ServiceMonitor configuration. Compare the desired behavior with the blackbox exporter’s array handling, then define and verify how multiple PostgreSQL targets should be processed while preserving the current single-target behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kubernetes, postgresql
- Domain
- backend, databases, observability-sre
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100