private void populateResource(Resource resource, TimelineMetric metric,
                                  TemporalInfo temporalInfo) {
      String metric_name = metric.getMetricName();
      Set<String> propertyIdSet = metrics.get(metric_name);
      List<String> parameterList  = new LinkedList<>();

      if (propertyIdSet == null) {
        for (Map.Entry<String, Set<String>> entry : metrics.entrySet()) {
          String key = entry.getKey();
          Pattern pattern = Pattern.compile(key);
          Matcher matcher = pattern.matcher(metric_name);

          if (matcher.matches()) {
            propertyIdSet = entry.getValue();
            // get parameters
            for (int i = 0; i < matcher.groupCount(); ++i) {
              parameterList.add(matcher.group(i + 1));
            }
            break;
          }
        }
      }
      if (propertyIdSet != null) {
        Map<String, PropertyInfo> metricsMap = getComponentMetrics().get(getOverridenComponentName(resource));
        if (metricsMap != null) {
          for (String propertyId : propertyIdSet) {
            if (propertyId != null) {
//              propertyId = postProcessPropertyId(propertyId, getComponentName(resource));
              if (metricsMap.containsKey(propertyId)){
                if (containsArguments(propertyId)) {
                  int i = 1;
                  //if nothing to substitute in metric name, then
                  //substitute $1 with an instanceId
                  if (!parameterList.isEmpty())  {
                    for (String param : parameterList) {
                      propertyId = substituteArgument(propertyId, "$" + i, param);
                      ++i;
                    }
                  } else {
                    propertyId = substituteArgument(propertyId, "$1", metric.getInstanceId());
                  }
                }else {
                  if(metric.getInstanceId() != null){
                    //instanceId "CHANNEL.ch1"
                    String instanceId = metric.getInstanceId();
                    instanceId = instanceId.matches("^\\w+\\..+$") ? instanceId.split("\\.")[1]:"";
                    //propertyId "metrics/flume/flume/CHANNEL/ch1/[ChannelCapacity]"
                    if(!propertyId.contains(instanceId)) continue;
                  }
                }
                Object value = getValue(metric, temporalInfo);
                if (value != null && !containsArguments(propertyId)) {
                  resource.setProperty(propertyId, value);
                }
              }
            }
          }
        }
      }
    }
Populate the associated resources by making a call to the Metrics
service.

@return a collection of populated resources
@throws SystemException if unable to populate the resources
ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProvider.java