Exemplo n.º 1
0
        public IActionResult GetMetricsFromAllCluster([FromRoute] DateTimeOffset fromTime, [FromRoute] DateTimeOffset toTime)
        {
            var response = _repository.GetByPeriod(fromTime, toTime);

            _logger.LogInformation("GetMetricsFromAllCluster_Ram:", " fromTime: ", fromTime.ToString(), " toTime: ", toTime.ToString());

            return(Ok(response));
        }
Exemplo n.º 2
0
        public IActionResult GetMetricsAllCluster([FromRoute] DateTimeOffset fromTime, [FromRoute] DateTimeOffset toTime)
        {
            _logger.LogInformation("RamControllerCluster FromTime:{0} ToTime {1}", fromTime, toTime);
            var metrics = _repository.GetByPeriod(new PeriodArgs()
            {
                FromTime = fromTime, ToTime = toTime
            });

            var response = new ByPeriodRamMetricResponse()
            {
                Metrics = _mapper.Map <IEnumerable <RamMetric>, List <RamMetricDto> >((IEnumerable <RamMetric>)metrics)
            };

            return(Ok(response));
        }
Exemplo n.º 3
0
            public async Task <RamMetricResponse> Handle(RamMetricGetByPeriodQuery request, CancellationToken cancellationToken)
            {
                var result = await Task.Run(() =>
                {
                    var metricsList = _repository.GetByPeriod(request.FromTime, request.ToTime);

                    var response = new RamMetricResponse();

                    response.Metrics.AddRange(_mapper.Map <List <RamMetricDto> >(metricsList));

                    return(response);
                });

                return(result);
            }
Exemplo n.º 4
0
        public IActionResult GetByPeriod([FromRoute] DateTimeOffset fromTime, [FromRoute] DateTimeOffset toTime)
        {
            _logger.LogInformation($"Запрос метрик за период c {fromTime:f} по {toTime:f}");
            var metrics = _repository.GetByPeriod(fromTime, toTime);

            var response = new ListRamMetricsResponse()
            {
                Metrics = new List <RamMetricResponse>()
            };

            foreach (var metric in metrics)
            {
                response.Metrics.Add(_mapper.Map <RamMetricResponse>(metric));
            }

            return(Ok(response));
        }
Exemplo n.º 5
0
        public IActionResult GetMetricsFromAllCluster(
            [FromRoute] DateTimeOffset fromTime,
            [FromRoute] DateTimeOffset toTime)
        {
            var metrics  = _repository.GetByPeriod(fromTime, toTime);
            var response = new AllRamMetricsResponse()
            {
                Metrics = new List <RamMetricManagerDto>()
            };

            foreach (var metric in metrics)
            {
                response.Metrics.Add(_mapper.Map <RamMetricManagerDto>(metric));
            }

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

            return(Ok(response));
        }
Exemplo n.º 6
0
 public IActionResult GetMetricsFromAgent([FromRoute] DateTimeOffset fromTime, [FromRoute] DateTimeOffset toTime)
 {
     try
     {
         _logger.Debug($"Route(api/metrics/ram): Running the GetMetricsFromAgent method");
         var metrics  = _repository.GetByPeriod(fromTime, toTime);
         var response = new MetricsResponse <RamMetricsDto>();
         foreach (var item in metrics)
         {
             response.Metrics.Add(_mapper.Map <RamMetricsDto>(item));
         }
         _logger.Debug($"Route(api/metrics/ram): GetMetricsFromAgent method completed successfully");
         return(Ok(response.Metrics.ToList()));
     }
     catch (Exception e)
     {
         _logger.Error(e);
         return(BadRequest(e.Message));
     }
 }
        public IActionResult GetMetricsFromAgent([FromRoute] DateTimeOffset fromTime, [FromRoute] DateTimeOffset toTime)
        {
            var config = new MapperConfiguration(cfg => cfg.CreateMap <RamMetric, RamMetricDto>());

            var m = config.CreateMapper();

            var metrics = _repository.GetByPeriod(fromTime, toTime);

            var response = new RamAllMetricsResponse()
            {
                Metrics = new List <RamMetricDto>()
            };

            foreach (var metric in metrics)
            {
                response.Metrics.Add(m.Map <RamMetricDto>(metric));
            }

            _logger.LogInformation(string.Concat("GetMetricsFromAgent_Ram: ", " fromTime: ", fromTime.ToString(), " toTime: ", toTime.ToString()));

            return(Ok(response));
        }
Exemplo n.º 8
0
 public IList <RamMetric> GetRamMetricsByPeriod(DateTimeOffset fromTime, DateTimeOffset toTime, int agentId = 0)
 {
     return(_ramMetricsRepository.GetByPeriod(fromTime, toTime, agentId));
 }