feat(logs): remontée des logs agents vers le central — buffer, API, UI (Fixes #50 #51 #52)

- Agent : LogBufferService (ring buffer borné, drop-oldest), AgentLoggingProvider
  (capture ILogger non-bloquante), LogSanitizer (masque password/token/secret/bearer),
  LogUploadService (batch POST /api/agents/{id}/logs, retry, drop si 400)
- Central : entité AgentLogEntry + migration AddAgentLogEntries (index AgentId+TimestampUtc),
  SubmitAgentLogsCommand (batch <= 200, entrées invalides ignorées),
  GetAgentLogsQuery (pagination, filtres niveau/période/recherche),
  endpoints POST + GET /api/agents/{id}/logs
- UI : onglet Logs dans AgentDetail (filtres, pagination, auto-refresh toggle)
- Logs agent enrichis : heartbeat succès (Debug), résolution IP (Debug)
- Tests : LogBufferServiceTests (6), AgentDetailLogsTests (4), handlers AgentLogs (8)
This commit is contained in:
Arnaud Dartois committed 2026-08-11 18:51:52 +02:00
1 parent ab705e72fa
commit 0136bf33ec
28 files changed
+3261 -3

No files matched your search

+8
View File
@@ -1,9 +1,11 @@
using Sentry.AspNetCore;
using Heimdall.Agent;
using Heimdall.Agent.Logging;
using Heimdall.Agent.Services;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
var builder = WebApplication.CreateSlimBuilder(args);
@@ -69,6 +71,12 @@ builder.Services.AddHostedService<AgentRegistrationService>();
builder.Services.AddHostedService<ConfigReceiverService>();
builder.Services.AddHostedService<AgentDiscoveryService>();
// Log capture & upload to Central (ticket #50)
builder.Services.AddSingleton<LogBufferService>();
builder.Services.AddSingleton<AgentLoggingProvider>();
builder.Services.AddSingleton<ILoggerProvider>(sp => sp.GetRequiredService<AgentLoggingProvider>());
builder.Services.AddHostedService<LogUploadService>();
// Health checks — used by Docker HEALTHCHECK
builder.Services.AddHealthChecks()
.AddCheck<AgentHealthCheck>("agent_health", tags: ["ready"]);