code: @POST
      @Consumes(MediaType.APPLICATION_JSON)
      @Produces(MediaType.APPLICATION_JSON)
      @Path("/metrics")
      @Description("Submits externally collected metric data.")
      public Map<String, Object> submitMetrics(@Context HttpServletRequest req, final List<MetricDto> metricDtos) {
          PrincipalUser remoteUser = getRemoteUser(req);
  
          SystemAssert.requireArgument(metricDtos != null, "Cannot submit null timeseries metrics list.");
  
          List<Metric> legalMetrics = new ArrayList<>();
          List<MetricDto> illegalMetrics = new ArrayList<>();
          List<String> errorMessages = new ArrayList<>();
  
          for (MetricDto metricDto : metricDtos) {
              try {
                  Metric metric = new Metric(metricDto.getScope(), metricDto.getMetric());
                  metric.setTags(metricDto.getTags());
                  if (metricDto.getMetatags() != null) {
                      metric.setMetatagsRecord(new MetatagsRecord(metricDto.getMetatags(), metricDto.getMetatagsKey()));
                  }
  
                  copyProperties(metric, metricDto);
                  legalMetrics.add(metric);
              } catch (Exception e) {
                  illegalMetrics.add(metricDto);
                  errorMessages.add(e.getMessage());
              }
          }
          _collectionService.submitMetrics(remoteUser, legalMetrics);
  
          Map<String, Object> result = new HashMap<>();
  
          result.put("Success", legalMetrics.size() + " metrics");
          result.put("Error", illegalMetrics.size() + " metrics");
          result.put("Error Messages", errorMessages);
          return result;
      }
docs: Submits externally collected metric data.
  
  @param   req         The HTTP request.
  @param   metricDtos  The metric DTOs to submit.
  
  @return  The number of metrics that were submitted, and the number of errors encountered.