Prometheus module.

exception wmflib.prometheus.PrometheusError[source]

Bases: wmflib.exceptions.WmflibError

Custom exception class for errors of this module.

class wmflib.prometheus.Prometheus[source]

Bases: object

Class to interact with the Prometheus server.

Initialize the instance.

query(query: str, site: str, *, timeout: Optional[Union[float, int]] = 10) List[Dict][source]

Perform a generic query.

  • query (str) – a prometheus query

  • site (str) – The site to use for queries. Must be one of wmflib.constants.ALL_DATACENTERS

  • timeout (float, int, None, optional) – How many seconds to wait for the prometheus to send data before giving up, as a float or int. Alternatively None to indicate an infinite timeout.


returns an empty list if there are no results otherwise return a list of results of the form: {‘metric’: {}, ‘value’: [$timestamp, $value]}

Return type



wmflib.prometheus.PrometheusError – on error