A comprehensive demonstration of observability practices in a Go service using Prometheus, Grafana, and AlertManager.
This project demonstrates a complete observability stack for a Go microservice, including:
- Metrics collection with Prometheus
- Visualization with Grafana
- Alerting with AlertManager
- Horizontal Pod Autoscaling
- Kubernetes Ingress configuration
- PostgreSQL database integration
The project consists of the following components:
- Product Service: A Go microservice that manages product data
- PostgreSQL: Database for storing product information
- Prometheus: Metrics collection and storage
- Grafana: Metrics visualization and dashboards
- AlertManager: Alert handling and routing
- Kubernetes: Container orchestration
- Nginx Ingress: External access management
- Horizontal Pod Autoscaler: Automatic scaling based on metrics
- Docker Desktop
- Kubernetes cluster (local or remote)
- kubectl configured
- Go 1.x
- Make (optional)
.
├── cmd/
│ └── server/ # Main application entry point
├── internal/
│ ├── handler/ # HTTP handlers
│ ├── metrics/ # Prometheus metrics
│ ├── model/ # Data models
│ └── repository/ # Database operations
├── k8s/
│ ├── alertmanager/ # AlertManager configuration
│ ├── grafana/ # Grafana configuration
│ ├── ingress/ # Ingress configuration
│ ├── prometheus/ # Prometheus configuration
│ └── *.yaml # Kubernetes manifests
├── docker-compose.yml # Local development setup
├── dockerfile # Container configuration
└── go.mod # Go dependencies
-
Clone the repository
git clone https://github.com/yourusername/go-observability-demo.git cd go-observability-demo
-
Build the application
go build -o productservice ./cmd/server
-
Deploy to Kubernetes
kubectl apply -f k8s/
-
Access the services
- Grafana: http://grafana.local
- Prometheus: http://prometheus.local
- Product Service: http://productservice.local
- Collects metrics from the product service
- Stores time-series data
- Provides querying capabilities
- Visualizes metrics from Prometheus
- Custom dashboards for monitoring
- Alert visualization
- Handles alerts from Prometheus
- Routes alerts to appropriate channels
- Manages alert grouping and silencing
- Routes external traffic to services
- Supports multiple domains
- SSL/TLS termination (if configured)
- Automatically scales the product service
- Based on CPU and memory metrics
- Configurable scaling policies
docker-compose up -d
docker build -t go-observability-demo-productservice:latest .
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.