diff --git a/cerberus/prometheus/client.py b/cerberus/prometheus/client.py index dbb05ee..20520d6 100644 --- a/cerberus/prometheus/client.py +++ b/cerberus/prometheus/client.py @@ -15,7 +15,10 @@ def initialize_prom_client(distribution, prometheus_url, prometheus_bearer_token ) prometheus_url = "https://" + url if distribution == "openshift" and not prometheus_bearer_token: - prometheus_bearer_token = runcommand.invoke("oc -n openshift-monitoring " "sa get-token prometheus-k8s") + prometheus_bearer_token = runcommand.invoke( + "oc -n openshift-monitoring sa get-token prometheus-k8s " + "|| oc create token -n openshift-monitoring prometheus-k8s" + ) if prometheus_url and prometheus_bearer_token: bearer = "Bearer " + prometheus_bearer_token headers = {"Authorization": bearer}