Multiple Prometheus Datasources secured by OAuth Token

Hi All,

I’m a Grafana rookie so please forgive me if I’m missing something obvious, but I did my best to find a solution and I came up blank…

I’m trying to add a Prometheus Datasource that is secured using a short lived OAuth token. The prometheus oauth token has nothing to do with the Grafana user authentication. I need the Grafana server to fetch a new OAuth token whenever the existing token has expired and to attach it to all my PromQL requests to this particular Prometheus datasource as a ‘bearer’ token.

Initially I thought this might be possible with the ‘Routes’ config in Prom’s plugin.json as described here: https://grafana.com/docs/grafana/latest/developers/plugins/add-authentication-for-data-source-plugins/#enable-token-authentication. How that doesn’t seem to work for me, likely because it needs deeper plugin integration.

OK, I got an route added to the plugin.json that is working for a single datasource. plugin.json snippet:

"routes": [
{
  "path": "",
  "method": "",
  "url": "https://metric-store.sys.pcf1.mycompany.com",
  "tokenAuth": {
    "url": "https://login.sys.pcf1.mycompany.com/oauth/token",
    "params": {
      "grant_type": "password",
      "client_id": "cf",
      "client_secret": "",
      "username": "omitted",
      "password": "omitted"
    }
  }
}
]

When I add another datasource and route all traffic just get proxied through the first route. How do I go about applying a route to a single datasource? My thought was using the ‘path’ attribute, but I have not be able to make that work.