forked from ddrilling/AsbCloudServer
93 lines
3.0 KiB
C#
93 lines
3.0 KiB
C#
using AsbCloudApp.Data;
|
|
using AsbCloudApp.Services;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Collections.Generic;
|
|
|
|
namespace AsbCloudWebApi.Controllers
|
|
{
|
|
|
|
/// <summary>
|
|
/// Мониторинг запросов, ошибок, пользователей
|
|
/// </summary>
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
[Authorize]
|
|
public class RequestTrackerController : ControllerBase
|
|
{
|
|
private readonly IRequerstTrackerService service;
|
|
|
|
public RequestTrackerController(IRequerstTrackerService service)
|
|
{
|
|
this.service = service;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Получить последние `take` запросов к серверу
|
|
/// </summary>
|
|
/// <param name="take">от 1 до 1000</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[Permission]
|
|
public IActionResult GetAll(int take = 512)
|
|
{
|
|
var result = service.GetAll(take);
|
|
return Ok(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Получить последние `take` быстрых запросов к серверу
|
|
/// </summary>
|
|
/// <param name="take">от 1 до 1000</param>
|
|
/// <returns></returns>
|
|
[HttpGet("fast")]
|
|
[Permission]
|
|
public IActionResult GetFast(int take = 512)
|
|
{
|
|
var result = service.GetFast(take);
|
|
return Ok(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Получить последние `take` медленных запросов к серверу
|
|
/// </summary>
|
|
/// <param name="take">от 1 до 1000</param>
|
|
/// <returns></returns>
|
|
[HttpGet("slow")]
|
|
[Permission]
|
|
public IActionResult GetSlow(int take = 512)
|
|
{
|
|
var result = service.GetSlow(take);
|
|
return Ok(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Получить последние `take` ошибок при выполнении запросов
|
|
/// </summary>
|
|
/// <param name="take">от 1 до 1000</param>
|
|
/// <returns></returns>
|
|
[HttpGet("error")]
|
|
[Permission]
|
|
public IActionResult GetError(int take = 512)
|
|
{
|
|
var result = service.GetError(take);
|
|
return Ok(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Получить последних пользователей обращавшихся к серверу. Уникальность пользователя проверяется по логину и Ip.
|
|
/// </summary>
|
|
/// <param name="take">от 1 до 1000</param>
|
|
/// <returns></returns>
|
|
[HttpGet("users")]
|
|
[Permission]
|
|
[ProducesResponseType(typeof(IEnumerable<RequestLogUserDto>), (int)System.Net.HttpStatusCode.OK)]
|
|
public IActionResult GetUsersStat(int take = 512)
|
|
{
|
|
var result = service.GetUsersStat(take);
|
|
return Ok(result);
|
|
}
|
|
}
|
|
|
|
}
|