Beispiel #1
0
    def _update_metric_collection_settings(self, ladCfg):
        """
        Update mdsd_config_xml_tree for Azure Portal metric collection. The mdsdCfg performanceCounters element contains
        an array of metric definitions; this method passes each definition to its provider's AddMetric method, which is
        responsible for configuring the provider to deliver the metric to mdsd and for updating the mdsd config as
        required to expect the metric to arrive. This method also builds the necessary aggregation queries (from the
        metrics.metricAggregation array) that grind the ingested data and push it to the WADmetric table.
        :param ladCfg: ladCfg object from extension config
        :return: None
        """
        metrics = LadUtil.getPerformanceCounterCfgFromLadCfg(ladCfg)
        if not metrics:
            return

        counter_to_table = {}
        local_tables = set()

        # Add each metric
        for metric in metrics:
            if metric['type'] == 'builtin':
                local_table_name = BuiltIn.AddMetric(metric)
                if local_table_name:
                    local_tables.add(local_table_name)
                    counter_to_table[
                        metric['counterSpecifier']] = local_table_name

        # Finalize; update the mdsd config to be prepared to receive the metrics
        BuiltIn.UpdateXML(self._mdsd_config_xml_tree)

        # Aggregation is done by <LADQuery> within a <DerivedEvent>. If there are no alternate sinks, the DerivedQuery
        # can send output directly to the WAD metrics table. If there *are* alternate sinks, have the LADQuery send
        # output to a new local table, then arrange for additional derived queries to pull from that.
        intervals = LadUtil.getAggregationPeriodsFromLadCfg(ladCfg)
        sinks = LadUtil.getFeatureWideSinksFromLadCfg(ladCfg,
                                                      'performanceCounters')
        for table_name in local_tables:
            for aggregation_interval in intervals:
                if sinks:
                    local_table_name = ProvUtil.MakeUniqueEventName(
                        'aggregationLocal')
                    self._add_derived_event(aggregation_interval,
                                            table_name,
                                            local_table_name,
                                            'Local',
                                            add_lad_query=True)
                    self._handle_alternate_sinks(aggregation_interval, sinks,
                                                 local_table_name)
                else:
                    self._add_derived_event(
                        aggregation_interval,
                        table_name,
                        LadConfigAll._wad_table_name(aggregation_interval),
                        'Central',
                        add_lad_query=True)
    def _update_metric_collection_settings(self, ladCfg):
        """
        Update mdsd_config_xml_tree for Azure Portal metric collection. The mdsdCfg performanceCounters element contains
        an array of metric definitions; this method passes each definition to its provider's AddMetric method, which is
        responsible for configuring the provider to deliver the metric to mdsd and for updating the mdsd config as
        required to expect the metric to arrive. This method also builds the necessary aggregation queries (from the
        metrics.metricAggregation array) that grind the ingested data and push it to the WADmetric table.
        :param ladCfg: ladCfg object from extension config
        :return: None
        """
        metrics = LadUtil.getPerformanceCounterCfgFromLadCfg(ladCfg)
        if not metrics:
            return

        counter_to_table = {}
        local_tables = set()

        # Add each metric
        for metric in metrics:
            if metric['type'] == 'builtin':
                local_table_name = BuiltIn.AddMetric(metric)
                if local_table_name:
                    local_tables.add(local_table_name)
                    counter_to_table[metric['counterSpecifier']] = local_table_name

        # Finalize; update the mdsd config to be prepared to receive the metrics
        BuiltIn.UpdateXML(self._mdsd_config_xml_tree)

        # Aggregation is done by <LADQuery> within a <DerivedEvent>. If there are no alternate sinks, the DerivedQuery
        # can send output directly to the WAD metrics table. If there *are* alternate sinks, have the LADQuery send
        # output to a new local table, then arrange for additional derived queries to pull from that.
        intervals = LadUtil.getAggregationPeriodsFromLadCfg(ladCfg)
        sinks = LadUtil.getFeatureWideSinksFromLadCfg(ladCfg, 'performanceCounters')
        for table_name in local_tables:
            for aggregation_interval in intervals:
                if sinks:
                    local_table_name = ProvUtil.MakeUniqueEventName('aggregationLocal')
                    self._add_derived_event(aggregation_interval, table_name,
                                            local_table_name,
                                            'Local', add_lad_query=True)
                    self._handle_alternate_sinks(aggregation_interval, sinks, local_table_name)
                else:
                    self._add_derived_event(aggregation_interval, table_name,
                                            LadConfigAll._wad_table_name(aggregation_interval),
                                            'Central', add_lad_query=True)
    def _update_metric_collection_settings(self, ladCfg, namespaces):
        """
        Update mdsd_config_xml_tree for Azure Portal metric collection. This method builds the necessary aggregation queries
        that grind the ingested data and push it to the WADmetric table.
        :param ladCfg: ladCfg object from extension config
        :param namespaces: list of telegraf plugins sources obtained after parsing lad metrics config
        :return: None
        """

        # Aggregation is done by <LADQuery> within a <DerivedEvent>. If there are no alternate sinks, the DerivedQuery
        # can send output directly to the WAD metrics table. If there *are* alternate sinks, have the LADQuery send
        # output to a new local table, then arrange for additional derived queries to pull from that.

        intervals = LadUtil.getAggregationPeriodsFromLadCfg(ladCfg)
        sinks = LadUtil.getFeatureWideSinksFromLadCfg(ladCfg,
                                                      'performanceCounters')
        for plugin in namespaces:
            lad_specific_storage_plugin = "storage-" + plugin
            for aggregation_interval in intervals:
                if sinks:
                    local_table_name = ProvUtil.MakeUniqueEventName(
                        'aggregationLocal')
                    self._add_derived_event(aggregation_interval,
                                            lad_specific_storage_plugin,
                                            local_table_name,
                                            'Local',
                                            add_lad_query=True)
                    self._handle_alternate_sinks(aggregation_interval, sinks,
                                                 local_table_name)
                else:
                    self._add_derived_event(
                        aggregation_interval,
                        lad_specific_storage_plugin,
                        LadConfigAll._wad_table_name(aggregation_interval),
                        'Central',
                        add_lad_query=True)
 def test_getAggregationPeriodsFromLadCfg(self):
     periods = LadUtil.getAggregationPeriodsFromLadCfg(self.valid_config)
     self.assertEqual(len(periods), 2)
     self.assertIn('PT5M', periods)
     self.assertIn('PT1H', periods)
 def test_getAggregationPeriodsFromLadCfg(self):
     periods = LadUtil.getAggregationPeriodsFromLadCfg(self.valid_config)
     self.assertEqual(len(periods), 2)
     self.assertIn('PT5M', periods)
     self.assertIn('PT1H', periods)