Passing session cookie to grafana script running inside the browser

We are trying to integrate grafana into our website. We are using grafana in direct mode with influxdb as the datasource. No authentication turned on grafana as well as influxdb. However, we have to log into our website and grafana will be one of the tabs within the page. The influxdb query within the dashboard hit our backend and needs to be authenticated. To avoid that authentication, we plan to pass the cookie from login session to the grafana queries being generated by the grafana script. Is there a way to pass this cookie to that script? If yes, i will appreciate if someone can help on how to do that.


If you use direct access and influxdb is on the same domain and you use a cookie that is on that domain then yes you can get the cookie to influxdb.

Thanks Torkel for the quick response. My question is AFAIK the influxdb queries will be generated by the script (running on the web browser) and that script comes from the grafana server, right? How can i pass the cookie to that script? The cookie will work, but my question is about how to pass that cookie to that script.

pass cookie to script? What script?

Browsers will send cookies automatically for the domain they are assigned to if the request is to that domain.

Thanks once i got the grafana on the same domain as my parent’s domain, things work fine. Thanks for your help.