Nginx reverse proxy rewrite directive

In the grafana reverse proxy tutorial, we’re told to add the following to the location block if we’re serving grafana from a sub path

rewrite ^/grafana/(.*) /$1 break;

which from what I understand means for a url like http://X.X.X.X/grafana/d/Y8u6aUiRt/dash?orgId=2&refresh=10s&kiosk, $1 will then contain d/Y8u6aUiRt/dash?orgId=2&refresh=10s&kiosk

Then I understand /$1 is slapped onto the end of what’s in proxy_pass, so the server behind nginx can handle the request. Since I can see my dashboard, I’m assuming my understanding is somewhat correct, so how come the following isn’t equivalent?

Maybe something to with how ? is handled in the rewrite string?

rewrite ^/grafana/(.*) /d/Y8u6aUiRt/dash?orgId=2&refresh=10s&kiosk break;

If I make this change in nginx, then all I get is the dreaded " If you’re seeing this Grafana has failed to load its application files" page, so obviously it’s not the same, but why?

Maybe something to do with how ‘?’ is interpreted in the rewrite string?