Skip to content

Elfarrar/RVM.LogStream

Repository files navigation

English | Portugues

RVM.LogStream

Plataforma centralizada de ingestao e busca de logs com retencao configuravel, dashboard SignalR e analytics.

build tests license dotnet


Sobre

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.


Tecnologias

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

Arquitetura

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     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             β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Estrutura do Projeto

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

Como Executar

Pre-requisitos

Configuracao

  1. Clone o repositorio:
git clone https://github.com/rvenegas5/RVM.LogStream.git
cd RVM.LogStream
  1. 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
  }
}
  1. Execute a aplicacao:
cd src/RVM.LogStream.API
dotnet run

Docker Compose

docker compose -f docker-compose.dev.yml up -d

A API ficara disponivel em http://localhost:8080.


Endpoints da API

Todos os endpoints requerem autenticacao via header X-API-Key.

Ingestao

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 }

Busca

Metodo Rota Descricao
GET /api/search Busca com filtros avancados

Query parameters: query, source, level, correlationId, from, to, offset, limit

Sources

Metodo Rota Descricao
GET /api/sources Listar todas as sources
GET /api/sources/{name} Buscar source por nome

Retencao

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

Estatisticas

Metodo Rota Descricao
GET /api/stats Volume por level e por source

Query parameters: source, from, to

Real-time

Protocolo Rota Descricao
SignalR /hubs/log-stream Push em tempo real de novos logs

Eventos: LogReceived | Grupos: JoinSourceGroup(source), LeaveSourceGroup(source)

Health Check

Metodo Rota Descricao
GET /health Verificacao de saude (publico)

Testes

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

Stack de testes

  • xUnit 2.9 - Framework de testes
  • Moq 4.20 - Mocking para services
  • EF Core InMemory - Banco em memoria para testes de repositorio

Funcionalidades

  • 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 /health com verificacao de conectividade do banco
  • Docker ready - Docker Compose para dev e prod com rede rvmtech

Desenvolvido por RVM Tech

About

Centralized log aggregation platform with search, retention policies & SignalR

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages