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.

  1. Login to using operate-first login

  2. Copy the token from the User dropdown menu

  3. Use this token as your oauth bearer token when connecting to Thanos via the client library

    • Eg:

      headers= {“Authorization”: “Bearer my_oauth_token_to_the_host”},
  4. The metric data can be extracted locally using the prometheus client in a Jupyter notebook

  5. You can also spawn and run your notebooks on JupyterHub