How bpabon/api-gateway-kong-grafana-prometheus-nginx-alertmanager works
Project Type and Purpose
• This is a full-stack, container-based orchestration project combining:
• An API Gateway (Kong)
• A sample microservice (NestJS) exposing public & JWT-protected routes
• A reverse proxy / SSL termination layer (NGINX + Certbot)
• A complete observability stack (Prometheus, Grafana, Alertmanager, Blackbox Exporter)
• Alerting via SMTP email
• The goal is to route client traffic through NGINX → Kong → NestJS, while collecting metrics, visualizing dashboards, and sending alerts.
File-Structure Analysis
• Top level:
• docker-compose.yml – service orchestration
• init-letsencrypt.sh & certbot configs – SSL certificate bootstrap
• public.key & .env.example – JWT and email settings
• Service directories:
• kong/ (kong.conf, kong.yml) – gateway config
• nginx/ (nginx.conf) – reverse proxy config
• nestjs-service/ – NestJS code, Dockerfile, routes under src/public & src/protected
• prometheus/ (prometheus.yml, alert.rules.yml)
• grafana/ (provisioning dashboards & datasources)
• alertmanager/ (alertmanager.yml, routing, SMTP settings)
• blackbox/ (blackbox.yml)
README Insights
Client → HTTPS → NGINX → Kong → NestJS
└─/metrics→ Prometheus → Alertmanager → Email
└→ Grafana → Admin
• Lists service ports, security approach (JWT RS256), and SSL setup steps.
Main Components
a. Edge Layer
• Client (Browser or External Consumer)
• Domain DNS / hosts file (midominio.com)
b. Ingress / SSL Termination
• NGINX container (80/443) with Certbot hooks
c. API Gateway
• Kong container (public proxy on 8000/8443, admin on 8001/8444)
• JWT plugin configured (public vs protected routes)
d. Microservice
• NestJS service (port 3000 inside Docker)
• PublicController & ProtectedController
e. Observability
• Prometheus server scraping:
• Kong (/metrics)
• NestJS metrics if exposed
• Blackbox Exporter (9115)
• Alertmanager (9093) routing alerts via SMTP
• Grafana (3001) dashboards provisioned for Kong/Prometheus
f. External Systems
• SMTP server (e.g., Gmail)
• Certbot ACME endpoint
Relationships and Data Flows
Client → (HTTPS) → NGINX → (proxy_pass) → Kong → NestJS
Kong → (metrics endpoint) → Prometheus
Prometheus → Alertmanager → (email alerts) → User
Prometheus → Grafana → Administrator
Prometheus → Blackbox Exporter → target endpoints (HTTP(s) health checks)
• Docker network links implicitly connecting all containers.
Architectural Patterns & Principles
• Edge-Gateway-Backend separation
• Microservices behind an API Gateway
• Side-car-style observability (Prometheus + exporters)
• Declarative provisioning (Grafana dashboards via YAML)
• Infrastructure as Code (docker-compose, shell scripts)
Detail Checklist
• Following elements:
• Client / DNS entry
• NGINX + Certbot
• Kong (public vs admin APIs)
• NestJS microservice (public & protected endpoints)
• Prometheus & Blackbox Exporter
• Alertmanager → SMTP
• Grafana Dashboard
• Don’t overthink: break the system into as many meaningful components as possible and represent each separately.