Prometheus get refresh tokens from sidecar program?

Issue: Prometheus on Kubernetes Pod with OAuth Sidecar

I am running Prometheus on a Kubernetes Pod, with an OAuth sidecar to obtain a bearer token for the targets. The token expires after two weeks, and I am having to restart the Pod to get the new token working in Prometheus.

Can anyone help me understand why the new token provided by the sidecar is not being updated in Prometheus?

Fenced code blocks

It is likely that Prometheus is caching the bearer token and not refreshing it automatically. You can try adding the bearer_token_file configuration option in the Prometheus configuration file and pointing it to the file where the sidecar is updating the bearer token. This will make Prometheus read the new token from the file instead of caching it.