When I try to publish a snapshot to the external server I get an “Unexpected error” in the UI. After further investigations it seems that the first OPTIONS request to api/snapshots returns a 404 with body {“message”:“Not found”}.
I can successfully publish local snapshots on both Grafana servers. Also, from both servers I can publish a snapshot of the same dashboard to snapshot.raintank.io.
Is there anything I’m missing in my configuration? What could be causing this error?
I think that you’ll need to enable CORS on your external grafana instance. Easiest way of doing this is probably by running a reverse proxy that’s responds with proper CORS responses.
Hi
I am having the problem. Why would you think ia reverse proxy will fix the problem?
As it is an issue between two different applications?
I have a company openshift stack so difficult to add extra components.
My debugging is limited, I just see a , no message, in the chrome network tab, so not much to go on.
Hi Marcus,
Would you have an example of a reverse proxy setting,i am still struggling, going from a localhost grafana to a remote [called remote-grafana]
looking for general Cors solution, just a demo i am doing, so not too worried about security for now.
No luck yet, guess have to turn on full apache logging tomorrow.
just to check, on the remote grafana which will store the snapshots, it is just the default configuration, i have not changed any settings as i read snapshots is on by default
I switched to nginx as my ubuntu apache reverse proxy had a known bug when the url is longer than 98 characters , a url truncation is done (i have a long openshift url)
looking at nginx logs:
http upstream request: “/api/snapshots?”
my local grafana tries to copy the snapshot to this remote grafana, gets a 404 response code, but does it need an API key for the Authorization: Bearer , into the remote grafana? or does the remote grafana need to be put into annoyomous mode or something.
i am blind at the moment, knowing what/where thew problem/blockage is?
I think you need to add authentication (api key or basic authentication) information to an incoming request in nginx before you forward the request to to remote grafana.
If you still have issues you need to provide more detailed information. Like the complete request (including header and payload) from local grafana when saving snapshot and the complete response from (including header and payload) from that request.
You should also be able to check nginx log and the remote grafana server log - you can enable debug logging and router logging.
Thanks very much Marcus ,it is all working now.
I have a local Grafana, where I generate the snapshots ,and a remote Grafana to receive the snapshots (called remote-grafana.com for documentation), with NGINX running locally .
For the local Grafana I have:
[snapshots]
external_enabled = true
external_snapshot_url = http://localhost
external_snapshot_name = Publish to company
The reason why NGINX is needed I found was:
The private grafana issues a /api/snapshots OPTIONS api call to the remote Grafana before doing a POST api, I am not sure why, as it is not needed for a remote server, but it happens.
The API KEY for the public facing Grafana is inserted by the nginx changes. for securityI can improve this later and add HTTPS to the Grafana’s.