Python Api

class observabilityclient.v1.python_api.QueryManager(client)

Bases: Manager

clean_tombstones()

Instruct prometheus to clean tombstones.

delete(matches, start=None, end=None)

Delete metrics from Prometheus.

The metrics aren’t deleted immediately. Do a call to clean_tombstones() to speed up the deletion. If start and end isn’t specified, then minimum and maximum timestamps are used.

Parameters:
  • matches ([str]) – List of matches to match which metrics to delete

  • start (rfc3339 or unix_timestamp) – timestamp from which to start deleting

  • end (rfc3339 or unix_timestamp) – timestamp until which to delete

list(disable_rbac=True)

List metric names.

Parameters:

disable_rbac (boolean) – Disables rbac injection if set to True

query(query, disable_rbac=True)

Send a query to prometheus.

The query can be any PromQL query. Labels for enforcing rbac will be added to all of the metric name inside the query. Having labels as part of a query is allowed.

A call like this: query(“sum(name1) - sum(name2{label1=’value’})”) will result in a query string like this: “sum(name1{rbac=’rbac_value’}) - sum(name2{label1=’value’, rbac=’rbac_value’})”

Parameters:
  • query (str) – Custom query string

  • disable_rbac (boolean) – Disables rbac injection if set to True

show(name, disable_rbac=True)

Show current values for metrics of a specified name.

Parameters:

disable_rbac (boolean) – Disables rbac injection if set to True

snapshot()

Create a snapshot of the current data.