lib/vmpooler/metrics/promstats.rb
# locate a metric and check/interpet the sub-fields.
locate a metric and check/interpet the sub-fields.
locate a metric and check / interpet the sub - fields .
def find_metric(label)
        sublabels = label.split('.')
        metric_key = sublabels.shift.to_sym
        raise("Invalid Metric #{metric_key} for #{label}") unless @p_metrics.key? metric_key
        metric_spec = @p_metrics[metric_key]
        raise("Invalid Component #{component} for #{metric_key}") if (metric_spec[:torun] & @torun).nil?
        metric = metric_spec.clone
        if metric.key? :metric_suffixes
          metric_subkey = sublabels.shift.to_sym
          raise("Invalid Metric #{metric_key}_#{metric_subkey} for #{label}") unless metric[:metric_suffixes].key? metric_subkey.to_sym
          metric[:metric_name] = "#{@prometheus_prefix}_#{metric_key}_#{metric_subkey}"
        else
          metric[:metric_name] = "#{@prometheus_prefix}_#{metric_key}"
        end
        if metric.key? :param_labels
          metric[:labels] = {}
          if metric[:param_labels].length == 1
            metric[:labels][metric[:param_labels].first] = sublabels.join('.')
          else
            metric[:param_labels].reverse_each do |param_label|
              metric[:labels][param_label] = sublabels.pop(1).first
            end
          end
        end
        metric
      end
def find_metric ( label ) sublabels = label . split ( '.' ) metric_key = sublabels . shift . to_sym raise ( "Invalid Metric #{metric_key} for #{label}" ) unless @p_metrics . key? metric_key metric_spec = @p_metrics [ metric_key ] raise ( "Invalid Component #{component} for #{metric_key}" ) if ( metric_spec [ :torun ] & @torun ) . nil? metric = metric_spec . clone if metric . key? :metric_suffixes metric_subkey = sublabels . shift . to_sym raise ( "Invalid Metric #{metric_key}_#{metric_subkey} for #{label}" ) unless metric [ :metric_suffixes ] . key? metric_subkey . to_sym metric [ :metric_name ] = "#{@prometheus_prefix}_#{metric_key}_#{metric_subkey}" else metric [ :metric_name ] = "#{@prometheus_prefix}_#{metric_key}" end if metric . key? :param_labels metric [ :labels ] = { } if metric [ :param_labels ] . length == 1 metric [ :labels ] [ metric [ :param_labels ] . first ] = sublabels . join ( '.' ) else metric [ :param_labels ] . reverse_each do | param_label | metric [ :labels ] [ param_label ] = sublabels . pop ( 1 ) . first end end end metric end
locate a metric and check/interpet the sub-fields.
locate a metric and check / interpet the sub - fields .
# Check if we are looking for a parameter value at last element. # Special case processing here - if there is only one parameter label then make sure # we append all of the remaining contents of the metric with "." separators to ensure # we get full nodenames (e.g. for Migration to node operations)
label