English | Portugues
Plataforma centralizada de ingestao e busca de logs com retencao configuravel, dashboard SignalR e analytics.
RVM.LogStream e uma plataforma centralizada de logs que permite ingestao em batch, busca avancada por multiplos filtros (source, level, query, correlationId, date range), politicas de retencao configuraveis por source e analytics de volume por level/source. O sistema utiliza SignalR para push em tempo real de novos logs e oferece um pipeline completo de observabilidade.
| Camada | Stack |
|---|---|
| Runtime | .NET 10, ASP.NET Core 10 |
| Real-time | SignalR |
| ORM | Entity Framework Core 10 |
| Banco de Dados | PostgreSQL (Npgsql 10.0.1) |
| Logging | Serilog + Compact JSON |
| Autenticacao | API Key (header X-API-Key) |
| Testes | xUnit 2.9, Moq 4.20, EF Core InMemory |
| Containerizacao | Docker, Docker Compose |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β API Layer β
β βββββββββββββββ ββββββββββββ βββββββββββββββββββββ β
β β Ingestion β β Search β β Retention/Stats β β
β β Controller β βControllerβ β Controllers β β
β ββββββββ¬βββββββ ββββββ¬ββββββ ββββββββββ¬βββββββββββ β
β β β β β
β ββββββββΌβββββββ ββββββΌββββββ βββββββββΌβββββββββββ β
β β Ingestion β β Search β β RetentionWorker β β
β β Service β β Service β β (BackgroundService)β β
β ββββββββ¬βββββββ ββββββ¬ββββββ βββββββββ¬βββββββββββ β
β β β β β
β ββββββββΌββββββββββββββΌβββββββββββββββββΌβββββββββββ β
β β SignalR Hub (Push) β β
β ββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β Domain Layer β
β ββββββββββββββ βββββββββββββ βββββββββββββββββββββ β
β β LogEntry β β LogSource β β RetentionPolicy β β
β ββββββββββββββ βββββββββββββ βββββββββββββββββββββ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Repository Interfaces β β
β ββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β Infrastructure Layer β
β ββββββββββββββββββββββΌββββββββββββββββββββββββββββ β
β β LogStreamDbContext (EF Core) β β
β β PostgreSQL + Npgsql β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Repository Implementations β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
RVM.LogStream/
βββ src/
β βββ RVM.LogStream.API/
β β βββ Auth/
β β β βββ ApiKeyAuthHandler.cs
β β β βββ ApiKeyAuthOptions.cs
β β βββ Controllers/
β β β βββ IngestionController.cs
β β β βββ RetentionController.cs
β β β βββ SearchController.cs
β β β βββ SourcesController.cs
β β β βββ StatsController.cs
β β βββ Dtos/
β β β βββ IngestionDtos.cs
β β β βββ RetentionDtos.cs
β β β βββ SearchDtos.cs
β β β βββ SourceDtos.cs
β β β βββ StatsDtos.cs
β β βββ Health/
β β β βββ DatabaseHealthCheck.cs
β β βββ Hubs/
β β β βββ LogStreamHub.cs
β β βββ Middleware/
β β β βββ CorrelationIdMiddleware.cs
β β βββ Services/
β β β βββ LogIngestionService.cs
β β β βββ LogSearchService.cs
β β β βββ RetentionWorker.cs
β β βββ Program.cs
β β βββ appsettings.json
β βββ RVM.LogStream.Domain/
β β βββ Entities/
β β β βββ LogEntry.cs
β β β βββ LogSource.cs
β β β βββ RetentionPolicy.cs
β β βββ Enums/
β β β βββ LogLevel.cs
β β βββ Interfaces/
β β β βββ ILogEntryRepository.cs
β β β βββ ILogSourceRepository.cs
β β β βββ IRetentionPolicyRepository.cs
β β βββ Models/
β β βββ AggregationModels.cs
β βββ RVM.LogStream.Infrastructure/
β βββ Data/
β β βββ Configurations/
β β β βββ LogEntryConfiguration.cs
β β β βββ LogSourceConfiguration.cs
β β β βββ RetentionPolicyConfiguration.cs
β β βββ LogStreamDbContext.cs
β βββ Repositories/
β β βββ LogEntryRepository.cs
β β βββ LogSourceRepository.cs
β β βββ RetentionPolicyRepository.cs
β βββ DependencyInjection.cs
βββ test/
β βββ RVM.LogStream.Test/
β βββ Domain/
β β βββ EntityTests.cs
β βββ Infrastructure/
β β βββ LogEntryRepositoryTests.cs
β β βββ LogSourceRepositoryTests.cs
β β βββ RetentionPolicyRepositoryTests.cs
β βββ Services/
β βββ LogIngestionServiceTests.cs
βββ docker-compose.dev.yml
βββ docker-compose.prod.yml
βββ RVM.LogStream.slnx
- .NET 10 SDK
- PostgreSQL (ou Docker)
- Clone o repositorio:
git clone https://github.com/rvenegas5/RVM.LogStream.git
cd RVM.LogStream- Configure a connection string e API keys via variaveis de ambiente ou
appsettings.json:
{
"ConnectionStrings": {
"DefaultConnection": "Host=localhost;Database=rvmlogstream;Username=postgres;Password=sua_senha"
},
"ApiKeys": {
"Keys": [
{ "Key": "sua-api-key", "AppId": "app-1", "Name": "MeuApp" }
]
},
"Retention": {
"CheckIntervalMinutes": 60
}
}- Execute a aplicacao:
cd src/RVM.LogStream.API
dotnet rundocker compose -f docker-compose.dev.yml up -dA API ficara disponivel em http://localhost:8080.
Todos os endpoints requerem autenticacao via header X-API-Key.
| Metodo | Rota | Descricao |
|---|---|---|
POST |
/api/ingestion |
Ingestao de logs em batch |
Request body:
{
"events": [
{
"timestamp": "2026-04-09T12:00:00Z",
"level": "Error",
"message": "Falha na conexao",
"messageTemplate": null,
"source": "payments-api",
"correlationId": "abc-123",
"properties": "{\"key\":\"value\"}",
"exception": "NullReferenceException"
}
]
}Response: { "accepted": 1, "rejected": 0 }
| Metodo | Rota | Descricao |
|---|---|---|
GET |
/api/search |
Busca com filtros avancados |
Query parameters: query, source, level, correlationId, from, to, offset, limit
| Metodo | Rota | Descricao |
|---|---|---|
GET |
/api/sources |
Listar todas as sources |
GET |
/api/sources/{name} |
Buscar source por nome |
| Metodo | Rota | Descricao |
|---|---|---|
GET |
/api/retention |
Listar politicas de retencao |
GET |
/api/retention/{id} |
Buscar politica por ID |
POST |
/api/retention |
Criar politica de retencao |
PUT |
/api/retention/{id} |
Atualizar politica |
DELETE |
/api/retention/{id} |
Remover politica |
| Metodo | Rota | Descricao |
|---|---|---|
GET |
/api/stats |
Volume por level e por source |
Query parameters: source, from, to
| Protocolo | Rota | Descricao |
|---|---|---|
| SignalR | /hubs/log-stream |
Push em tempo real de novos logs |
Eventos: LogReceived | Grupos: JoinSourceGroup(source), LeaveSourceGroup(source)
| Metodo | Rota | Descricao |
|---|---|---|
GET |
/health |
Verificacao de saude (publico) |
O projeto possui 44 testes cobrindo domain, infrastructure e services.
dotnet test| Suite | Arquivo | Testes |
|---|---|---|
| Domain | EntityTests.cs |
12 (6 Fact + 1 Theory x6 InlineData) |
| Infrastructure | LogEntryRepositoryTests.cs |
12 |
| Infrastructure | LogSourceRepositoryTests.cs |
5 |
| Infrastructure | RetentionPolicyRepositoryTests.cs |
8 |
| Services | LogIngestionServiceTests.cs |
7 |
| Total | 44 |
- xUnit 2.9 - Framework de testes
- Moq 4.20 - Mocking para services
- EF Core InMemory - Banco em memoria para testes de repositorio
- Ingestao em batch - Envio de multiplos log entries em uma unica requisicao
- Busca avancada - Filtros por source, level, query, correlationId e date range
- Politicas de retencao - Configuracao de retencao por source com pattern matching
- RetentionWorker - BackgroundService que aplica politicas de retencao automaticamente
- Analytics de volume - Agregacao de logs por level e por source
- SignalR push - Notificacao em tempo real de novos logs via WebSocket
- 6 niveis de log - Trace, Debug, Information, Warning, Error, Fatal
- Paginacao - Offset/limit com clamp (max 200 por pagina)
- Correlation ID - Middleware que propaga ou gera X-Correlation-ID
- Rate limiting - 60 requisicoes/minuto por IP
- API Key auth - Autenticacao por chave com identificacao de app
- Health check - Endpoint
/healthcom verificacao de conectividade do banco - Docker ready - Docker Compose para dev e prod com rede
rvmtech
Desenvolvido por RVM Tech