Accessing cookies from datasource plugin

I’m pretty sure this isn’t possible, but figured I’d check anyway…

I’m using the Infinity datasource plugin. We have some somewhat funky auth, where each Grafana user has a JWT stored in a cookie. That cookie is included in all requests the frontend makes to the Grafana backend (including datasource requests). The JWT from that cookie can be used to authenticate requests to an API endpoint I’d like to hit from the Infinity datasource.

I figured I should be able to modify the datasource plugin to (1) read the cookie, (2) grab the JWT, (3) pass the JWT with the API requests. But after a bit of poking around, it seems that there’s no way for the datasource plugin to access any cookies included from the HTTP request. In fact, inspecting QueryDataRequest (SDK) always shows a completely blank Headers map regardless of the request headers…I guess this is only populated when OAuth passthrough is enabled?

Anyway, as I said at the start, I guess there’s no way to access the cookie/request headers from within the datasource plugin - but I’d love to be corrected if I’ve missed anything!

what if you used apache echart grafana plugin. @mikhailvolkov

Avoid any kind of funk unless it’s on the dance floor.

Sample apache echart code


@yosiasz Bringing the funk with Apache ECharts. Love it!

Haha love it!!

The EChart plugin looks really neat, and I’ve been meaning to play around with it. For now I’d say we’re after something that works with the stock Grafana visuals, just on the datasource side of things.

And yeah, I agree that the funk is no bueno. For now I wanted to see if there is a relatively simple way to get things working with the existing auth mechanism. Plan B is to basically change the auth mechanism itself to something less funky…

1 Like