code: public static String stripInstanceAndHost(String metricsName) {
      String[] pieces = metricsName.split("\\.");
      Preconditions.checkArgument(pieces.length > 1, "Incorrect metrics name: %s.", metricsName);
  
      // Master metrics doesn't have hostname included.
      if (!pieces[0].equals(MetricsSystem.InstanceType.MASTER.toString())) {
        pieces[1] = null;
      }
      pieces[0] = null;
      return Joiner.on(".").skipNulls().join(pieces);
    }
docs: Removes the instance and host from the given metric name, returning the result.
  
  @param metricsName the long metrics name with instance and host name
  @return the metrics name without instance and host name