protected boolean checkAuthorizationForMetrics(Set<Resource> resources, String clusterNamePropertyId) throws AuthorizationException {
    String resType = null;

    // Get the Type
    resType = getResourceTypeFromResources(resources);
    if (resType == null) {
      return false;
    }

    // Get the cluster Id.
    Set<Long> clusterResIds = getClustersResourceId(resources, clusterNamePropertyId);
    if (clusterResIds.size() == 0) {
      return false;
    }

    if(LOG.isDebugEnabled()) {
      LOG.debug("Retrieved cluster's Resource Id = {}, Resource Type = {}", clusterResIds, resType);
    }
    Iterator<Long> clusResIdsItr = clusterResIds.iterator();
    while (clusResIdsItr.hasNext()) {
      Long clusResId = clusResIdsItr.next();
      Resource.InternalType resTypeVal = Resource.InternalType.valueOf(resType);
      switch (resTypeVal) {
        case Cluster:
          if (!AuthorizationHelper.isAuthorized(ResourceType.CLUSTER, clusResId, EnumSet.of(RoleAuthorization.CLUSTER_VIEW_METRICS))) {
            throw new AuthorizationException("The authenticated user does not have authorization to view cluster metrics");
          }
          break;
        case Host:
          if (!AuthorizationHelper.isAuthorized(ResourceType.CLUSTER, clusResId, EnumSet.of(RoleAuthorization.HOST_VIEW_METRICS))) {
            throw new AuthorizationException("The authenticated user does not have authorization to view Host metrics");
          }
          break;
        case Component :
          if (!AuthorizationHelper.isAuthorized(ResourceType.CLUSTER, clusResId, EnumSet.of(RoleAuthorization.SERVICE_VIEW_METRICS))) {
            throw new AuthorizationException("The authenticated user does not have authorization to view Service metrics");
          }
          break;
        case HostComponent:
          if (!AuthorizationHelper.isAuthorized(ResourceType.CLUSTER, clusResId, EnumSet.of(RoleAuthorization.SERVICE_VIEW_METRICS))) {
            throw new AuthorizationException("The authenticated user does not have authorization to view Service metrics");
          }
          break;
        default:
          LOG.error("Unsuported Resource Type for Metrics");
          return false;
      }
    }
    return true;
  }
Check the User's authorization for retrieving the Metrics.

@param resources Set of Resources.
@param clusterNamePropertyId ClusterName PropertyId.
@return boolean
@throws AuthorizationException
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractPropertyProvider.java