code: public static MonitoredResource getResource(String projectId, String resourceTypeParam) {
      String resourceType = resourceTypeParam;
      if (Strings.isNullOrEmpty(resourceType)) {
        Resource detectedResourceType = getAutoDetectedResourceType();
        resourceType = detectedResourceType.getKey();
      }
      // Currently, "gae_app" is the supported logging Resource type, but we distinguish
      // between "gae_app_flex", "gae_app_standard" to support zone id, instance name logging on flex
      // VMs.
      // Hence, "gae_app_flex", "gae_app_standard" are trimmed to "gae_app"
      String resourceName = resourceType.startsWith("gae_app") ? "gae_app" : resourceType;
      MonitoredResource.Builder builder =
          MonitoredResource.newBuilder(resourceName).addLabel(Label.ProjectId.getKey(), projectId);
  
      for (Label label : resourceTypeWithLabels.get(resourceType)) {
        String value = getValue(label);
        if (value != null) {
          builder.addLabel(label.getKey(), value);
        }
      }
      return builder.build();
    }
docs: /* Return a self-configured monitored Resource.