(self, metric, scraper_config)
Quota and current usage by resource type.
Quota and current usage by resource type.
Quota and current usage by resource type .
def kube_resourcequota(self, metric, scraper_config):
        """Quota and current usage by resource type."""
        metric_base_name = scraper_config['namespace'] + '.resourcequota.{}.{}'
        suffixes = {'used': 'used', 'hard': 'limit'}
        if metric.type in METRIC_TYPES:
            for sample in metric.samples:
                mtype = sample[self.SAMPLE_LABELS].get("type")
                resource = sample[self.SAMPLE_LABELS].get("resource")
                tags = (
                    self._label_to_tags("namespace", sample[self.SAMPLE_LABELS], scraper_config)
                    + self._label_to_tags("resourcequota", sample[self.SAMPLE_LABELS], scraper_config)
                    + scraper_config['custom_tags']
                )
                self.gauge(metric_base_name.format(resource, suffixes[mtype]), sample[self.SAMPLE_VALUE], tags)
        else:
            self.log.error("Metric type %s unsupported for metric %s", metric.type, metric.name)
def kube_resourcequota ( self , metric , scraper_config ) : metric_base_name = scraper_config [ 'namespace' ] + '.resourcequota.{}.{}' suffixes = { 'used' : 'used' , 'hard' : 'limit' } if metric . type in METRIC_TYPES : for sample in metric . samples : mtype = sample [ self . SAMPLE_LABELS ] . get ( "type" ) resource = sample [ self . SAMPLE_LABELS ] . get ( "resource" ) tags = ( self . _label_to_tags ( "namespace" , sample [ self . SAMPLE_LABELS ] , scraper_config ) + self . _label_to_tags ( "resourcequota" , sample [ self . SAMPLE_LABELS ] , scraper_config ) + scraper_config [ 'custom_tags' ] ) self . gauge ( metric_base_name . format ( resource , suffixes [ mtype ] ) , sample [ self . SAMPLE_VALUE ] , tags ) else : self . log . error ( "Metric type %s unsupported for metric %s" , metric . type , metric . name )