Use bearer token to scrape Prometheus

Hello,

we’ve been able to do token based authentication by using plugin routes, e.g.:

“routes”: [
{
“path”: “”,
“method”: “GET”,
“url”: “https://prometheus-openshift-metrics.apps.example.com”,
“headers”: [
{“name”: “Authorization”, “content”: “Bearer [your-token-here]”}
]
}],

You need to add above stanza to:

/usr/share/grafana/public/app/plugins/datasource/prometheus/plugin.json

restart grafana and properly configure a prometheus datasource pointing to above url.

It is a bit suboptimal since i’ve not yet found a way to add this section programmatically but i’m a grafana newby.

Is there a way to add a plugin routes programmatically or alternatively to create a prometheus datasource with token based authentication via APIs?

Thanks for any insight,

-m