diff --git a/PARR.API/Contracts/V1/Responses/Statistics/StatRobotStateResponse.cs b/PARR.API/Contracts/V1/Responses/Statistics/StatRobotStateResponse.cs index 7695dacf..5735cf55 100644 --- a/PARR.API/Contracts/V1/Responses/Statistics/StatRobotStateResponse.cs +++ b/PARR.API/Contracts/V1/Responses/Statistics/StatRobotStateResponse.cs @@ -5,5 +5,7 @@ public DateTimeOffset Date { get; set; } public int IsUp { get; set; } + + public string? Ip { get; set; } } } diff --git a/PARR.API/Controllers/V1/Statistics/StatRobotStateController.cs b/PARR.API/Controllers/V1/Statistics/StatRobotStateController.cs index 561e8b63..54b0a469 100644 --- a/PARR.API/Controllers/V1/Statistics/StatRobotStateController.cs +++ b/PARR.API/Controllers/V1/Statistics/StatRobotStateController.cs @@ -9,6 +9,7 @@ using PARR.API.Contracts.V1.Requests.Queries; using PARR.API.Contracts.V1.Responses.Base; using PARR.API.Contracts.V1.Responses.Statistics; using PARR.API.Controllers.V1.Base; +using PARR.API.Services.Interfaces; using PARR.API.Settings; using PARR.Constants; using PARR.DAL.InfluxDbServices; @@ -26,18 +27,21 @@ namespace PARR.API.Controllers.V1.Statistics private readonly IValidator validator; private readonly InfluxDbSettings influxDbSettings; private readonly MonitoringSettings monitoringSettings; + private readonly IClientService clientService; public StatRobotStateController( IInfluxDbService influxDbService, IValidator validator, InfluxDbSettings influxDbSettings, - MonitoringSettings monitoringSettings + MonitoringSettings monitoringSettings, + IClientService clientService ) { this.influxDbService = influxDbService; this.validator = validator; this.influxDbSettings = influxDbSettings; this.monitoringSettings = monitoringSettings; + this.clientService = clientService; } @@ -81,7 +85,8 @@ namespace PARR.API.Controllers.V1.Statistics table.Records.Select(record => new StatRobotStateResponse { Date = (DateTimeOffset)record.GetTimeInDateTime(), - IsUp = int.Parse(record.GetValue()?.ToString() ?? "0") + IsUp = int.Parse(record.GetValue()?.ToString() ?? "0"), + Ip = record.GetValueByKey("ip")?.ToString() }) ); }, influxDbSettings.Robots!.Token); @@ -112,6 +117,7 @@ namespace PARR.API.Controllers.V1.Statistics { var point = PointData.Measurement("robots") .Tag("robot", request.Robot.ToString()) + .Tag("ip", clientService.GetClientIp()?.ToString()) //.Field("robot", (int)request.Robot) .Field("isUp", 1) .Timestamp(DateTime.UtcNow, WritePrecision.Ns);