Skip to content

Prometheus: invalid header field value for "Authorization"

Observabilitytested on Ubuntu 24.04, k3s v1.37.3+k3s1, kube-prometheus-stack 94.5.0, Qdrant 1.20.3 mit API-Schlüssel und TLS

With curl and the same key, fetching the metrics works. Prometheus reports down for every pod, and the error does not come from the server – the request never leaves Prometheus.

Symptom

jq -r '.data.activeTargets[] | select(.labels.namespace=="qdrant") | [.labels.job, .labels.pod, .health, .lastError] | @tsv' ziele.json
qdrant-headless	qdrant-0	down	Get "https://10.42.1.56:6333/metrics": net/http: invalid header field value for "Authorization"
qdrant-headless	qdrant-2	down	Get "https://10.42.2.16:6333/metrics": net/http: invalid header field value for "Authorization"
qdrant-headless	qdrant-1	down	Get "https://10.42.3.32:6333/metrics": net/http: invalid header field value for "Authorization"

A ServiceMonitor reads Qdrant's read-only key from a secret and sends it as the Authorization header.

Diagnosis

64 hex characters and a newline – openssl rand -hex -out writes a \n at the end.

wc -c ../tag10/lese-key
65 ../tag10/lese-key

Causes

secretNewline at the end of the key

kubectl create secret --from-file copies the file byte for byte. curl with $(cat …) does not notice, because the shell strips the final newline. Prometheus takes the value literally, and a newline is not allowed in an HTTP header.

Fix

tr -d "\n" < ../tag10/lese-key > lese-key-prometheus, check with wc -c (64), then kubectl -n qdrant create secret generic prometheus-lesen --from-file=lesen=lese-key-prometheus and point the ServiceMonitor at this secret. The change takes effect after one to two minutes.

Don't: Look for the error on the server. Prometheus never sends the request – Qdrant's log shows nothing.

▶
Break it yourself and find it – free
Vector database engineering on Kubernetes, day 11: observability – the lending statistics.
Go to day 11 →

FAQ

Why does Qdrant accept the same key?

Qdrant reads the value from the same secret and apparently strips the newline when loading it. Prometheus does not.

Where else does the same mistake show up?

In the course also with S3 – there it is called SignatureDoesNotMatch. Always check key files with wc -c.

Related error patterns

More