static String insertTagInToMetricName(String tag, String metricName, String prefix) {
    String sepExpr = "\\.";
    String seperator = ".";
    if (metricName.indexOf(EXTERNAL_PATH_SEP) != -1) {
      sepExpr = Character.toString(EXTERNAL_PATH_SEP);
      seperator = sepExpr;
    }
    String prefixSep = prefix.contains(".") ? "\\." : "" + EXTERNAL_PATH_SEP;

    // Remove separator if any
    if (prefix.substring(prefix.length() - 1).equals(prefixSep)) {
      prefix = prefix.substring(0, prefix.length() - 1);
    }
    int pos = prefix.split(prefixSep).length - 1;
    String[] parts = metricName.split(sepExpr);
    StringBuilder sb = new StringBuilder();

    for (int i = 0; i < parts.length; i++) {
      sb.append(parts[i]);
      if (i < parts.length - 1) {
        sb.append(seperator);
      }
      if (i == pos) { // append the tag
        sb.append(tag);
        sb.append(seperator);
      }
    }
    return sb.toString();
  }
Returns tag inserted metric name after the prefix.
@param tag E.g.: client
@param metricName : rpc.rpc.CallQueueLength Or metrics/rpc/CallQueueLen
@param prefix : rpc.rpc
@return rpc.rpc.client.CallQueueLength Or metrics/rpc/client/CallQueueLen
ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java