400 Bad Request - There Was An Error Returned Querying The Prometheus Api Apr 2026
curl -G http://localhost:9090/api/v1/query \ --data-urlencode 'query=upjob="node"' (This is the safest way to use curl with Prometheus.) Sometimes, it genuinely isn't your fault. A bug in a third-party exporter or a service discovery crash can inject NaN or Inf values into the label set. If your query tries to filter on a label that contains a newline character ( \n ) or a control character, the JSON marshaller fails.
Troubleshooting the Ghost: Decoding the “400 Bad Request” from the Prometheus API It is frustrating
4 minutes We have all been there. You have built a beautiful Grafana dashboard, or you are trying to fetch metrics via curl to debug a latency spike. You type the command, hit enter, and instead of a JSON payload of time series data, you are greeted with the digital equivalent of a slammed door: "400 Bad Request - There was an error returned querying the Prometheus API" It is vague. It is frustrating. And it usually happens at 2 AM during an incident. the JSON marshaller fails.
debugging-prometheus-400-bad-request