grafana / synthetic-monitoring-app

Synthetic Monitoring frontend application
https://grafana.com/docs/grafana-cloud/how-do-i/synthetic-monitoring/
GNU Affero General Public License v3.0
121 stars 17 forks source link

[QUESTION] Call Auth, get token, and share it across all checks #932

Open fasatrix opened 1 week ago

fasatrix commented 1 week ago

Hi,

I’m new to this and not entirely sure if this is the right place for my question, so any guidance is appreciated.

We have a basic authentication (HTTPS) endpoint that requires a username and password to retrieve a token, which is then used in the headers for subsequent API calls. Since the Auth endpoint has a throttling limit, allowing only a few requests per minute without errors, I’m looking for a way to call this endpoint just once, store the token, and make it accessible in our k6 test scripts as an environment variable.

Ideally, the token should be refreshed periodically. A script triggered by cron (or a similar scheduler) would be perfect for this. The goal is to avoid making an Auth request in every k6 script, but instead, have the token fetched periodically, stored, and reused across all scripts.

Any advice on how to set this up would be greatly appreciated.

I really appreciate any help you can provide.

peterschretlen commented 15 hours ago

@fasatrix thanks for the question, we don't currently have a way to manage auth tokens or other secretes in this way. "secrets management" is a synthetics feature we're planning to implement, though I don't have an ETA for it.

Until then, consider using a secrets manager with an API to cache the token and then fetch it from the k6 script. For example if you're using AWS you could consider using https://grafana.com/docs/k6/latest/javascript-api/jslib/aws/secretsmanagerclient/ where you cache your token in AWS secrets manager and then use this client to fetch the token. Other secrets managers have APIs that you could use to create helper functions that operate in a similar way to this client.