예제 #1
0
        public IActionResult GetMetricsByPercentileFromAgent(
            [FromRoute] DateTimeOffset fromTime,
            [FromRoute] DateTimeOffset toTime,
            [FromRoute] Percentile percentile)
        {
            var metrics          = _repository.GetByPeriodWithSorting(fromTime, toTime, "value");
            var percentileMetric = metrics.Cast <NetworkMetric>().SingleOrDefault(i => i.Value == PercentileCalculator.Calculate(GetListValuesFromMetrics(metrics), (double)percentile / 100.0));
            var response         = new AllNetworkMetricsResponse()
            {
                Metrics = new List <NetworkMetricDto>()
            };

            response.Metrics.Add(_mapper.Map <NetworkMetricDto>(percentileMetric));

            _logger.LogInformation($"Запрос персентиля метрик Network за период с {fromTime} по {toTime}");

            return(Ok(response));
        }