How to get "Authorization: Bearer $SENSU_TOKEN"?

Hi Geeks,

I am integration grafana with sensugo API using Sensu Go datasource. Grafana is successfully connected with datasource but it is not showing all namespaces and subsciptions but default. I try to explore API, it is asking “Authorization: Bearer $SENSU_TOKEN”?. How can I get it. I tried as. sensugo is my token for cluster.

curl http://IP:8080/api/core/v2/namespaces -H “Authorization: Bearer sensugo”
{“Code”:5,“Message”:“invalid credentials”}

Hi @masifpak,

If you just need to manually query the API, you could export your user access token to your environment variables and use that as the bearer token; keep in mind that this access token is valid for a maximum of 5 minutes so you might need to refresh it often. Here’s how you could use it:

$ eval $(sensuctl env)
$ curl -H "Authorization: Bearer $SENSU_ACCESS_TOKEN"[...]

Alternatively, you could create and use an API key to authenticate against the API if you need long-lived tokens:

For the grafana integration you may want to look at the new apikey resource as an alternative to the authentication token for this integration. apikeys are new in 5.15.

And think about configurating a dedicated grafana user in Sensu that has RBAC rules in place to limit access to just the events API.

Great idea thanks @jspaleta for ever being helpful.