Thanos Programmatic Access#
The Thanos metrics can be queried using the this Python client library.
You can install the latest version with pip install prometheus-api-client
.
You will need to extract the OpenShift bearer token for the client library to authenticate the thanos instance.
Personal token#
You can use your personal token for testing and ad-hoc scripts, but it will expire in ~24 hours.
Login to https://console-openshift-console.apps.smaug.na.operate-first.cloud/ using
operate-first
loginCopy the token from the User dropdown menu
Use this token as your oauth bearer token when connecting to Thanos via the client library
Eg:
prometheus_api_client.prometheus_connect.PrometheusConnect( url='https://thanos-query-frontend-opf-observatorium.apps.smaug.na.operate-first.cloud', headers= {“Authorization”: “Bearer my_oauth_token_to_the_host”}, disable_ssl=False )
The metric data can be extracted locally using the prometheus client in a Jupyter notebook
You can also spawn and run your notebooks on JupyterHub