prometheus¶
Prometheus module.
-
exception
spicerack.prometheus.
PrometheusError
[source]¶ Bases:
spicerack.exceptions.SpicerackError
Custom exception class for errors of this module.
-
class
spicerack.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.
- Parameters
query (str) -- a prometheus query
site (str) -- The site to use for queries. Must be one of
spicerack.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
returns an empty list if there are no results otherwise return a list of results of the form: {'metric': {}, 'value': [$timestamp, $value]}
- Return type
- Raises
spicerack.prometheus.PrometheusError -- on error
-