Ejemplo n.º 1
0
 def setUp(self):
     super(MonascaCollectorTest, self).setUp()
     self.conf.set_override('collector', 'monasca', 'collect')
     conf = {
         'metrics': {
             'metric_one': {
                 'unit': 'GiB',
                 'groupby': ['project_id'],
                 'extra_args': {
                     'aggregation_method': 'max',
                 },
             },
             'metric_two': {
                 'unit': 'MiB',
                 'groupby': ['project_id'],
                 'extra_args': {
                     'aggregation_method': 'max',
                     'forced_project_id': 'project_x'
                 },
             },
         }
     }
     with mock.patch(
             'cloudkitty.collector.monasca.'
             'MonascaCollector._get_monasca_endpoint',
             return_value='http://noop'):
         self.collector = mon_collector.MonascaCollector(
             transformer.get_transformers(),
             period=3600,
             conf=conf,
         )
Ejemplo n.º 2
0
 def get_metadata(cls, resource_type, transformers, conf):
     args = {
         'transformers': transformer.get_transformers(),
         'period': conf['period']
     }
     tmp = cls(**args)
     return tmp._get_metadata(resource_type, transformers, conf)
Ejemplo n.º 3
0
 def get_metadata(cls, resource_type, transformers):
     args = {
         'transformers': transformer.get_transformers(),
         'period': CONF.collect.period
     }
     tmp = cls(**args)
     return tmp._get_metadata(resource_type, transformers)
Ejemplo n.º 4
0
 def setUp(self):
     super(PrometheusCollectorTest, self).setUp()
     self._tenant_id = samples.TENANT
     args = {
         'period': 3600,
         'scope_key': 'namespace',
         'conf': {
             'metrics': {
                 'http_requests_total': {
                     'unit': 'instance',
                     'groupby': [
                         'foo',
                         'bar',
                     ],
                     'metadata': [
                         'code',
                         'instance',
                     ],
                     'extra_args': {
                         'aggregation_method': 'avg',
                     },
                 },
             }
         }
     }
     transformers = transformer.get_transformers()
     self.collector = prometheus.PrometheusCollector(transformers, **args)
Ejemplo n.º 5
0
 def setUp(self):
     super(PrometheusCollectorTest, self).setUp()
     self._tenant_id = samples.TENANT
     args = {
         'period': 3600,
         'scope_key': 'namespace',
         'conf': {
             'metrics': {
                 'http_requests_total': {
                     'unit': 'instance',
                     'groupby': [
                         'foo',
                         'bar',
                     ],
                     'metadata': [
                         'code',
                         'instance',
                     ],
                     'extra_args': {
                         'aggregation_method': 'avg',
                     },
                 },
             }
         }
     }
     transformers = transformer.get_transformers()
     self.collector = prometheus.PrometheusCollector(transformers, **args)
Ejemplo n.º 6
0
    def __init__(self, worker_id):
        self._worker_id = worker_id
        super(Orchestrator, self).__init__(self._worker_id)

        self.fetcher = driver.DriverManager(
            FETCHERS_NAMESPACE,
            CONF.fetcher.backend,
            invoke_on_load=True,
        ).driver

        transformers = transformer.get_transformers()
        self.collector = collector.get_collector(transformers)
        self.storage = storage.get_storage()
        self._state = state.StateManager()

        # RPC
        self.server = None
        self._rating_endpoint = RatingEndpoint(self)
        self._init_messaging()

        # DLM
        self.coord = coordination.get_coordinator(
            CONF.orchestrator.coordination_url,
            uuidutils.generate_uuid().encode('ascii'))
        self.coord.start(start_heart=True)
Ejemplo n.º 7
0
def get_collector(transformers=None):
    if not transformers:
        transformers = transformer.get_transformers()
    collector_args = {"period": CONF.collect.period, "transformers": transformers}
    collector = driver.DriverManager(
        COLLECTORS_NAMESPACE, CONF.collect.collector, invoke_on_load=True, invoke_kwds=collector_args
    ).driver
    return collector
Ejemplo n.º 8
0
def get_collector(transformers=None):
    if not transformers:
        transformers = transformer.get_transformers()
    collector_args = {
        'period': METRICS_CONF['period'],
        'transformers': transformers}
    collector = driver.DriverManager(
        COLLECTORS_NAMESPACE,
        METRICS_CONF['collector'],
        invoke_on_load=True,
        invoke_kwds=collector_args).driver
    return collector
Ejemplo n.º 9
0
    def setUp(self):
        super(GnocchiCollectorTest, self).setUp()
        self._tenant_id = samples.TENANT
        self.conf.set_override('collector', 'gnocchi', 'collect')
        self.conf.set_override('gnocchi_auth_type', 'basic',
                               'collector_gnocchi')

        self.collector = gnocchi.GnocchiCollector(
            transformer.get_transformers(),
            period=3600,
            conf=samples.DEFAULT_METRICS_CONF,
        )
Ejemplo n.º 10
0
    def setUp(self):
        super(GnocchiCollectorTest, self).setUp()
        self._tenant_id = samples.TENANT
        self.conf.set_override('collector', 'gnocchi', 'collect')
        self.conf.set_override(
            'gnocchi_auth_type', 'basic', 'collector_gnocchi')

        self.collector = gnocchi.GnocchiCollector(
            transformer.get_transformers(),
            period=3600,
            conf=samples.DEFAULT_METRICS_CONF,
        )
Ejemplo n.º 11
0
def get_collector(transformers=None):
    metrics_conf = ck_utils.load_conf(CONF.collect.metrics_conf)
    if not transformers:
        transformers = transformer.get_transformers()
    collector_args = {
        'period': CONF.collect.period,
        'transformers': transformers,
    }
    collector_args.update({'conf': metrics_conf})
    return driver.DriverManager(COLLECTORS_NAMESPACE,
                                CONF.collect.collector,
                                invoke_on_load=True,
                                invoke_kwds=collector_args).driver
Ejemplo n.º 12
0
def get_collector_metadata():
    """Return dict of metadata.

    Results are based on enabled collector and services in CONF.
    """
    transformers = transformer.get_transformers()
    collector = driver.DriverManager(
        COLLECTORS_NAMESPACE, METRICS_CONF['collector'],
        invoke_on_load=False).driver
    metadata = {}
    for service in METRICS_CONF['services']:
        metadata[service] = collector.get_metadata(service, transformers)
    return metadata
Ejemplo n.º 13
0
def get_collector(transformers=None):
    metrics_conf = ck_utils.load_conf(CONF.collect.metrics_conf)
    if not transformers:
        transformers = transformer.get_transformers()
    collector_args = {
        'period': CONF.collect.period,
        'transformers': transformers,
    }
    collector_args.update({'conf': metrics_conf})
    return driver.DriverManager(
        COLLECTORS_NAMESPACE,
        CONF.collect.collector,
        invoke_on_load=True,
        invoke_kwds=collector_args).driver
Ejemplo n.º 14
0
def get_metrics_based_collector_metadata():
    """Return dict of metadata.

    Results are based on enabled collector and metrics in CONF.
    """
    metrics_conf = ck_utils.get_metrics_conf(CONF.collect.metrics_conf)
    transformers = transformer.get_transformers()
    collector = get_collector_without_invoke()
    metadata = {}
    if 'metrics' in metrics_conf:
        for metric in metrics_conf.get('metrics', {}):
            metadata[metric] = collector.get_metadata(
                metric,
                transformers,
                metrics_conf,
            )
    return metadata
Ejemplo n.º 15
0
 def setUp(self):
     super(PrometheusCollectorTest, self).setUp()
     self._tenant_id = samples.TENANT
     args = {
         'period': 3600,
         'conf': {
             'metrics': {
                 'http_requests_total': {
                     'unit': 'instance',
                     'extra_args': {
                         'query': 'http_request_total[$period]',
                     },
                 },
             }
         }
     }
     transformers = transformer.get_transformers()
     self.collector = prometheus.PrometheusCollector(transformers, **args)
Ejemplo n.º 16
0
def get_metrics_based_collector_metadata():
    """Return dict of metadata.

    Results are based on enabled collector and metrics in CONF.
    """
    metrics_conf = ck_utils.load_conf(CONF.collect.metrics_conf)
    transformers = transformer.get_transformers()
    collector = get_collector_without_invoke()
    metadata = {}
    if 'metrics' in metrics_conf:
        for metric_name, metric in metrics_conf.get('metrics', {}).items():
            alt_name = metric.get('alt_name', metric_name)
            metadata[alt_name] = collector.get_metadata(
                metric_name,
                transformers,
                metrics_conf,
            )
    return metadata
Ejemplo n.º 17
0
    def __init__(self):
        # Tenant fetcher
        self.fetcher = driver.DriverManager(FETCHERS_NAMESPACE,
                                            CONF.tenant_fetcher.backend,
                                            invoke_on_load=True).driver

        self.transformers = transformer.get_transformers()
        self.collector = collector.get_collector(self.transformers)
        self.storage = storage.get_storage(self.collector)

        # RPC
        self.server = None
        self._rating_endpoint = RatingEndpoint(self)
        self._init_messaging()

        # DLM
        self.coord = coordination.get_coordinator(
            CONF.orchestrator.coordination_url,
            str(uuid.uuid4()).encode('ascii'))
        self.coord.start()
Ejemplo n.º 18
0
    def __init__(self):
        self.fetcher = driver.DriverManager(
            FETCHERS_NAMESPACE,
            METRICS_CONF['fetcher'],
            invoke_on_load=True
        ).driver

        transformers = transformer.get_transformers()
        self.collector = collector.get_collector(transformers)
        self.storage = storage.get_storage()

        # RPC
        self.server = None
        self._rating_endpoint = RatingEndpoint(self)
        self._init_messaging()

        # DLM
        self.coord = coordination.get_coordinator(
            CONF.orchestrator.coordination_url,
            uuidutils.generate_uuid().encode('ascii'))
        self.coord.start()
Ejemplo n.º 19
0
    def __init__(self):
        # Tenant fetcher
        self.fetcher = driver.DriverManager(
            FETCHERS_NAMESPACE,
            CONF.tenant_fetcher.backend,
            invoke_on_load=True).driver

        self.transformers = transformer.get_transformers()
        self.collector = collector.get_collector(self.transformers)
        self.storage = storage.get_storage(self.collector)

        # RPC
        self.server = None
        self._rating_endpoint = RatingEndpoint(self)
        self._init_messaging()

        # DLM
        self.coord = coordination.get_coordinator(
            CONF.orchestrator.coordination_url,
            str(uuid.uuid4()).encode('ascii'))
        self.coord.start()
Ejemplo n.º 20
0
    def __init__(self):
        # Tenant fetcher
        self.fetcher = driver.DriverManager(FETCHERS_NAMESPACE,
                                            CONF.tenant_fetcher.backend,
                                            invoke_on_load=True).driver

        self.transformers = transformer.get_transformers()
        self.collector = collector.get_collector(self.transformers)
        self.storage = storage.get_storage(self.collector)

        # RPC
        self.server = None
        self._rating_endpoint = RatingEndpoint(self)
        self._init_messaging()

        # DLM
        self.coord = coordination.get_coordinator(
            CONF.orchestrator.coordination_url,
            uuidutils.generate_uuid().encode('ascii'))
        self.coord.start()

        self._period = METRICS_CONF['period']
        self._wait_time = METRICS_CONF['wait_periods'] * self._period
Ejemplo n.º 21
0
 def get_metadata(cls, resource_type, transformers, conf):
     args = {
         'transformers': transformer.get_transformers(),
         'period': conf['period']}
     tmp = cls(**args)
     return tmp._get_metadata(resource_type, transformers, conf)