JSON API Data Source : 404 error

It’s a slash. Yeah, that’s right:

  • /api/cool/device/1/ OK
  • /api/cool/device/1 FAIL

I don’t know the whole story, but note

  • It’s a NGINX related thing: NGINX is proxy_pass and returning a 301 redirect to a URL with the slash. Reference
  • Postman works fine on the API. I guess it can handle the 301 and re-request. The JSON datasource, I guess, doesn’t do this.
  • The difficult to work out error messages are (guessing) related to dataproxy in Grafana displaying a 404, when it actually received a 301 from the API. Other errors (e.g. 500) from the server are also shown as 404.

The simple solution is to add a trailing slash to queries, so NGINX doesn’t send a 301.

( A better solution would be to stop ngnix adding the slash. That’s homework.)

2 Likes