in src/azinsights/collector/PrometheusMetricCollector.py [0:0]
def query_prometheus(self, metric_name: str):
'''Performs an http request to the specified Prometheus DB url
in configuration file (i.e. config.ini) for the specific metric.
Parameters
----------
metric_name : str
Name of the metric being queried for
Returns
-------
response : requests.Response
Http response associated with querying Prometheus for the metric
'''
logger.debug('query_prometheus')
response = self._session.get('{0}/api/v1/query'.format(self._url), params={'query': metric_name})
if (not PrometheusMetricCollector.successful_response(response)):
logger.warning(
'Request received status code {0} with content: {1} when querying for {2}.'.format(
response.status_code,
response.content,
metric_name)
)
return response