// GetMetricConfigItem returns value of configuration item specified by `name` defined in Metrics Config
// Notes: GetMetricConfigItem() will be helpful to access and get configuration item's value in CollectMetrics()
// (Plugin Global Config is merged into Metric Config)
func GetMetricConfigItem(metric plugin.MetricType, name string) (interface{}, error) {
	if metric.Config() != nil && len(metric.Config().Table()) > 0 {
		if item, ok := metric.Config().Table()[name]; ok {
			return getConfigItemValue(item)
		}
	}

	return nil, fmt.Errorf("Cannot find %v in Metrics Config", name)
}
// GetMetricConfigItems returns map to values of multiple configuration items defined in Metric Config and specified in 'names' slice
// Notes: GetMetricConfigItems() will be helpful to access and get multiple configuration items' values in CollectMetrics()
// (Plugin Global Config is merged into Metric Config)
func GetMetricConfigItems(metric plugin.MetricType, names []string) (map[string]interface{}, error) {
	result := make(map[string]interface{})

	for _, name := range names {
		if metric.Config() != nil && len(metric.Config().Table()) > 0 {
			item, ok := metric.Config().Table()[name]
			if !ok {
				return nil, fmt.Errorf("Cannot find %v in Metrics Config", name)
			}

			val, err := getConfigItemValue(item)
			if err != nil {
				return nil, err
			}
			result[name] = val
		} else {
			return nil, fmt.Errorf("Cannot find %v in Metrics Config", name)
		}
	}

	return result, nil
}