public IActionResult GetMetricsByPercentileFromAgent( [FromRoute] int agentId, [FromRoute] DateTimeOffset fromTime, [FromRoute] DateTimeOffset toTime, [FromRoute] int percentile) { _logger.LogInformation($"GetMetricsByPercentileFromAgent:{agentId} from:{fromTime} to:{toTime} int:{percentile}"); var metrics = _repository.GetByTimePeriodSorted(agentId, fromTime, toTime); var response = new NetworkMetricsResponse() { Metrics = new List<NetworkMetricDto>() }; foreach (var metric in metrics) { response.Metrics.Add(_mapper.Map<NetworkMetricDto>(metric)); } int[] values = new int[response.Metrics.Count()]; for (int i = 0; i < response.Metrics.Count(); i++) { values[i] = response.Metrics[i].Value; } return Ok(PercentileCounter.GetPercentile(values, percentile)); }