diff --git a/backend/ISLInterfaces/Features/CaseAccess/CaseAccessService.cs b/backend/ISLInterfaces/Features/CaseAccess/CaseAccessService.cs index ded9ce77..95a02b73 100644 --- a/backend/ISLInterfaces/Features/CaseAccess/CaseAccessService.cs +++ b/backend/ISLInterfaces/Features/CaseAccess/CaseAccessService.cs @@ -18,6 +18,12 @@ public class CaseAccessService(DiamReadOnlyContext context, ILogger caseSearchCount = instrumentation.CaseSearchCount; private readonly Counter caseActiveUsersCount = instrumentation.CaseActiveUsersCount; + + /// + /// Get users that are currently active on a case + /// + /// + /// public async Task> GetCaseAccessUsersAsync(string rccNumber) { this.logger.LogInformation($"Getting users on case {rccNumber}"); @@ -28,14 +34,16 @@ public async Task> GetCaseAccessUsersAsync(string rccNumber) logger.LogError("Unable to connect to database - check connection info"); } - var result = await this.context.SubmittingAgencyRequests - .Where(access => access.RCCNumber == rccNumber && (access.RequestStatus == AgencyRequestStatus.Complete || access.RequestStatus == AgencyRequestStatus.Pending)) - .Include(party => party.Party) - .OrderBy(access => access.RequestedOn) - .Select(access => access.Party.Jpdid) - .ToListAsync(); - this.caseActiveUsersCount.Add(result.Count); - return result; + List results = []; + + results = await this.context.SubmittingAgencyRequests + .Where(access => access.RCCNumber == rccNumber && (access.RequestStatus == AgencyRequestStatus.Complete || access.RequestStatus == AgencyRequestStatus.Pending || access.RequestStatus == AgencyRequestStatus.Submitted)) + .Include(party => party.Party) + .OrderBy(access => access.RequestedOn) + .Select(access => access.Party.Jpdid) + .ToListAsync(); + this.caseActiveUsersCount.Add(results.Count); + return results; } } diff --git a/backend/ISLInterfaces/ISLInterfacesConfiguration.cs b/backend/ISLInterfaces/ISLInterfacesConfiguration.cs index b88ac7a7..801d7dc7 100644 --- a/backend/ISLInterfaces/ISLInterfacesConfiguration.cs +++ b/backend/ISLInterfaces/ISLInterfacesConfiguration.cs @@ -10,10 +10,17 @@ public class ISLInterfacesConfiguration public KeycloakConfiguration Keycloak { get; set; } = new(); public const string KeycloakConfig = "Keycloak"; public const string DatabaseConnectionInfoConfig = "DatabaseConnectionInfo"; - + public SplunkConfiguration SplunkConfig { get; set; } = new(); public ConnectionStringConfiguration DatabaseConnectionInfo { get; set; } = new(); } +public class SplunkConfiguration +{ + public string Host { get; set; } = string.Empty; + public string CollectorToken { get; set; } = string.Empty; +} + + public class ConnectionStringConfiguration { public string CaseManagementDataStore { get; set; } = string.Empty; diff --git a/backend/ISLInterfaces/Program.cs b/backend/ISLInterfaces/Program.cs index 1f7614d7..1e0d2c1b 100644 --- a/backend/ISLInterfaces/Program.cs +++ b/backend/ISLInterfaces/Program.cs @@ -13,6 +13,7 @@ namespace ISLInterfaces; using OpenTelemetry.Resources; using Prometheus; using Serilog; +using Serilog.Events; public class Program { @@ -70,6 +71,29 @@ public static void Main(string[] args) app.UseSwagger(); app.UseSwaggerUI(); } + var loggerConfig = new LoggerConfiguration(); + + + + var splunkHost = Environment.GetEnvironmentVariable("SplunkConfig__Host"); + splunkHost ??= builder.Configuration.GetValue("SplunkConfig:Host"); + var splunkToken = Environment.GetEnvironmentVariable("SplunkConfig__CollectorToken"); + splunkToken ??= builder.Configuration.GetValue("SplunkConfig:CollectorToken"); + + if (string.IsNullOrEmpty(splunkHost) || string.IsNullOrEmpty(splunkToken)) + { + Console.WriteLine("Splunk Host or Token is not configured - check Splunk environment"); + Environment.Exit(-1); + } + else + { + Log.Information($"Logging to splunk host {splunkHost}"); + } + + + loggerConfig + .MinimumLevel.Verbose() + .WriteTo.EventCollector(splunkHost, splunkToken, restrictedToMinimumLevel: LogEventLevel.Debug); Action configureResource = r => r.AddService( diff --git a/backend/ISLInterfaces/appsettings.json b/backend/ISLInterfaces/appsettings.json index cafbfed3..32214cfc 100644 --- a/backend/ISLInterfaces/appsettings.json +++ b/backend/ISLInterfaces/appsettings.json @@ -16,5 +16,9 @@ "Schema": "diam", "EfHistorySchema": "public" }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "SplunkConfig": { + "Host": "localhost", + "CollectorToken": "" + } } diff --git a/backend/common/Common.csproj b/backend/common/Common.csproj index 9e6d7fb0..bb4afe93 100644 --- a/backend/common/Common.csproj +++ b/backend/common/Common.csproj @@ -58,13 +58,13 @@ - + - +