Skip to content

Hadzab/monitor-saude-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📊 Monitor Saúde API

REST API for monitoring external services with Discord alerts.
API REST para monitoramento de serviços externos com alertas via Discord.

🇺🇸 English | 🇧🇷 Português


🇺🇸 English Version

📌 Overview

A backend application built with Java and Spring Boot designed to automatically monitor external services. It periodically checks registered URLs, stores their status history (UP/DOWN), and sends Discord alerts whenever status changes occur.

  • ✔ Layered architecture (controller → service → repository)
  • ✔ DTO separation between persistence and API models
  • ✔ Scheduled automatic monitoring (every 60 seconds)
  • ✔ Discord webhook integration
  • ✔ Persistent history using H2 in-memory database
  • ✔ Clean RESTful endpoints

🚀 Automatic Monitoring

  • ✔ Runs every 60 seconds
  • ✔ Checks all enabled services
  • ✔ Stores history for each check
  • ✔ Sends alerts when status changes

If no service is registered or enabled, the monitoring process (AutoCheck) continues running normally. In this case, the following message will appear in the application console/log:

⚠ No registered or enabled services.

📊 Main Endpoints

MethodEndpointDescription
GET/healthCheck if API is running
GET/servicesList all services
POST/servicesCreate new service
PUT/services/{id}Update service
DELETE/services/{id}Delete service
GET/services/{id}/historyService history

📥 Running Locally

git clone https://github.com/Hadzab/monitor-saude-api.git
cd monitor-saude-api
mvn clean install
mvn spring-boot:run

Access:

http://localhost:8080/health

🧪 Testing the API (Postman / Insomnia)

You can test the endpoints using Postman, Insomnia, or any REST client.

Base URL:

http://localhost:8080

Example – Create Service:

POST http://localhost:8080/services

{
  "name": "Netflix",
  "url": "https://www.netflix.com"
}

Example – Get All Services:

GET http://localhost:8080/services

Example – Get Service History:

GET http://localhost:8080/services/{id}/history

📬 Discord Webhook Configuration

Add to application.properties:

discord.webhook.url=

⚠ Do NOT commit your webhook URL.


🚀 Future Improvements

  • Authentication & Authorization
  • Monitoring dashboard
  • Email/SMS alerts
  • Dynamic interval configuration

🇧🇷 Versão em Português

📌 Visão Geral

Aplicação backend desenvolvida em Java com Spring Boot para monitoramento automático de serviços externos. Verifica URLs periodicamente, registra histórico de status (UP/DOWN) e envia alertas ao Discord quando há mudanças.

  • ✔ Arquitetura em camadas (controller → service → repository)
  • ✔ Uso de DTOs separando modelo de persistência da API
  • ✔ Monitoramento automático a cada 60 segundos
  • ✔ Integração com webhook do Discord
  • ✔ Histórico persistido com banco H2 em memória
  • ✔ Endpoints REST organizados

🚀 Monitoramento Automático

  • ✔ Executa a cada 60 segundos
  • ✔ Verifica todos os serviços habilitados
  • ✔ Armazena histórico de cada verificação
  • ✔ Envia alertas quando o status muda

Caso nenhum serviço esteja cadastrado ou habilitado, o processo de monitoramento (AutoCheck) continua sendo executado normalmente. Nesse caso, a seguinte mensagem será exibida no console/log da aplicação:

⚠ Nenhum serviço cadastrado ou habilitado.

📊 Endpoints Principais

MétodoEndpointDescrição
GET/healthVerifica se a API está funcionando
GET/servicesLista todos os serviços
POST/servicesCria novo serviço
PUT/services/{id}Atualiza serviço
DELETE/services/{id}Remove serviço
GET/services/{id}/historyHistórico do serviço

📥 Executando Localmente

git clone https://github.com/Hadzab/monitor-saude-api.git
cd monitor-saude-api
mvn clean install
mvn spring-boot:run

Acesse por:

http://localhost:8080/health

🧪 Testando a API (Postman / Insomnia)

Você pode testar os endpoints utilizando Postman, Insomnia ou qualquer cliente REST.

URL base:

http://localhost:8080

Exemplo – Criar Serviço:

POST http://localhost:8080/services

{
  "name": "Netflix",
  "url": "https://www.netflix.com"
}

Exemplo – Listar Serviços:

GET http://localhost:8080/services

Exemplo – Histórico do Serviço:

GET http://localhost:8080/services/{id}/history

📬 Configuração do Webhook do Discord

Adicionar no application.properties:

discord.webhook.url=

⚠ Não comite sua URL de webhook.


🚀 Próximas Melhorias

  • Autenticação e autorização
  • Dashboard de monitoramento
  • Alertas por e-mail/SMS
  • Configuração dinâmica de intervalos

🧡 Autor

Hadassa — Java Backend Developer

⭐ Se você gostou deste projeto, deixe uma estrela no GitHub!


📄 Licença

Este projeto está licenciado sob a Licença MIT.

About

Procuction-style Spring Boot REST API that monitors external services, tracks uptime history and sends automated Discord alerts

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages