This repository contains a Terraform configuration to deploy a complete monitoring stack on Kubernetes in AWS, focused on the eu-north-1 region. The stack includes:
- Prometheus
- Grafana
- Node Exporter
- Kube State Metrics
- AWS CloudWatch Exporter
- Alertmanager
- AWS CLI configured with appropriate permissions
- Terraform installed (version 1.0+)
- kubectl installed and configured to connect to your Kubernetes cluster
- Helm 3 installed
- Clone this repository:
git clone https://github.com/pooyanazad/k8s-monitoring-stack.git
cd k8s-monitoring-stack
- Initialize Terraform:
terraform init
- Review the Terraform plan:
terraform plan
- Apply the configuration:
terraform apply
- Access Grafana:
# Get the Grafana admin password
kubectl get secret --namespace monitoring grafana -o jsonpath="{.data.admin-password}" | base64 --decode
# Port-forward to access Grafana
kubectl port-forward --namespace monitoring svc/grafana 3000:80
Then open your browser and navigate to http://localhost:3000
- Update the
cloudwatch-exporter-config.ymlfile to monitor additional AWS services - Modify the
alertmanager.ymlfile to configure different notification channels - Add or modify dashboard configurations in
grafana-dashboards.yaml - Update alert rules in
prometheus-rules.yml
main.tf: Main Terraform configuration filecloudwatch-exporter-config.yml: Configuration for AWS CloudWatch metrics to collectalertmanager.yml: Alertmanager configuration with notification settingsgrafana-dashboards.yaml: Grafana dashboard configurationsprometheus-rules.yml: Prometheus alerting rules
- The default Grafana admin password is set to
adminin the Terraform code. Change this for production use. - Update the Slack webhook URL in
alertmanager.ymlbefore deploying. - Make sure your AWS credentials have permissions to read CloudWatch metrics.