(self, endpoint, pFormat=PrometheusFormat.PROTOBUF, headers=None, instance=None)
Polls the metrics from the prometheus metrics endpoint provided.
        Defaults to the protobuf format, but can use the formats specified by
        the PrometheusFormat class.
        Custom headers can be added to the default headers.

        Returns a valid requests.Response, raise requests.HTTPError if the status code of the requests.Response
        isn't valid - see response.raise_for_status()

        The caller needs to close the requests.Response

        :param endpoint: string url endpoint
        :param pFormat: the preferred format defined in PrometheusFormat
        :param headers: extra headers
        :return: requests.Response
Polls the metrics from the prometheus metrics endpoint provided.
        Defaults to the protobuf format, but can use the formats specified by
        the PrometheusFormat class.
        Custom headers can be added to the default headers.
Polls the metrics from the prometheus metrics endpoint provided . Defaults to the protobuf format but can use the formats specified by the PrometheusFormat class . Custom headers can be added to the default headers .
def poll(self, endpoint, pFormat=PrometheusFormat.PROTOBUF, headers=None, instance=None):
        """
        Polls the metrics from the prometheus metrics endpoint provided.
        Defaults to the protobuf format, but can use the formats specified by
        the PrometheusFormat class.
        Custom headers can be added to the default headers.

        Returns a valid requests.Response, raise requests.HTTPError if the status code of the requests.Response
        isn't valid - see response.raise_for_status()

        The caller needs to close the requests.Response

        :param endpoint: string url endpoint
        :param pFormat: the preferred format defined in PrometheusFormat
        :param headers: extra headers
        :return: requests.Response
        """
        if headers is None:
            headers = {}
        if 'Accept-Encoding' not in headers:
            headers['Accept-Encoding'] = 'gzip'
        if pFormat == PrometheusFormat.PROTOBUF:
            headers['accept'] = (
                'application/vnd.google.protobuf; ' 'proto=io.prometheus.client.MetricFamily; ' 'encoding=delimited'
            )
        handler = self.get_http_handler(endpoint, instance)
        if (
            endpoint.startswith('https')
            and not handler.ignore_tls_warning
            and not is_affirmative(handler.options.get('ssl_verify', True))
        ):
            self.log.warning(u'An unverified HTTPS request is being made to %s', endpoint)

        try:
            response = handler.get(endpoint, extra_headers=headers, stream=False)
        except requests.exceptions.SSLError:
            self.log.error("Invalid SSL settings for requesting %s endpoint", endpoint)
            raise
        except IOError:
            if self.health_service_check:
                self._submit_service_check(
                    "{}{}".format(self.NAMESPACE, ".prometheus.health"),
                    AgentCheck.CRITICAL,
                    tags=["endpoint:" + endpoint],
                )
            raise
        try:
            response.raise_for_status()
            if self.health_service_check:
                self._submit_service_check(
                    "{}{}".format(self.NAMESPACE, ".prometheus.health"), AgentCheck.OK, tags=["endpoint:" + endpoint]
                )
            return response
        except requests.HTTPError:
            response.close()
            if self.health_service_check:
                self._submit_service_check(
                    "{}{}".format(self.NAMESPACE, ".prometheus.health"),
                    AgentCheck.CRITICAL,
                    tags=["endpoint:" + endpoint],
                )
            raise
def poll ( self , endpoint , pFormat = PrometheusFormat . PROTOBUF , headers = None , instance = None ) : if headers is None : headers = { } if 'Accept-Encoding' not in headers : headers [ 'Accept-Encoding' ] = 'gzip' if pFormat == PrometheusFormat . PROTOBUF : headers [ 'accept' ] = ( 'application/vnd.google.protobuf; ' 'proto=io.prometheus.client.MetricFamily; ' 'encoding=delimited' ) handler = self . get_http_handler ( endpoint , instance ) if ( endpoint . startswith ( 'https' ) and not handler . ignore_tls_warning and not is_affirmative ( handler . options . get ( 'ssl_verify' , True ) ) ) : self . log . warning ( u'An unverified HTTPS request is being made to %s' , endpoint ) try : response = handler . get ( endpoint , extra_headers = headers , stream = False ) except requests . exceptions . SSLError : self . log . error ( "Invalid SSL settings for requesting %s endpoint" , endpoint ) raise except IOError : if self . health_service_check : self . _submit_service_check ( "{}{}" . format ( self . NAMESPACE , ".prometheus.health" ) , AgentCheck . CRITICAL , tags = [ "endpoint:" + endpoint ] , ) raise try : response . raise_for_status ( ) if self . health_service_check : self . _submit_service_check ( "{}{}" . format ( self . NAMESPACE , ".prometheus.health" ) , AgentCheck . OK , tags = [ "endpoint:" + endpoint ] ) return response except requests . HTTPError : response . close ( ) if self . health_service_check : self . _submit_service_check ( "{}{}" . format ( self . NAMESPACE , ".prometheus.health" ) , AgentCheck . CRITICAL , tags = [ "endpoint:" + endpoint ] , ) raise