private String resolveProtocol(Cluster cluster, String hostname) {
    String protocol = DEFAULT_PROTOCOL;
    if (metricsProperties.containsKey(PORT_CONFIG_TYPE_PROPERTY) && metricsProperties.containsKey(HTTPS_PROTOCOL_PROPERTY)) {
      String configType = metricsProperties.get(PORT_CONFIG_TYPE_PROPERTY);
      String propertyName = metricsProperties.get(HTTPS_PROTOCOL_PROPERTY);
      String value = getPropertyValueByNameAndConfigType(propertyName, configType, cluster, hostname);
      if (value != null) {
        return HTTPS_PROTOCOL;
      }
    }
    if (metricsProperties.containsKey(PROTOCOL_OVERRIDE_PROPERTY)) {
      protocol = metricsProperties.get(PROTOCOL_OVERRIDE_PROPERTY).toLowerCase();
      if (!protocol.equals(HTTP_PROTOCOL) && !protocol.equals(HTTPS_PROTOCOL)) {
        String message = String.format(
            "Unsupported protocol type %s, falling back to %s",
            protocol, DEFAULT_PROTOCOL);
        LOG.warn(message);
        protocol = DEFAULT_PROTOCOL;
      }
    } else {
      protocol = DEFAULT_PROTOCOL;
    }
    return protocol;
  }
if HTTPS_PROTOCOL_PROPERTY is present in metrics properties then checks if it is present in PORT_CONFIG_TYPE_PROPERTY and returns "https" if it is.

Otherwise extracts protocol type from metrics properties. If no protocol is defined,
uses default protocol.
ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/RestMetricsPropertyProvider.java