Exemplo n.º 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)
Exemplo n.º 2
0
def AddMetric(counterSpec):
    try:
        metric = BuiltinMetric(counterSpec)
    except ProvUtil.ParseException as ex:
        print "Couldn't create metric: ", ex
        return

    # (class, instanceId, sampleRate) -> [ metric ]
    # Given a class, instance within that class, and sample rate, we have a list of the requested metrics
    # matching those constraints. For that set of constraints, we also have a common eventName, the local
    # table where we store the collected metrics.

    key = (metric.Class(), metric.InstanceId(), metric.SampleRate())
    if key not in _eventNames:
        _eventNames[key] = ProvUtil.MakeUniqueEventName('builtin')
    _metrics[key].append(metric)
Exemplo n.º 3
0
def AddMetric(counter_spec):
    """
    Add a metric to the list of metrics to be collected.
    :param counter_spec: The specification of a builtin metric.
    :return: the generated local-table name in mdsd into which this metric will be fetched, or None
    """
    global _metrics, _eventNames
    try:
        metric = BuiltinMetric(counter_spec)
    except ProvUtil.ParseException as ex:
        print "Couldn't create metric: ", ex
        return None

    # (class, instanceId, sampleRate) -> [ metric ]
    # Given a class, instance within that class, and sample rate, we have a list of the requested metrics
    # matching those constraints. For that set of constraints, we also have a common eventName, the local
    # table where we store the collected metrics.

    key = (metric.class_name(), metric.condition(), metric.sample_rate())
    if key not in _eventNames:
        _eventNames[key] = ProvUtil.MakeUniqueEventName('builtin')
    _metrics[key].append(metric)
    return _eventNames[key]
    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)